For AI agents: markdown of this page — /docs-content-en/chats/management/leave.md documentation index — /llms.txt
Leave a chat
POST /v1/chats/:chatId/leave
The current user (or application) leaves a group chat.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ParameterchatId (path) |
Typenumber | Requiredyes | DescriptionChat ID (positive integer) |
Examples
curl — personal key
curl -X POST https://vibecode.bitrix24.com/v1/chats/456/leave \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl -X POST https://vibecode.bitrix24.com/v1/chats/456/leave \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN"
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/456/leave', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
},
})
const { success, data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/456/leave', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
const { success, data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata |
Typeboolean | Descriptiontrue when the chat was left successfully |
Response example
{
"success": true,
"data": true
}
Error response example
422 — chat not found or another Bitrix24 error:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "Chat not found"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_CHAT_ID |
DescriptionchatId is not a positive integer — checked before the Bitrix24 call |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionBitrix24 returned an error — chat not found or insufficient permissions (details in message) |
| HTTP502 | CodeBITRIX_UNAVAILABLE |
DescriptionBitrix24 is unavailable or returned a server error |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe API key lacks the im scope |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe API key has no configured tokens |
Full list of common API errors — Errors.
Known specifics
Owner leaving. The chat creator remains the owner even after leaving — this endpoint does not revoke ownership. To leave a chat completely: first transfer ownership to another participant via POST /v1/chats/:chatId/owner, then call this endpoint.