لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/chats/discovery.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Chat discovery
Find a chat through recent dialogs, unread counters, folders and list sections, channels, collabs and external chats, shared chats, changes since a moment, CRM entity chats, search, dialog details, external dialog IDs and access checks.
Scope: im | Base URL: https://vibecode.bitrix24.com/v1 | Authorization: X-Api-Key
Recent dialogs
GET /v1/chats/recent
Returns the list of the current user's recent dialogs: pinned dialogs first, then by the time of the last message.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
Parameterformat (query) |
Typestring | Requiredno | Default— | Descriptionv2 turns on the v2 mode — see "The v2 mode" below. Any other value is ignored, and the legacy response is returned. A repeated format is not rejected: with format=v1&format=v2 the last value is used, so the v2 mode is on, while format=v2&format=v1 returns the legacy response. The bracket form format[]=v2 turns on the v2 mode when all its values are v2 |
ParameterskipOpenLines (query) |
Typestring | Requiredno | Default— | DescriptionExclude Open Channels conversations. Accepts true, Y, or y |
ParameterskipChat (query) |
Typestring | Requiredno | Default— | DescriptionExclude group chats. Accepts true, Y, or y |
ParameterskipDialog (query) |
Typestring | Requiredno | Default— | DescriptionExclude private dialogs. Accepts true, Y, or y |
ParameterunreadOnly (query) |
Typestring | Requiredno | Default— | DescriptionOnly dialogs with unread messages. Accepts true, Y, or y |
ParameteronlyOpenLines (query) |
Typestring | Requiredno | Default— | DescriptionOnly Open Channels conversations. Accepts true, Y, or y |
ParameteronlyCopilot (query) |
Typestring | Requiredno | Default— | DescriptionOnly chats with the AI assistant. Accepts true, Y, or y |
ParameteronlyChannel (query) |
Typestring | Requiredno | Default— | DescriptionOnly channels. Accepts true, Y, or y |
ParameterlastMessageDate (query) |
Typestring | Requiredno | Default— | DescriptionDate of the last message for pagination (ISO 8601). In the v2 mode, it is the cursor defined by the rule below, in the YYYY-MM-DDTHH:MM:SS format with an offset or Z and without fractional seconds |
ParameterupdatedAfter (query) |
Typestring | Requiredno | Default— | DescriptionDelta mode: return dialogs changed at or after the given instant. Date in ISO 8601 with an explicit offset or Z. Not compatible with offset or lastMessageDate |
Parameterlimit (query) |
Typenumber | Requiredno | Default50 | DescriptionNumber of items in the response. Maximum 200. In the v2 mode, the range is 50 to 200: a smaller value is raised to 50 and a larger one is clamped to 200, and in both cases the passed and applied values are returned in meta |
Parameteroffset (query) |
Typenumber | Requiredno | Default0 |
DescriptionOffset for paging |
Delta mode. The updatedAfter parameter switches the endpoint into a "what changed since the given instant" mode: GET /v1/chats/recent?updatedAfter=2026-06-28T00:00:00Z. The response contains an array of dialogs whose dateUpdate is not earlier than the given instant. The boundary is inclusive — a dialog whose dateUpdate equals the given instant is included, so if you advance the cursor to the highest value you have seen, that boundary record arrives again on the next call.
The page size in this mode is controlled by the server: one page of up to 200 dialogs is read. The limit you pass does not affect it and is returned in meta.requestedLimit together with the applied meta.appliedLimit.
When meta contains truncated with the value true, the delta may be incomplete: more dialogs exist beyond the returned page, or the response shape could not be parsed. In that case do not move updatedAfter — read the full list using the paged mode with the lastMessageDate cursor. The number of rows returned is not a completeness signal — a short response also arrives when more data exists beyond it.
A date without an explicit offset — for example 2026-06-29 10:00:00 — is rejected with 400 INVALID_PARAMS: such a value is interpreted differently depending on the server time zone, so the instant has to be stated unambiguously.
The v2 mode. format=v2 switches the endpoint to the v2 mode: the first page is requested without lastMessageDate, subsequent pages with it. data carries the v2 object — recentItems and the chats, users, messages, files collections — with camelCase keys. The mode accepts only format, limit, lastMessageDate and unreadOnly (true or false). Any other parameter, including the parameters of the legacy mode and their upper-case forms (OFFSET, LIMIT, LAST_UPDATE), is refused with 400 INVALID_PARAMS naming the parameter. The list is always the general one, without nested sections. The mode has its own rate-limit bucket, separate from that of the legacy mode.
The cursor of the next page is the smallest non-empty dateLastActivity among the unpinned rows of the current page; compare instants, not strings: dates may carry different offsets. The bound is inclusive, and pinned chats dated no later than the cursor appear at the top of every page — deduplicate by chatId. The list ends only at hasNextPage: false. If hasNextPage is true but there is no cursor or it equals the previous one, repeat the request with a larger limit, up to 200; true without progress even at 200 is a failure, not the end of the list. Do not discard rows from a response even if you display fewer: the cursor is computed over the whole response, and discarded rows are not returned again. Pagination does not give a snapshot: a chat lifted above the cursor by new activity during pagination does not appear in it, so re-read the first page after pagination. To read the whole list, use limit=200: pinned rows repeat on every page, and small pages waste requests on repeats.
Examples
curl — personal key
curl "https://vibecode.bitrix24.com/v1/chats/recent?limit=20" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl "https://vibecode.bitrix24.com/v1/chats/recent?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/recent?limit=20', {
headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})
const { data } = await res.json()
console.log('Recent dialogs:', data.items)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/recent?limit=20', {
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
const { data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata |
Typeobject|array | DescriptionResult object. In delta mode — an array of dialogs, see the paragraph below the table |
Fielddata.items |
Typearray | DescriptionArray of recent dialogs |
Fielddata.items[].id |
Typestring | DescriptionDialog identifier (chatXXX for a group chat or a numeric ID for a private dialog) |
Fielddata.items[].chatId |
Typenumber | DescriptionNumeric chat ID |
Fielddata.items[].type |
Typestring | DescriptionDialog type: chat, openlines, copilot, channel |
Fielddata.items[].title |
Typestring | DescriptionDialog title |
Fielddata.items[].avatar |
Typeobject | DescriptionDialog avatar |
Fielddata.items[].avatar.url |
Typestring | DescriptionAvatar image URL. Empty string if the avatar is not set |
Fielddata.items[].avatar.color |
Typestring | DescriptionAvatar color in hexadecimal format, for example #4ba984 |
Fielddata.items[].message |
Typeobject | DescriptionLast message in the dialog |
Fielddata.items[].message.id |
Typenumber | DescriptionMessage ID |
Fielddata.items[].message.text |
Typestring | DescriptionMessage text |
Fielddata.items[].message.authorId |
Typenumber | DescriptionMessage author ID |
Fielddata.items[].message.date |
Typestring | DescriptionMessage date (ISO 8601) |
Fielddata.items[].message.file |
Typeboolean | DescriptionWhether the message contains a file |
Fielddata.items[].message.attach |
Typeboolean | DescriptionWhether the message contains an attachment |
Fielddata.items[].message.sticker |
Typestring | null | DescriptionMessage sticker or null |
Fielddata.items[].message.status |
Typestring | DescriptionMessage status (for example, received) |
Fielddata.items[].lastId |
Typenumber | DescriptionID of the last read message |
Fielddata.items[].unread |
Typeboolean | DescriptionWhether there are unread messages |
Fielddata.items[].counter |
Typenumber | DescriptionNumber of unread messages |
Fielddata.items[].pinned |
Typeboolean | DescriptionWhether the dialog is pinned |
Fielddata.items[].dateUpdate |
Typestring | DescriptionDate of the last dialog update (ISO 8601) |
Fielddata.items[].dateLastActivity |
Typestring | DescriptionDate of the last activity (ISO 8601) |
Fielddata.items[].chat |
Typeobject | DescriptionExtended chat information |
Fielddata.items[].chat.id |
Typenumber | DescriptionNumeric chat ID |
Fielddata.items[].chat.name |
Typestring | DescriptionSystem chat name |
Fielddata.items[].chat.type |
Typestring | DescriptionChat type: chat, general, openlines, copilot, channel, mail, crm, and others |
Fielddata.items[].chat.owner |
Typenumber | DescriptionChat owner ID |
Fielddata.items[].chat.userCounter |
Typenumber | DescriptionNumber of members |
Fielddata.items[].chat.role |
Typestring | DescriptionRole of the current user: OWNER, MANAGER, MEMBER |
Fielddata.items[].chat.entityType |
Typestring | DescriptionType of the linked entity (CRM, TASKS, MAIL, GENERAL, and others) |
Fielddata.items[].chat.entityId |
Typestring | DescriptionID of the linked entity |
Fielddata.hasMorePages |
Typeboolean | Descriptiontrue if there is a next page |
Fielddata.hasMore |
Typeboolean | DescriptionDuplicates hasMorePages. Kept for backward compatibility |
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, when limit is passed in delta mode, or when in the v2 mode it is below 50 or above 200 |
Fieldmeta.appliedLimit |
Typenumber | DescriptionThe applied limit value — only when it was clamped to a bound. In delta mode it comes with any limit passed and equals the server page size — 200 |
Fieldmeta.mode |
Typestring | DescriptionThe value delta. Present only in delta mode |
Fieldmeta.returned |
Typenumber | DescriptionNumber of dialogs in the response. Present only in delta mode |
Fieldmeta.truncated |
Typeboolean | DescriptionReturned with the value true when the delta could not be confirmed complete: more dialogs exist beyond the returned page, or the response shape could not be parsed |
Fielddata.recentItems |
Typearray | DescriptionThe v2 mode: list rows in the order Bitrix24 returns them — pinned first, then by activity |
Fielddata.recentItems[].dialogId |
Typestring | DescriptionThe v2 mode: dialog ID (chatXXX or a user ID) — chat loading and the message feed take it |
Fielddata.recentItems[].chatId |
Typenumber | DescriptionThe v2 mode: chat ID — the deduplication key; equals data.chat.id in the chat loading response |
Fielddata.recentItems[].pinned |
Typeboolean | DescriptionThe v2 mode: whether the chat is pinned |
Fielddata.recentItems[].dateLastActivity |
Typestring|null | DescriptionThe v2 mode: the instant of the last activity; the smallest value among unpinned rows is the cursor of the next page |
Fielddata.hasNextPage |
Typeboolean | DescriptionThe v2 mode: false marks the end of the list |
In delta mode data is an array of dialogs with the same item fields listed above for data.items. The hasMorePages and hasMore fields are not returned in this mode — meta.truncated serves that role instead.
Response example
Paged mode:
{
"success": true,
"data": {
"items": [
{
"id": "chat456",
"chatId": 456,
"type": "chat",
"title": "Development team",
"avatar": {
"url": "",
"color": "#4ba984"
},
"message": {
"id": 1201,
"text": "Task update is ready",
"authorId": 1,
"date": "2026-06-03T16:51:12+00:00",
"file": false,
"attach": false,
"sticker": null,
"status": "received"
},
"lastId": 1195,
"pinned": false,
"unread": false,
"counter": 0,
"dateUpdate": "2026-06-03T16:51:12+00:00",
"dateLastActivity": "2026-06-03T16:51:12+00:00",
"chat": {
"id": 456,
"name": "Development team",
"type": "chat",
"owner": 1,
"userCounter": 5,
"role": "OWNER",
"entityType": "",
"entityId": ""
}
},
{
"id": "chat123",
"chatId": 123,
"type": "crm",
"title": "Deal chat",
"avatar": {
"url": "",
"color": "#f76187"
},
"message": {
"id": 980,
"text": "Contract approved",
"authorId": 7,
"date": "2026-06-02T14:08:10+00:00",
"file": false,
"attach": false,
"sticker": null,
"status": "received"
},
"lastId": 0,
"pinned": false,
"unread": false,
"counter": 0,
"dateUpdate": "2026-06-02T14:08:10+00:00",
"dateLastActivity": "2026-06-02T14:08:10+00:00",
"chat": {
"id": 123,
"name": "Deal chat",
"type": "crm",
"owner": 1,
"userCounter": 2,
"role": "MEMBER",
"entityType": "CRM",
"entityId": "DEAL|42"
}
}
],
"hasMorePages": true,
"hasMore": true
}
}
Delta mode. The main item fields are shown; the full set is in the table above:
{
"success": true,
"data": [
{
"id": "chat456",
"chatId": 456,
"type": "chat",
"title": "Development team",
"pinned": false,
"unread": false,
"counter": 0,
"dateUpdate": "2026-06-29T10:12:44+00:00",
"dateLastActivity": "2026-06-29T10:12:44+00:00"
}
],
"meta": {
"mode": "delta",
"returned": 1
}
}
Error response example
403 — no im scope:
{
"success": false,
"error": {
"code": "SCOPE_DENIED",
"message": "This endpoint requires 'im' scope"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
DescriptionupdatedAfter was passed without an explicit offset or Z, or is not a date |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionupdatedAfter was passed together with offset or lastMessageDate |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionThe v2 mode: a parameter other than format, limit, lastMessageDate or unreadOnly; a repeated parameter other than format; a non-numeric limit; an unreadOnly other than true or false; or a lastMessageDate that is not in the YYYY-MM-DDTHH:MM:SS format with an offset or Z, or that names a date or time that does not exist (2026-02-30, 24:00) |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe API key does not have the im scope |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe API key has no Bitrix24 tokens configured |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionBitrix24 returned an error (details in message) |
| HTTP502 | CodeBITRIX_UNAVAILABLE |
DescriptionBitrix24 is unavailable or returned a server error |
Full list of common API errors — Errors.
Known specifics
- The
skipOpenLinesandonlyOpenLinesflags are mutually exclusive: enabling both yields a result in which no Open Channels chat appears in the list. - In legacy mode a deep
offsetis forwarded to Bitrix24. A small window is read from one buffered page, and an incomplete boundary row may require one additional request. New activity between requests can reorder the list. In legacy mode the date bound is inclusive: pass the last unpinned item'sdateLastActivity, omitoffsetand deduplicate bychatId. Pinned rows and rows with the same boundary date may repeat. If the cursor does not advance, increaselimitup to 200. - The response contains a
data.copilotfield with the configuration of the Bitrix24 account's AI assistant. It is not related to the list of dialogs. - In delta mode a dialog whose
dateUpdatecannot be read stays in the response: an extra record is safer than a lost change. - The
skip*andonly*filter families andunreadOnlyapply in delta mode as well, narrowing the page that is scanned. - In the v2 mode, keys that name fields are converted to camelCase, while keys that are data stay as they are: the keys of the
data.copilot.rolesdictionary are role codes, andcopilot_assistantarrives ascopilot_assistant— the same value thatrolecarries on a chat, so a role is found directly asroles[role]. - On a Bitrix24 account without the v2 methods, the mode responds with
422 BITRIX_ERRORand the Bitrix24 error code inerror.b24Code, and does not silently fall back to the legacy response: the response shape is different.