## Unlink all contacts from a lead

`DELETE /v1/leads/:id/contacts`

Unlinks all contacts from a lead in one call. The contacts themselves stay in the CRM.

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

## Parameters

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

## Examples

### curl — personal key

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

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/leads/1001321/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/leads/1001321/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/leads/1001321/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 HTTP status `204 No Content` is returned with an empty body. Success is indicated by the status code, not by the content.

## Response example

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

## Error response example

404 — no lead with this `id` exists:

```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 lead with this `id` exists |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens attached |
| 403 | `SCOPE_DENIED` | The key does not have 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 lead without contacts also returns `204`, so you can repeat the request after a lost response.

## See also

- [Lead contacts](/docs/entities/leads/contacts)
- [List lead contacts](/docs/entities/leads/contacts-list)
- [Link a contact to a lead](/docs/entities/leads/contacts-create)
- [Replace lead contacts](/docs/entities/leads/contacts-set)
- [Unlink a contact from a lead](/docs/entities/leads/contacts-delete-delete)
- [Contacts](/docs/entities/contacts)
