لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/chats/messages.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Messages
Read, send, edit and delete messages, mark them as read or set them aside for later, open a chat at its first page or at a specific message, see who has read a message, search and forward messages, manage reactions, pins, disappearing messages, channel comments and message blocks, show the typing indicator, and load messages from several dialogs in a single request.
Scope: im | Base URL: https://vibecode.bitrix24.com/v1 | Authorization: X-Api-Key
Read messages
GET /v1/chats/:dialogId/messages
Returns dialog messages with cursor-based pagination.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
ParameterdialogId (path) |
Typestring | Requiredyes | Default— | DescriptionDialog ID: numeric user ID for personal messages, chatXXX for group chats — the dialogId field of a recent dialogs row; a user ID comes from the user list. The special me alias — the current user's personal dialog |
Parameterlimit (query) |
Typenumber | Requiredno | Default20, in the v2 mode — 50 | DescriptionNumber of messages per page; values up to 200 are accepted. In the regular mode, a cloud portal returns at most 50 records per call, and in the v2 mode up to 200 — see "Known specifics" |
ParameterlastId (query) |
Typenumber | Requiredno | Default— | DescriptionCursor to load older messages: returns messages with an ID lower than the given one |
ParameterfirstId (query) |
Typenumber | Requiredno | Default— | DescriptionCursor to load newer messages: returns messages with an ID higher than the given one. Rejected in the v2 mode |
Parameterformat (query) |
Typestring | Requiredno | Default— | Descriptionv2 turns on the v2 mode — see "The v2 mode" below. Any other value is ignored and the response is unchanged. A repeated format is not rejected: with format=v1&format=v2 the last value wins, so the v2 mode is on, while format=v2&format=v1 returns the regular-mode response. The bracket form format[]=v2 turns on the v2 mode when all its values are v2 |
Parameterorder (query) |
Typestring | Requiredno | Defaultdesc |
DescriptionThe v2 mode only: desc — messages older than lastId, asc — newer than lastId |
The v2 mode. format=v2 reads the message history. data carries the v2 object — messages, users, files, reactions and other collections — and hasNextPage, with camelCase keys. Reactions arrive on the same page. The mode accepts only format, limit (from 1 to 200: an out-of-range value is clamped, and the passed and applied values are in meta), lastId and order. firstId is rejected with 400 INVALID_PARAMS — page forward with order=asc and lastId. The lastId bound is exclusive: the page after 52523 starts at 52522. hasNextPage: false marks the end of the history. A request in this mode differs from the examples below only in the query string: GET /v1/chats/chat42/messages?format=v2&limit=50&lastId=1002 returns 50 messages older than 1002. The authorization headers are the same. The v2 mode may make you a member: when the chat allows auto-join — a comment chat, a collab or a task chat, for example — the call adds the current user as a member, as loading a chat does. A READONLY key may use the v2 mode as a targeted exception. The user's access rights and the im scope are still checked. The read updates the employee's presence. Reading the history does not itself mark messages as read. These effects and their exact method boundaries are listed under access rights.
Read-only key. In READONLY mode, this request reads an existing chat both with and without format=v2: use its chatN, or a numeric peer ID confirmed in the same employee's recent dialogs. For me, the check requires an existing personal dialog. The check scans at most 4000 raw rows of recent dialogs. If the binding is not confirmed, the request returns 403 WRITE_BLOCKED_READONLY_KEY without calling a method that could create a chat. The check's limits and the permitted read effects are described in access rights.
For format=v2, this exception for named reads applies only to an ordinary employee personal key, whether it uses a webhook or previously configured OAuth tokens. An application key with a user Bearer session, a management key, or a key whose owner type is unconfirmed receives 403 WRITE_BLOCKED_READONLY_KEY in READONLY mode before the existing-chat binding check and before the named messenger method is called. Ordinary reads without these effects remain available to application keys. Read/write mode is unaffected. In regular mode without format=v2, the named-method exception does not apply: ordinary scope and user access checks remain, and the existing-binding check is still required for a read-only key.
Examples
curl — personal key
curl "https://vibecode.bitrix24.com/v1/chats/chat42/messages?limit=20" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl "https://vibecode.bitrix24.com/v1/chats/chat42/messages?limit=20" \
-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/chat42/messages?limit=20',
{
headers: {
'X-Api-Key': 'YOUR_API_KEY',
},
}
)
const { success, data } = await res.json()
console.log('Messages:', data.messages)
console.log('Participants:', data.users)
JavaScript — OAuth application
const res = await fetch(
'https://vibecode.bitrix24.com/v1/chats/chat42/messages?limit=20',
{
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
}
)
const { success, data } = await res.json()
Response fields
The regular mode — without format=v2:
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata.chatId |
Typenumber | DescriptionChat ID |
Fielddata.messages |
Typearray | DescriptionArray of messages |
Fielddata.messages[].id |
Typenumber | DescriptionMessage ID |
Fielddata.messages[].chatId |
Typenumber | DescriptionID of the chat the message belongs to |
Fielddata.messages[].authorId |
Typenumber | DescriptionMessage author ID. 0 — system message |
Fielddata.messages[].date |
Typestring | DescriptionSent date (ISO 8601) |
Fielddata.messages[].text |
Typestring | DescriptionMessage text |
Fielddata.messages[].unread |
Typeboolean | DescriptionNot read by the current user |
Fielddata.messages[].uuid |
Typestring|null | DescriptionUnique message identifier (set by the sender) |
Fielddata.messages[].replaces |
Typearray | DescriptionList of replaced message IDs |
Fielddata.messages[].params |
Typearray|object | DescriptionAdditional message parameters (formatting, system markers) |
Fielddata.messages[].disappearingDate |
Typestring|null | DescriptionMessage auto-deletion date (ISO 8601) or null |
Fielddata.users |
Typearray | DescriptionDialog participants with profiles |
Fielddata.users[].id |
Typenumber | DescriptionUser ID |
Fielddata.users[].name |
Typestring | DescriptionDisplay name |
Fielddata.users[].active |
Typeboolean | DescriptionWhether the user is active in the Bitrix24 account |
Fielddata.files |
Typearray | DescriptionFiles attached to messages |
Fieldmeta.requestedLimit |
Typenumber | DescriptionThe passed limit before clamping. Present together with appliedLimit only when the passed value falls outside the range from 1 to 200 |
Fieldmeta.appliedLimit |
Typenumber | DescriptionThe limit value applied — only when it was clamped to a bound |
The v2 mode — format=v2. This mode has no data.chatId field: every message carries the chat ID.
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata.messages |
Typearray | DescriptionMessages on the page |
Fielddata.messages[].id |
Typenumber | DescriptionMessage ID — the lastId cursor for the next page and the messageId for messages around a message |
Fielddata.messages[].chatId |
Typenumber | DescriptionChat ID — equals data.chat.id in the chat loading response |
Fielddata.messages[].authorId |
Typenumber | DescriptionAuthor ID — the profile is in data.users of the same response or can be fetched by user ID. 0 — a system message |
Fielddata.messages[].date |
Typestring | DescriptionSent date (ISO 8601) |
Fielddata.messages[].text |
Typestring | DescriptionMessage text |
Fielddata.messages[].params |
Typeobject | DescriptionAdditional message parameters, keys in camelCase |
Fielddata.users |
Typearray | DescriptionAuthors of the messages on the page |
Fielddata.files |
Typearray | DescriptionFiles attached to the messages on the page |
Fielddata.reactions |
Typearray | DescriptionReactions to the messages on the page — one item per message with reactions |
Fielddata.reactions[].messageId |
Typenumber | DescriptionID of a message in data.messages of the same response |
Fielddata.reactions[].reactionCounters |
Typeobject | DescriptionNumber of reactions per reaction code, for example {"like": 2} |
Fielddata.reactions[].reactionUsers |
Typeobject | DescriptionIDs of the users who reacted, per reaction code. Only the first few are listed, not all of them. The profile is available by user ID |
Fielddata.reactions[].ownReactions |
Typearray | DescriptionReaction codes of the current user |
Fielddata.hasNextPage |
Typeboolean | Descriptionfalse — no more pages in the chosen direction |
Fieldmeta.requestedLimit |
Typenumber | DescriptionThe passed limit before clamping. Present together with appliedLimit only when the passed value falls outside the range from 1 to 200 |
Fieldmeta.appliedLimit |
Typenumber | DescriptionThe limit value applied — only when it was clamped to a bound |
Besides the ones listed, the v2 object may carry other messenger collections — for example, additionalMessages with the messages that the page's messages reply to, and copilot. Which collections are included depends on the Bitrix24 account.
Response example
The regular mode:
{
"success": true,
"data": {
"chatId": 42,
"messages": [
{
"id": 1001,
"chatId": 42,
"authorId": 5,
"date": "2026-06-05T10:00:00+00:00",
"text": "Good afternoon! How are you?",
"unread": false,
"uuid": null,
"replaces": [],
"params": [],
"disappearingDate": null
},
{
"id": 1002,
"chatId": 42,
"authorId": 7,
"date": "2026-06-05T10:01:00+00:00",
"text": "All good, thanks.",
"unread": true,
"uuid": null,
"replaces": [],
"params": [],
"disappearingDate": null
}
],
"users": [
{
"id": 5,
"active": true,
"name": "John Brown",
"firstName": "John",
"lastName": "Brown",
"workPosition": "Manager",
"color": "#3bc8f5",
"gender": "M",
"bot": false,
"type": "user"
}
],
"files": []
}
}
Response example — the v2 mode
{
"success": true,
"data": {
"messages": [
{
"id": 1002,
"chatId": 42,
"authorId": 7,
"date": "2026-09-20T10:01:00+00:00",
"text": "All done",
"params": {}
},
{
"id": 1001,
"chatId": 42,
"authorId": 5,
"date": "2026-09-20T10:00:00+00:00",
"text": "Please review the mockup",
"params": {}
}
],
"users": [],
"files": [],
"reactions": [
{
"messageId": 1001,
"reactionCounters": { "like": 1 },
"reactionUsers": { "like": [7] },
"ownReactions": []
}
],
"hasNextPage": true
}
}
Error response example
422 — no access to the dialog:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "You do not have access to the specified dialog",
"b24Code": "ACCESS_ERROR"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP422 | CodeBITRIX_ERROR |
DescriptionBitrix24 returned an error (text in the message field). In the regular mode both "dialog not found" and "no access" arrive this way. The portal code is in error.b24Code |
| HTTP403 | CodeBITRIX_ACCESS_DENIED |
DescriptionThe v2 mode: the user has no access to the chat — Bitrix24 refused with the ACCESS_DENIED code |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionBitrix24 returned a NOT_FOUND error. In the v2 mode, the portal error code arrives in error.b24Code |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionThe v2 mode: firstId, a parameter outside the allowed set (format, limit, lastId, order), a repeated parameter other than format, or a non-numeric value. Checked before any call to Bitrix24 |
| HTTP502 | CodeBITRIX_UNAVAILABLE |
DescriptionBitrix24 is unavailable or returned a server error |
| HTTP502 | CodeME_ALIAS_RESOLUTION_FAILED |
DescriptionFailed to resolve the user when using the me alias |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionRead-only mode: the bounded window of recent dialogs did not confirm an existing chat, or the supplied alias could create a chat or is ambiguous. The method that would create the chat is not sent to the portal |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe v2 mode: the named read in READONLY mode is unavailable to an application key, a management key, or a key whose owner type is unconfirmed |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key is missing the im scope |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe API key has no Bitrix24 tokens configured |
The full list of common API errors — Errors.
Known specifics
The page ceiling in the regular mode is 50 messages per call. The limit parameter accepts values up to 200, but in the regular mode a cloud portal returns at most 50 records per call regardless of the value passed. On-premise portals may return more. Read history beyond the latest 50 messages with the lastId cursor — page by page. The v2 mode has no such ceiling: a call returns as many messages as passed in limit, up to 200.
Message order. Messages are returned in descending order — from newest to oldest. In the v2 mode with order=asc the order is reversed: from oldest to newest, starting with the one after lastId.
The v2 mode and response keys. Keys that name fields are converted to camelCase: the FILE_ID message parameter arrives as fileId. Keys that are data stay as they are: the keys of the data.copilot.roles dictionary are role codes, and copilot_assistant arrives as copilot_assistant — the same value that role carries on a chat and a message in data.copilot, so a role is found directly as roles[role]. Fields inside a role are converted to camelCase. A request for a chat that does not exist in the Bitrix24 account returns 422 BITRIX_ERROR with error.b24Code set to CHAT_NOT_FOUND.