[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmessages\u002Finitial":3,"docs-tabs-chats\u002Fmessages\u002Finitial":6},{"content":4,"lastmod":5},"## First page of a chat\n\n`GET \u002Fv1\u002Fchats\u002F:dialogId\u002Fmessages\u002Finitial`\n\nReturns the page of messages that the messenger shows when it opens a chat. The page is built around the \"unread\" mark or, when there is none, around the last read message. Use it to open a chat where the user left off, without a separate request for the chat itself. The chat together with pinned messages comes from [loading a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload).\n\n## Parameters\n\n| Parameter | Type | Required | Default | Description |\n|----------|-----|:-----:|-----------|---------|\n| `dialogId` (path) | string | yes | — | Dialog ID: numeric user ID for personal messages, `chatXXX` for group chats. The `me` alias addresses the current user's personal dialog. The user's dialogs are in the [list of recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) (`GET \u002Fv1\u002Fchats\u002Frecent`) |\n| `limit` (query) | number | no | 50 | How many messages to take on each side of the anchor message. From 1 to 200: an out-of-range value is clamped; the passed and applied values are in `meta.requestedLimit` and `meta.appliedLimit` |\n| `ignoreMark` (query) | boolean | no | `false` | `true` — build the page around the last read message, ignoring the \"unread\" mark |\n\nAny other parameter or a repeated parameter is rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat42\u002Fmessages\u002Finitial?limit=20\" \\\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\u002Fchat42\u002Fmessages\u002Finitial?limit=20\" \\\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 res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat42\u002Fmessages\u002Finitial?limit=20', {\n  headers: { 'X-Api-Key': 'YOUR_API_KEY' },\n})\n\nconst { data } = await res.json()\nconsole.log('Messages:', data.messages.map((m) => m.id), 'has older:', data.hasPrevPage)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat42\u002Fmessages\u002Finitial?limit=20', {\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\n\nconst { data } = await res.json()\nconsole.log('Messages:', data.messages.map((m) => m.id), 'has older:', data.hasPrevPage)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.messages` | array | Messages on the page, from oldest to newest |\n| `data.messages[].id` | number | Message ID |\n| `data.messages[].chatId` | number | Chat ID |\n| `data.messages[].authorId` | number | Author ID. `0` — a system message |\n| `data.messages[].date` | string | Date sent (ISO 8601) |\n| `data.messages[].text` | string | Message text |\n| `data.messages[].unread` | boolean | Not read by the current user |\n| `data.messages[].viewed` | boolean | Viewed by the current user |\n| `data.messages[].viewedByOthers` | boolean | Viewed by one of the members |\n| `data.additionalMessages` | array | Messages that the page's messages reply to, when they are not on the page themselves |\n| `data.users` | array | Authors of the page's messages |\n| `data.usersShort` | array | Short profiles of the page's users |\n| `data.files` | array | Files of the page's messages |\n| `data.reactions` | array | Reactions to the page's messages |\n| `data.stickers` | array | Stickers of the page's messages |\n| `data.forwardSource` | null | A collection of the v2 message history shared by responses that contain messages. Comes as `null`, including when the page contains forwarded messages |\n| `data.copilot` | object\\|null | The CoPilot block, shaped as in the [CoPilot draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft). `null` outside CoPilot chats |\n| `data.tariffRestrictions.isHistoryLimitExceeded` | boolean | History older than the plan allows is hidden |\n| `data.hasPrevPage` | boolean | There are messages older than the page |\n| `data.hasNextPage` | boolean | There are messages newer than the page |\n| `meta.requestedLimit` | number | The passed `limit`, when it falls outside the range from 1 to 200 |\n| `meta.appliedLimit` | number | The applied `limit` value — only when it was clamped to a bound |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"messages\": [\n      {\n        \"id\": 1001,\n        \"chatId\": 42,\n        \"authorId\": 5,\n        \"date\": \"2026-09-20T10:00:00+00:00\",\n        \"text\": \"Please review the mockup\",\n        \"params\": {}\n      },\n      {\n        \"id\": 1002,\n        \"chatId\": 42,\n        \"authorId\": 7,\n        \"date\": \"2026-09-20T10:01:00+00:00\",\n        \"text\": \"All done\",\n        \"params\": {}\n      }\n    ],\n    \"additionalMessages\": [],\n    \"users\": [],\n    \"usersShort\": [],\n    \"files\": [],\n    \"reactions\": [],\n    \"stickers\": [],\n    \"tariffRestrictions\": { \"isHistoryLimitExceeded\": false },\n    \"hasPrevPage\": true,\n    \"hasNextPage\": false\n  }\n}\n```\n\n## Error response example\n\n422 — the chat does not exist in the Bitrix24 account:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"CHAT_NOT_FOUND\",\n    \"b24Code\": \"CHAT_NOT_FOUND\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | A parameter other than `limit` and `ignoreMark`, a repeated parameter or an invalid value. Checked before any call to Bitrix24 |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned the `NOT_FOUND` code. The portal code is in `error.b24Code` |\n| 422 | `BITRIX_ERROR` | Bitrix24 returned an error. The portal code is in `error.b24Code`. A missing chat lands here too: `CHAT_NOT_FOUND` |\n| 502 | `ME_ALIAS_RESOLUTION_FAILED` | Failed to resolve the user for the `me` alias |\n| 403 | `BITRIX_ACCESS_DENIED` | The user has no access to the chat — Bitrix24 refused with the `ACCESS_DENIED` code |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | Loading the first page grants quick access to Drive files, so a read-only key cannot call it. Use the [message history in the v2 mode](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist) |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nThe full list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**The initial page may change state.** The call can make you a member of a chat that allows auto-join, and it grants quick access to Drive files.\n\n**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`.\n\n**Continue in the message history.** Read older messages from the [message history in the v2 mode](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist), passing `lastId` equal to the smallest `id` on the page, and newer ones with `order=asc` and `lastId` equal to the largest.\n\n## See also\n\n- [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload)\n- [Read messages](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist)\n- [Messages around a message](\u002Fdocs\u002Fchats\u002Fmessages\u002Fcontext)\n","2026-10-07",{},1794739547542]