[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmessages\u002Fload-in-context":3,"docs-tabs-chats\u002Fmessages\u002Fload-in-context":6},{"content":4,"lastmod":5},"## Load around a message\n\n`GET \u002Fv1\u002Fchats\u002Fmessages\u002F:messageId\u002Fload`\n\nOpens a chat at the given message in one request — like [loading a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload), but the page is built around the given message instead of the last read one. The chat is found by the message, so `dialogId` is not needed.\n\n## Parameters\n\n| Parameter | Type | Required | Default | Description |\n|----------|-----|:-----:|-----------|---------|\n| `messageId` (path) | number | yes | — | Message ID, a positive integer — the `id` field of a message from the [message history](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist), [message search](\u002Fdocs\u002Fchats\u002Fmessages\u002Fsearch) or [chat loading](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload) |\n| `messageLimit` (query) | number | no | 50 | How many messages to take on each side of the given one. From 1 to 200: a value outside the range is clamped; the passed and applied values are in `meta.requestedMessageLimit` and `meta.appliedMessageLimit` |\n| `pinLimit` (query) | number | no | 50 | How many pinned messages to return. From 1 to 200; the passed and applied values are in `meta.requestedPinLimit` and `meta.appliedPinLimit` |\n\nOther or repeated parameters are rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F1002\u002Fload?messageLimit=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\u002Fmessages\u002F1002\u002Fload?messageLimit=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\u002Fmessages\u002F1002\u002Fload?messageLimit=20', {\n  headers: { 'X-Api-Key': 'YOUR_API_KEY' },\n})\n\nconst { data } = await res.json()\nconsole.log('Chat:', data.chat.dialogId)\nconsole.log('Has older:', data.hasPrevPage, 'has newer:', data.hasNextPage)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F1002\u002Fload?messageLimit=20', {\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\n\nconst { data } = await res.json()\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.chat` | object | The card of the message's chat: `id`, `dialogId`, `name`, `type`, `owner`, `role`, `permissions` and other fields |\n| `data.messages` | array | The given message and its neighbours |\n| `data.messages[].id` | number | Message ID |\n| `data.messages[].chatId` | number | Chat ID — equals `data.chat.id` |\n| `data.messages[].authorId` | number | Author ID — the profile can be fetched [by user ID](\u002Fdocs\u002Fentities\u002Fusers\u002Fget). `0` — a system message |\n| `data.messages[].date` | string | Date sent (ISO 8601) |\n| `data.messages[].text` | string | Message text |\n| `data.pins` | array | Pinned messages |\n| `data.users` | array | Members mentioned on the page |\n| `data.files` | array | Files of the page's messages |\n| `data.reactions` | array | Reactions to the page's messages |\n| `data.hasPrevPage` | boolean | Whether there are messages older than the page |\n| `data.hasNextPage` | boolean | Whether there are messages newer than the page |\n| `data.callInfo` | object | Chat context: `chatId` and `token` — the current user's call token. The endpoint passes it through unchanged. Do not write it to logs |\n| `meta.requestedMessageLimit` | number | The `messageLimit` passed, when it was outside the range from 1 to 200 |\n| `meta.appliedMessageLimit` | number | The applied `messageLimit` value — only when it was clamped to a bound |\n| `meta.requestedPinLimit` | number | The `pinLimit` passed, when it was outside the range from 1 to 200 |\n| `meta.appliedPinLimit` | number | The applied `pinLimit` value — only when it was clamped to a bound |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"chat\": {\n      \"id\": 42,\n      \"dialogId\": \"chat42\",\n      \"name\": \"Project\",\n      \"type\": \"chat\",\n      \"owner\": 5,\n      \"role\": \"member\"\n    },\n    \"messages\": [\n      {\n        \"id\": 1001,\n        \"chatId\": 42,\n        \"authorId\": 5,\n        \"date\": \"2026-09-20T10:00:00+00:00\",\n        \"text\": \"Please check 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    \"pins\": [],\n    \"users\": [],\n    \"files\": [],\n    \"reactions\": [],\n    \"hasPrevPage\": true,\n    \"hasNextPage\": true\n  }\n}\n```\n\n## Error response example\n\n422 — the message does not exist in the Bitrix24 account:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"MESSAGE_NOT_FOUND\",\n    \"b24Code\": \"MESSAGE_NOT_FOUND\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `messageId` is not a positive integer, or the request has a parameter other than `messageLimit` and `pinLimit`, a repeated parameter or an invalid value. Checked before any call to Bitrix24 |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned \"not found\". The portal code is in `error.b24Code` |\n| 422 | `BITRIX_ERROR` | Bitrix24 returned an error. The portal code is in `error.b24Code`. A missing message lands here too (`MESSAGE_NOT_FOUND`), as does a message older than the start of the chat history open to the user (`MESSAGE_ACCESS_DENIED`) |\n| 403 | `BITRIX_ACCESS_DENIED` | The user has no access to the message's chat — Bitrix24 refused with the `ACCESS_DENIED` code |\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\nThe full list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**Opening the chat may make you a member.** When the message's chat allows auto-join, the call adds the current user as a member, as [loading a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload) does. This targeted read operation is available to a `READONLY` key, subject to the `im` scope and the user's Bitrix24 permissions. It does not mark messages as read by itself.\n\n**How it differs from messages around a message.** [Messages around a message](\u002Fdocs\u002Fchats\u002Fmessages\u002Fcontext) returns only a page of messages with their authors and files. Loading around a message also returns the chat card, pinned messages and the chat context — everything needed to open the chat from scratch, for example from a link to a message.\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- [Messages around a message](\u002Fdocs\u002Fchats\u002Fmessages\u002Fcontext)\n- [Read messages](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist)\n","2026-10-07",{},1795000515637]