[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fdiscovery\u002Frecent-channels":3,"docs-tabs-chats\u002Fdiscovery\u002Frecent-channels":6},{"content":4,"lastmod":5},"## Channel list\n\n`GET \u002Fv1\u002Fchats\u002Frecent\u002Fchannels`\n\nReturns the public channels of the Bitrix24 account page by page, from the channel with the newest message to older ones. Use it to build a directory of channels the user can subscribe to.\n\n## Parameters\n\n| Parameter | Type | Required | Default | Description |\n|----------|-----|:-----:|-----------|---------|\n| `limit` (query) | integer | no | 50 | Rows per page, 1 to 200. A smaller value is raised to 1 and a larger one is clamped to 200, and both adjustments are echoed in `meta` |\n| `lastMessageId` (query) | integer | no | — | Cursor for the next page: the smallest positive `messageId` among the rows of the previous page. Not passed on the first page |\n\nOther parameters and repeated parameters are rejected with `400 INVALID_PARAMS`.\n\n**Pagination.** Rows are ordered by the ID of the channel's last message, from largest to smallest. Request the next page with `lastMessageId` equal to the smallest positive `messageId` of the current page. The bound is exclusive: the channel with that `messageId` is not repeated on the next page. The list ends only at `hasNextPage: false`. If `hasNextPage` is `true` but the page has no row with a positive `messageId`, repeat the request with a larger `limit`, up to 200.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Frecent\u002Fchannels?limit=50\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Frecent\u002Fchannels?limit=50\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\"\n```\n\n### JavaScript — personal key\n\n```javascript\nconst channels = []\nconst seen = new Set()\nlet limit = 50\nlet cursor\nfor (;;) {\n  const url = new URL('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Frecent\u002Fchannels')\n  url.searchParams.set('limit', String(limit))\n  if (cursor) url.searchParams.set('lastMessageId', String(cursor))\n  const res = await fetch(url, { headers: { 'X-Api-Key': 'YOUR_API_KEY' } })\n  const { data } = await res.json()\n  for (const item of data.recentItems) {\n    if (!seen.has(item.chatId)) { seen.add(item.chatId); channels.push(item) }\n  }\n  if (!data.hasNextPage) break\n  const ids = data.recentItems.map((i) => i.messageId).filter((id) => id > 0)\n  const next = ids.length ? Math.min(...ids) : undefined\n  if (next === undefined || (cursor !== undefined && next >= cursor)) {\n    if (limit === 200) throw new Error('Channel cursor did not advance; restart with a full refresh')\n    limit = Math.min(limit * 2, 200)\n    continue\n  }\n  cursor = next\n  limit = 50\n}\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst channels = []\nconst seen = new Set()\nlet limit = 50\nlet cursor\nfor (;;) {\n  const url = new URL('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Frecent\u002Fchannels')\n  url.searchParams.set('limit', String(limit))\n  if (cursor) url.searchParams.set('lastMessageId', String(cursor))\n  const res = await fetch(url, {\n    headers: {\n      'X-Api-Key': 'YOUR_APP_KEY',\n      'Authorization': 'Bearer USER_SESSION_TOKEN',\n    },\n  })\n  const { data } = await res.json()\n  for (const item of data.recentItems) {\n    if (!seen.has(item.chatId)) { seen.add(item.chatId); channels.push(item) }\n  }\n  if (!data.hasNextPage) break\n  const ids = data.recentItems.map((i) => i.messageId).filter((id) => id > 0)\n  const next = ids.length ? Math.min(...ids) : undefined\n  if (next === undefined || (cursor !== undefined && next >= cursor)) {\n    if (limit === 200) throw new Error('Channel cursor did not advance; restart with a full refresh')\n    limit = Math.min(limit * 2, 200)\n    continue\n  }\n  cursor = next\n  limit = 50\n}\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.recentItems` | array | List rows, one per channel |\n| `data.recentItems[].dialogId` | string | Dialog ID of the channel, `chatXXX` |\n| `data.recentItems[].chatId` | number | Chat ID of the channel, the deduplication key |\n| `data.recentItems[].messageId` | number | ID of the channel's last message, `0` for a channel without messages. The smallest positive value on the page is the cursor for the next one |\n| `data.recentItems[].pinned` | boolean | Whether the channel is pinned for the current user. It does not affect the row order |\n| `data.recentItems[].dateLastActivity` | null | Always `null` in this list: channels are ordered by message ID, not by date |\n| `data.chats` | array | Channel cards: `id`, `dialogId`, `name`, `type`, `owner`, the current user's `role` and other chat fields |\n| `data.messages` | array | The channels' last messages |\n| `data.users` | array | Authors of the last messages |\n| `data.recentConfigs` | array | The list sections each channel is counted in: `chatId` and `sections` |\n| `data.hasNextPage` | boolean | `false` — the end of the list |\n| `meta.requestedLimit` | number | The `limit` passed. Returned together with `appliedLimit`, and only when the value was outside the range of 1 to 200 |\n| `meta.appliedLimit` | number | The `limit` applied — only when it was clamped to a bound |\n\n## Response example\n\nThe main fields are shown:\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"recentItems\": [\n      {\n        \"dialogId\": \"chat206\",\n        \"chatId\": 206,\n        \"messageId\": 329393,\n        \"type\": \"chat\",\n        \"pinned\": false,\n        \"unread\": false,\n        \"dateUpdate\": null,\n        \"dateLastActivity\": null\n      },\n      {\n        \"dialogId\": \"chat2\",\n        \"chatId\": 2,\n        \"messageId\": 0,\n        \"type\": \"chat\",\n        \"pinned\": false,\n        \"unread\": false,\n        \"dateUpdate\": null,\n        \"dateLastActivity\": null\n      }\n    ],\n    \"chats\": [\n      {\n        \"id\": 206,\n        \"dialogId\": \"chat206\",\n        \"name\": \"Company news\",\n        \"type\": \"openChannel\",\n        \"owner\": 4,\n        \"role\": \"guest\"\n      }\n    ],\n    \"messages\": [\n      {\n        \"id\": 329393,\n        \"chatId\": 206,\n        \"authorId\": 4,\n        \"date\": \"2026-09-10T09:15:00+00:00\",\n        \"text\": \"Quarterly results are published\"\n      }\n    ],\n    \"recentConfigs\": [\n      { \"chatId\": 206, \"sections\": [\"default\", \"openChannel\", \"channel\"] }\n    ],\n    \"hasNextPage\": false\n  }\n}\n```\n\n## Error response example\n\n400 — the cursor is not a positive number:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"`lastMessageId` must be an integer, 1 or more — the smallest positive `messageId` among the rows of the previous page.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | A parameter other than `limit` and `lastMessageId`, a repeated parameter, a non-numeric `limit`, or `lastMessageId` less than `1`. Checked before the Bitrix24 call |\n| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the Bitrix24 code is in `error.b24Code` |\n| 403 | `BITRIX_ACCESS_DENIED` | Bitrix24 denied access |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**The list holds all public channels of the Bitrix24 account, not only yours.** Channels the user is not a member of are returned too, with the `guest` role in `data.chats[].role`.\n\n**Channels without messages come last.** Their `messageId` is `0`, and they do not serve as a cursor. If such channels do not fit on one page of 200 rows, pagination cannot continue past them: the next page would have no cursor.\n\n## See also\n\n- [Recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent)\n- [Collab list](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent-collabs)\n- [External chats of a section](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent-external)\n- [Chat discovery](\u002Fdocs\u002Fchats\u002Fdiscovery)\n","2026-10-07",{},1794739535346]