## Unlink all contacts from a deal

`DELETE /v1/deals/:id/contacts`

Unlinks all contacts from a deal in a single call; the contacts themselves stay in the CRM.

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

## Parameters

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

## Examples

### curl — personal key

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

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/deals/8785/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/deals/8785/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/deals/8785/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 status code, not by the body.

## Response example

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

## Error response example

404 — no deal with this `id`:

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

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `id` is not a positive integer |
| 404 | `ENTITY_NOT_FOUND` | No deal 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 read-only. 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 deal with no contacts also returns `204`, so you can retry the request if the response is lost.

## See also

- [Deal contacts](/docs/entities/deals/contacts)
- [List deal contacts](/docs/entities/deals/contacts-list)
- [Link a contact to a deal](/docs/entities/deals/contacts-create)
- [Replace deal contacts](/docs/entities/deals/contacts-set)
- [Unlink a contact from a deal](/docs/entities/deals/contacts-delete-delete)
- [Contacts](/docs/entities/contacts)
