[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fdiscovery\u002Fproject-recent":3,"docs-tabs-chats\u002Fdiscovery\u002Fproject-recent":6},{"content":4,"lastmod":5},"## Project chats\n\n`GET \u002Fv1\u002Fchats\u002Fprojects\u002F:projectId\u002Frecent`\n\nReturns the chats of one project from the current user's recent dialog list: the project's own chat and the chats nested in it. Use it for a project screen that shows the project's discussions next to its main chat.\n\n## Parameters\n\n| Parameter | Type | Required | Default | Description |\n|----------|-----|:-----:|-----------|---------|\n| `projectId` (path) | integer | yes | — | ID of the project chat, a positive integer. This is the `chatId` of the project row in the [collab list](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent-collabs) |\n| `limit` (query) | integer | no | 50 | Rows per page, 50 to 200. A smaller value is raised to 50 and a larger one is clamped to 200, and both adjustments are echoed in `meta` |\n| `lastMessageDate` (query) | string | no | — | Cursor of the next page: the smallest `dateLastActivity` among the unpinned rows of the previous page. Format `YYYY-MM-DDTHH:MM:SS` with an offset or `Z`, without fractional seconds. Not passed on the first page |\n\nOther parameters, including `format` and `unreadOnly`, and repeated parameters are rejected with `400 INVALID_PARAMS`.\n\n**Pagination** — as in [recent dialogs in the v2 mode](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent). The cursor of the next page is the smallest non-empty `dateLastActivity` among the **unpinned** rows; compare instants, not strings. The bound is inclusive: the row with the cursor date arrives again, so 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. Do not discard response rows: the cursor is computed over the whole response.\n\n**The first page modifies data.** On the first read of a project, Bitrix24 creates this project's CoPilot chat for the key owner — once per project and only for a project member. For that reason a read-only key gets `403 WRITE_BLOCKED_READONLY_KEY` on a request without `lastMessageDate`, before the Bitrix24 call. Requests with `lastMessageDate` only read and are available to such a key — see [access rights](\u002Fdocs\u002Faccess-rights).\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fprojects\u002F53\u002Frecent?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\u002Fprojects\u002F53\u002Frecent?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 rows = new Map()\nlet limit = 50\nlet cursor\nfor (;;) {\n  const url = new URL('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fprojects\u002F53\u002Frecent')\n  url.searchParams.set('limit', String(limit))\n  if (cursor) url.searchParams.set('lastMessageDate', 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) rows.set(item.chatId, item)\n  if (!data.hasNextPage) break\n  const dates = data.recentItems.filter((i) => !i.pinned && i.dateLastActivity).map((i) => i.dateLastActivity)\n  const next = dates.length ? dates.reduce((a, b) => (Date.parse(a) \u003C= Date.parse(b) ? a : b)) : undefined\n  if (!next || (cursor && Date.parse(next) >= Date.parse(cursor))) {\n    if (limit === 200) throw new Error('Recent-list 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 rows = new Map()\nlet limit = 50\nlet cursor\nfor (;;) {\n  const url = new URL('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fprojects\u002F53\u002Frecent')\n  url.searchParams.set('limit', String(limit))\n  if (cursor) url.searchParams.set('lastMessageDate', 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) rows.set(item.chatId, item)\n  if (!data.hasNextPage) break\n  const dates = data.recentItems.filter((i) => !i.pinned && i.dateLastActivity).map((i) => i.dateLastActivity)\n  const next = dates.length ? dates.reduce((a, b) => (Date.parse(a) \u003C= Date.parse(b) ? a : b)) : undefined\n  if (!next || (cursor && Date.parse(next) >= Date.parse(cursor))) {\n    if (limit === 200) throw new Error('Recent-list 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 in the order Bitrix24 returns them. On the first page the row of the project itself arrives together with the nested chats |\n| `data.recentItems[].dialogId` | string | Dialog ID, `chatXXX` |\n| `data.recentItems[].chatId` | number | Chat ID, the deduplication key |\n| `data.recentItems[].messageId` | number | ID of the last message |\n| `data.recentItems[].pinned` | boolean | The chat is pinned for the current user |\n| `data.recentItems[].unread` | boolean | The chat is manually marked as unread |\n| `data.recentItems[].dateLastActivity` | string\\|null | Instant of the last activity. The smallest value among the unpinned rows is the cursor of the next page |\n| `data.chats` | array | Chat cards of the rows: `id`, `dialogId`, `name`, the current user's `role` and other chat fields |\n| `data.chats[].type` | string | Chat type. `collab` for the project's own chat; for nested chats, the type of the chat itself, for example `chat` or `copilot` |\n| `data.chats[].parentChatId` | number | `0` for the project's own chat, `projectId` for nested chats |\n| `data.chats[].entityType` | string | `SONET_GROUP` for the project's own chat |\n| `data.chats[].entityId` | string | ID of the project group for the project's own chat |\n| `data.messages` | array | The chats' last messages |\n| `data.users` | array | Authors of the last messages |\n| `data.files` | array | Files of the last messages |\n| `data.recentConfigs` | array | The list sections each chat is counted in: `chatId` and `sections` |\n| `data.hasNextPage` | boolean | `false` — the end of the list |\n| `data.sectionMeta` | object | Project details. Present only on the first page; responses to requests with `lastMessageDate` do not have the field |\n| `data.sectionMeta.fixedChatIds` | array | ID of the project's own chat. An empty array if `projectId` is not a project chat |\n| `data.sectionMeta.collabInfo` | object\\|null | Project summary. `null` if `projectId` is not a project chat |\n| `data.sectionMeta.collabInfo.collabId` | number | ID of the project group |\n| `data.sectionMeta.collabInfo.guestCount` | number | Number of project guests |\n| `data.sectionMeta.collabInfo.entities` | object | The project sections `tasks`, `files` and `calendar`. Each has `counter` — the counter, and `url` — the section address relative to the Bitrix24 account domain |\n| `meta.requestedLimit` | number | The `limit` passed. Present together with `appliedLimit` only when the value was outside the range of 50 to 200 |\n| `meta.appliedLimit` | number | The `limit` applied — only when it was clamped to a bound |\n\nThe `data` object has the same shape as in [recent dialogs in the v2 mode](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent). Its other collections — `copilot`, `birthdayList`, `stickers`, `additionalMessages`, `messagesAutoDeleteConfigs`, `forwardSource` — arrive unchanged.\n\n## Response example\n\nThe first page, with the main fields shown:\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"recentItems\": [\n      {\n        \"dialogId\": \"chat57\",\n        \"chatId\": 57,\n        \"messageId\": 431,\n        \"type\": \"chat\",\n        \"pinned\": false,\n        \"unread\": false,\n        \"dateUpdate\": \"2026-09-30T10:51:36+00:00\",\n        \"dateLastActivity\": \"2026-09-30T10:51:36+00:00\"\n      },\n      {\n        \"dialogId\": \"chat55\",\n        \"chatId\": 55,\n        \"messageId\": 415,\n        \"type\": \"chat\",\n        \"pinned\": false,\n        \"unread\": false,\n        \"dateUpdate\": \"2026-09-30T10:07:32+00:00\",\n        \"dateLastActivity\": \"2026-08-10T14:31:46+00:00\"\n      },\n      {\n        \"dialogId\": \"chat53\",\n        \"chatId\": 53,\n        \"messageId\": 431,\n        \"type\": \"chat\",\n        \"pinned\": false,\n        \"unread\": false,\n        \"dateUpdate\": \"2026-09-30T10:51:36+00:00\",\n        \"dateLastActivity\": \"2026-09-30T10:51:36+00:00\"\n      }\n    ],\n    \"chats\": [\n      {\n        \"id\": 57,\n        \"dialogId\": \"chat57\",\n        \"name\": \"Terms negotiation\",\n        \"type\": \"chat\",\n        \"parentChatId\": 53,\n        \"entityType\": \"\",\n        \"entityId\": \"\",\n        \"owner\": 1,\n        \"role\": \"owner\"\n      },\n      {\n        \"id\": 55,\n        \"dialogId\": \"chat55\",\n        \"name\": \"Session #2\",\n        \"type\": \"copilot\",\n        \"parentChatId\": 53,\n        \"entityType\": \"SONET_PROJECT_COPILOT\",\n        \"entityId\": \"3\",\n        \"owner\": 1,\n        \"role\": \"owner\"\n      },\n      {\n        \"id\": 53,\n        \"dialogId\": \"chat53\",\n        \"name\": \"Partner program launch\",\n        \"type\": \"collab\",\n        \"parentChatId\": 0,\n        \"entityType\": \"SONET_GROUP\",\n        \"entityId\": \"3\",\n        \"owner\": 1,\n        \"role\": \"owner\"\n      }\n    ],\n    \"recentConfigs\": [\n      { \"chatId\": 57, \"sections\": [\"default\", \"chat\", \"collabDefault\", \"collabChat\"] },\n      { \"chatId\": 55, \"sections\": [\"default\", \"copilot\", \"collabDefault\"] },\n      { \"chatId\": 53, \"sections\": [\"default\", \"collab\"] }\n    ],\n    \"hasNextPage\": false,\n    \"sectionMeta\": {\n      \"fixedChatIds\": [53],\n      \"collabInfo\": {\n        \"guestCount\": 0,\n        \"collabId\": 3,\n        \"entities\": {\n          \"tasks\": { \"counter\": 0, \"url\": \"\u002Fworkgroups\u002Fgroup\u002F3\u002Ftasks\u002F\" },\n          \"files\": { \"counter\": 0, \"url\": \"\u002Fworkgroups\u002Fgroup\u002F3\u002Fdisk\u002Fpath\u002F?c_element=files_button\" },\n          \"calendar\": { \"counter\": 0, \"url\": \"\u002Fworkgroups\u002Fgroup\u002F3\u002Fcalendar\u002F\" }\n        }\n      }\n    }\n  }\n}\n```\n\n## Error response example\n\n403 — the first page is requested with a read-only key:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"WRITE_BLOCKED_READONLY_KEY\",\n    \"message\": \"Key is in read-only mode. Switch the key to read and write in \u002Fkeys to allow Bitrix24 data changes.\",\n    \"details\": {\n      \"method\": \"im.v2.Recent.load\",\n      \"keyName\": \"Reports dashboard\",\n      \"currentMode\": \"READONLY\",\n      \"switchUrl\": \"\u002Fkeys\"\n    }\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `projectId` is not a positive integer. Checked before the Bitrix24 call |\n| 400 | `INVALID_PARAMS` | A parameter other than `limit` and `lastMessageDate`, a repeated parameter, a non-numeric `limit`, or `lastMessageDate` not in the `YYYY-MM-DDTHH:MM:SS` format with an offset or `Z`, or with a nonexistent date or time (`2026-02-30`, `24:00`). Checked before the Bitrix24 call |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | A request without `lastMessageDate` is sent with a read-only key. The key name and its mode are in `error.details` |\n| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the portal code is in `error.b24Code`. `CHAT_NOT_FOUND` — there is no chat with this `projectId` |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned \"not found\"; the portal code is in `error.b24Code` |\n| 403 | `BITRIX_ACCESS_DENIED` | The key owner has no access to the project chat |\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**A chat that is not a project is an empty list, not an error.** The ID of a group chat not linked to a project returns `200` with empty collections and `hasNextPage: false`. Such a response does not reveal a mistake in `projectId`: a project is indicated by a non-empty `sectionMeta.fixedChatIds` on the first page.\n\n**The refusal for a read-only key does not depend on the project state.** The first page is closed to such a key even when the project's CoPilot chat already exists.\n\n## See also\n\n- [Collab list](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent-collabs)\n- [Recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent)\n- [External chats of a section](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent-external)\n- [Chat discovery](\u002Fdocs\u002Fchats\u002Fdiscovery)\n","2026-10-07",{},1795527960699]