## Unlink a contact from a company

`DELETE /v1/companies/:id/contacts/:relatedId`

Unlinks one contact from a company; the company's other contacts stay linked. The contact itself stays in the CRM.

To restore the link, use [`POST /v1/companies/:id/contacts`](/docs/entities/companies/contacts-create).

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | Company ID. List: [`GET /v1/companies`](/docs/entities/companies/list) |
| `relatedId` (path) | number | yes | ID of the linked contact — the `contactId` value from [`GET /v1/companies/:id/contacts`](/docs/entities/companies/contacts-list) |

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/companies/3123/contacts/2989" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/companies/3123/contacts/2989" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/companies/3123/contacts/2989', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

if (res.status === 204) {
  console.log('Contact unlinked')
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/companies/3123/contacts/2989', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

if (res.status === 204) {
  console.log('Contact unlinked')
}
```

## Response

On successful unlinking, the API returns HTTP status `204 No Content` with an empty body. Success is indicated by the response code, not the content.

## Response example

```
HTTP/1.1 204 No Content
```

## Error response example

404 — the contact is not linked to this company:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Binding not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `id` or `relatedId` is not a positive integer |
| 404 | `ENTITY_NOT_FOUND` | The contact with this ID is not linked to this company, for example because it was already unlinked. The message is `Binding not found` |
| 404 | `ENTITY_NOT_FOUND` | No company with this `id`. The message is `Not found.` |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |
| 403 | `SCOPE_DENIED` | The key has no `crm` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode. Unlinking requires a key with write access |
| 429 | `RATE_LIMITED` | Rate limit exceeded. Retry after the delay in the `Retry-After` header |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable. Retry the request later |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

- **The contact's primary company.** If this company was the contact's primary company, the contact's `companyId` field returns the ID of another of its companies, or `0` if it has no other companies. The `isPrimary` flag on the contact's remaining links does not change.
- **Retrying after a lost response.** Unlinking the same contact again answers `404` with the message `Binding not found`: the link no longer exists. To check the result, use the [company's contact list](/docs/entities/companies/contacts-list).

## See also

- [Company contacts](/docs/entities/companies/contacts)
- [List company contacts](/docs/entities/companies/contacts-list)
- [Link a contact to a company](/docs/entities/companies/contacts-create)
- [Replace company contacts](/docs/entities/companies/contacts-set)
- [Unlink all contacts from a company](/docs/entities/companies/contacts-delete)
- [Contacts](/docs/entities/contacts)
