
## Delete a document

`DELETE /v1/note/documents/:id`

Moves a document together with its entire subtree to the trash. A document cannot be restored via the API — this is only available in the Bitrix24 interface.

## Parameters

| Parameter | In | Type | Required | Description |
|----------|-----|-----|:-----:|---------|
| `id` | path | integer | yes | Identifier of the subtree root document |

## Examples

### curl — personal key

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

### curl — OAuth application

```bash
curl -X DELETE https://vibecode.bitrix24.com/v1/note/documents/77 \
  -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/note/documents/77', {
  method: 'DELETE',
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})
const { data } = await res.json()
console.log(data.deleted) // true
```

### JavaScript — OAuth application

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

## Response

On successful deletion an object `{ deleted: true }` is returned.

| Field | Type | Description |
|------|-----|---------|
| `data.deleted` | boolean | `true` on successful deletion |

## Response example

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

## Error response example

404 — document not found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Record with ID = `999999` not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `id` is not a positive integer |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The access key is read-only |
| 403 | `BITRIX_ACCESS_DENIED` | No permission to edit the document |
| 404 | `ENTITY_NOT_FOUND` | The document does not exist or is already in the trash |
| 403 | `SCOPE_DENIED` | The key lacks the `note` scope |
| 401 | `TOKEN_MISSING` | The key has no tokens configured |

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

## Known specifics

- **The document disappears from listings.** After deletion the document vanishes from the [`GET /v1/note/collections/:collectionId/documents`](../collections/tree.md) tree and from the [`GET /v1/note/documents/search`](./search.md) search results.

## See also

- [Archive a document](./archive.md)
- [Create a document](./create.md)
- [Documents](/docs/note/documents)
