## Delete a CRM document template

`DELETE /v1/crm-document-templates/:id`

Deletes a CRM document template by its ID. A deleted template cannot be restored via the API — create a new one if needed.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Template identifier. List: [`GET /v1/crm-document-templates`](/docs/entities/crm-document-templates/list) |

No request body is sent.

## Examples

### curl — personal key

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

### curl — OAuth application

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

const body = await res.json()
if (body.success) {
  console.log('Template deleted')
}
```

### JavaScript — OAuth application

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

const body = await res.json()
if (body.success) {
  console.log('Template deleted')
}
```

## Response fields

On successful deletion, HTTP status `200 OK` is returned.

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | `true` — the template is deleted |
| `data` | null | Deletion result, always `null` |

## Response example

```json
{
  "success": true,
  "data": null
}
```

## Error response example

404 — template not found, including when the same `id` is deleted again:

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

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `id` is not a positive integer, for example `abc`. Message: `Template ID must be a positive integer.` |
| 404 | `ENTITY_NOT_FOUND` | No template with this `id` exists, it has already been deleted, or it does not belong to the CRM module. The template is not deleted. Templates with `moduleId: rest` are deleted by [`DELETE /v1/doc-templates/:id`](/docs/entities/doc-templates/delete) |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the deletion. The reason is in `error.message` |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. Deletion requires a key with write access |
| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |
| 401 | `TOKEN_MISSING` | The key has no configured tokens |
| 429 | `RATE_LIMITED` | Bitrix24 rate-limited requests to the portal. Retry after the delay in the `Retry-After` header |

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

## See also

- [Get a template](/docs/entities/crm-document-templates/get)
- [List templates](/docs/entities/crm-document-templates/list)
- [Create a template](/docs/entities/crm-document-templates/create)
- [CRM document templates](/docs/entities/crm-document-templates)
