
## Delete template

`DELETE /v1/doc-templates/:id`

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

## Parameters

| Parameter | Type | Req. | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Template identifier |

## Examples

### curl — personal key

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

### curl — OAuth application

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

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

### JavaScript — OAuth application

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

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

## Response

On successful deletion an HTTP `204 No Content` status is returned with an empty body; the success indicator is the response code, not the content.

## Response example

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

## Error response example

404 — template not found:

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

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 404 | `ENTITY_NOT_FOUND` | No template with the given `id` (including a repeated delete) |
| 403 | `SCOPE_DENIED` | The key lacks the `documentgenerator` scope |
| 401 | `TOKEN_MISSING` | The key has no configured tokens |

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

## See also

- [Get template](/docs/entities/doc-templates/get)
- [List templates](/docs/entities/doc-templates/list)
- [Create template](/docs/entities/doc-templates/create)
