## Unlink all companies from a contact

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

Unlinks all linked companies from a contact in one call, without deleting the companies themselves from the CRM.

To restore the bindings later, save the current list with [`GET /v1/contacts/:id/companies`](/docs/entities/contacts/companies-list) before unlinking and pass it to [`PUT /v1/contacts/:id/companies`](/docs/entities/contacts/companies-set).

## Parameters

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

## Examples

### curl — personal key

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

### curl — OAuth application

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

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

### JavaScript — OAuth application

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

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

## Response

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

## Response example

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

## Error response example

404 — there is no contact 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` | There is no contact with this `id` |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | No Bitrix24 tokens are attached to the key |
| 403 | `SCOPE_DENIED` | The key lacks the `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

- **Retrying is safe.** A call for a contact with no companies also returns `204`, so you can repeat the request after a lost response.

## See also

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