For AI agents: markdown of this page — /docs-content-en/chats/events.md documentation index — /llms.txt

Events

Subscribe to messenger events and receive new messages and updates via polling.

Scope: im | Base URL: https://vibecode.bitrix24.com/v1 | Authorization: X-Api-Key

Subscribe to events

POST /v1/chats/events/subscribe

Enables accumulation of messenger user events for the current user. Without an active subscription, events are not accumulated and are not available through GET /v1/chats/events.

You must call subscribe before you start polling events. Calling it again while a subscription is active does not cause an error.

Parameters

The endpoint takes no parameters. The request body is an empty object {}.

Examples

curl — personal key

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

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/chats/events/subscribe" \
  -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/events/subscribe', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
console.log('Subscription:', data) // true

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/events/subscribe', {
  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 — the subscription is activated

Response example

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

Error response example

403 — no im scope:

JSON
{
  "success": false,
  "error": {
    "code": "SCOPE_DENIED",
    "message": "This endpoint requires 'im' scope"
  }
}

Errors

HTTP Code Description
403 SCOPE_DENIED The API key does not have the im scope
401 TOKEN_MISSING The API key has no configured tokens
422 BITRIX_ERROR Bitrix24 returned an error (error text in message)
502 BITRIX_UNAVAILABLE Bitrix24 is unavailable or returned a server error

Full list of common API errors — Errors.

Known specifics

Request body. The request can have no body or an empty {}. Unknown fields are ignored.

OAuth key. For a vibe_app_… key add the Authorization: Bearer <session_token> header — without it the request returns 401 TOKEN_MISSING. More — Keys and authorization.

See also