## Unlink all contacts from a company

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

Unlinks all linked contacts from a company in one call; the contacts themselves stay in the CRM.

Before unlinking, request the current set with [`GET /v1/companies/:id/contacts`](/docs/entities/companies/contacts-list), so you can restore the links later with [`PUT /v1/companies/:id/contacts`](/docs/entities/companies/contacts-set).

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | Company ID. List: [`GET /v1/companies`](/docs/entities/companies/list) |

## Examples

### curl — personal key

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

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/companies/3123/contacts" \
  -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', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

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

### JavaScript — OAuth application

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

if (res.status === 204) {
  console.log('All contacts 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 — no company with this `id`:

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

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `id` is not a positive integer |
| 404 | `ENTITY_NOT_FOUND` | No company with this `id` |
| 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 contacts' primary company.** For contacts whose primary company was this company, the `companyId` field returns the ID of another of their companies, or `0` if they have no other companies.
- **Retrying is safe.** A call for a company without contacts also returns `204`, so you can repeat the request if the response is lost.

## 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 a contact from a company](/docs/entities/companies/contacts-delete-delete)
- [Contacts](/docs/entities/contacts)
