## Delete a CRM document

`DELETE /v1/crm-documents/:id`

Deletes a document generated for a CRM record. It cannot be restored through the API — generate a new one if needed.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Document ID, a positive integer. Documents of a record: [`GET /v1/crm-documents`](/docs/entities/documents/crm-list) |

The request has no body.

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/crm-documents/1969" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

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

if (res.status === 204) {
  console.log('Document deleted')
}
```

### JavaScript — OAuth application

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

if (res.status === 204) {
  console.log('Document deleted')
}
```

## Response

On successful deletion, the HTTP status `204 No Content` is returned 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 — no document with this `id` exists, including when the same `id` is deleted again:

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

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `id` is not a positive integer, for example `0` or `abc`. Message: `id must be a positive integer` |
| 404 | `ENTITY_NOT_FOUND` | No document with this `id` exists, or it was already deleted |
| 403 | `BITRIX_ACCESS_DENIED` | No access to the CRM record the document is attached to, including when the record does not exist. Message: `Access denied` |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode |
| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | The key has no tokens mapped to it — an OAuth application key was called without a user session |

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

## See also

- [Documents by CRM record](/docs/entities/documents/crm-list)
- [Get a CRM document](/docs/entities/documents/crm-get)
- [Create a CRM document](/docs/entities/documents/crm-create)
- [Documents](/docs/entities/documents)
