## Delete a chat

`DELETE /v1/chats/:dialogId`

**Irreversible:** the chat is deleted for all members together with its messages and files, and it cannot be restored.

The response arrives before the chat disappears: Bitrix24 accepts the deletion and runs it as a background job, so the chat may still be readable for a few seconds after the response. The v2 messenger method is `im.v2.Chat.delete`. A chat can be deleted by a member with the delete permission — the owner by default.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `dialogId` (path) | string | yes | Group chat ID as `chatN`, for example `chat42`. A personal dialog cannot be deleted |

The endpoint accepts no query parameters and no request body: any parameter or body field is rejected with `400 INVALID_PARAMS` before any call to Bitrix24.

## Examples

### curl — personal key

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

### curl — OAuth application

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

const { success, data } = await res.json()
console.log('Deletion accepted:', data.result) // true
```

### JavaScript — OAuth application

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

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.result` | boolean | `true` — the deletion is accepted |

## Response example

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

## Error response example

403 — the caller has no permission to delete this chat:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ACCESS_DENIED",
    "message": "ACCESS_DENIED"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | A query parameter or a body field was sent — the endpoint accepts neither |
| 403 | `BITRIX_ACCESS_DENIED` | No permission to delete this chat. An attempt to delete a personal dialog or a CRM entity chat gets the same answer |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned "not found"; the portal code is in `error.b24Code` |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the portal code is in `error.b24Code`. A missing chat lands here with `CHAT_NOT_FOUND` |
| 502 | `ME_ALIAS_RESOLUTION_FAILED` | Failed to resolve the user when using the `me` alias |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](/docs/access-rights) |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

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

## Known specifics

**A deleted chat cannot be addressed.** Once the background job has run, the chat card and the chat feed answer `422 BITRIX_ERROR` with `error.b24Code` `CHAT_NOT_FOUND`. Any `dialogId` or `chatId` you stored for the deleted chat no longer points to anything.

**Leaving a chat is not deleting it.** If you only need to stop being a member, [leave the chat](/docs/chats/management/leave): the chat and its history stay for the other members.

## See also

- [Chat management](/docs/chats/management)
- [Leave a chat](/docs/chats/management/leave)
- [Create a chat](/docs/chats/management/create)
