#Leave a chat

POST /v1/chats/:chatId/leave

The current user (or application) leaves a group chat.

#Parameters

Parameter Type Required Description
chatId (path) number yes Chat ID (positive integer)

#Examples

#curl — personal key

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/chats/456/leave \
  -H "X-Api-Key: YOUR_API_KEY"

#curl — OAuth application

Terminal
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

javascript
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

javascript
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
success boolean Always true on success
data boolean true when the chat was left successfully

#Response example

JSON
{
  "success": true,
  "data": true
}

#Error response example

422 — chat not found or another Bitrix24 error:

JSON
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Chat not found"
  }
}

#Errors

HTTP Code Description
422 BITRIX_ERROR Bitrix24 returned an error — chat not found or no permissions (text in message)
502 BITRIX_UNAVAILABLE Bitrix24 is unavailable or returned a server error
403 SCOPE_DENIED The API key lacks the im scope
401 TOKEN_MISSING The 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 remove the owner status. To leave a chat completely: first transfer ownership to another participant via `POST /v1/chats/:chatId/owner`, then call leave.

#See also