[{"data":1,"prerenderedAt":12},["ShallowReactive",2],{"docs-chats\u002Fcopilot":3,"docs-tabs-chats\u002Fcopilot":6},{"content":4,"lastmod":5},"# CoPilot\n\nWork in chats with CoPilot, the Bitrix24 artificial intelligence (AI) assistant: open the CoPilot draft chat, switch the assistant's model and role, ask it to regenerate an answer, and rate the answer.\n\n**Scope:** `im` | **Base URL:** `https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1` | **Authorization:** `X-Api-Key`\n\n## Operations\n\n- [CoPilot draft chat](.\u002Fcopilot\u002Fdraft.md) — `POST \u002Fv1\u002Fchats\u002Fcopilot\u002Fdraft`\n- [Change the CoPilot model](.\u002Fcopilot\u002Fengine.md) — `PUT \u002Fv1\u002Fchats\u002F:dialogId\u002Fcopilot\u002Fengine`\n- [Change the CoPilot role](.\u002Fcopilot\u002Frole.md) — `PUT \u002Fv1\u002Fchats\u002F:dialogId\u002Fcopilot\u002Frole`\n- [Regenerate a CoPilot answer](.\u002Fcopilot\u002Fregenerate.md) — `POST \u002Fv1\u002Fchats\u002Fmessages\u002F:messageId\u002Fregenerate`\n- [Rate an answer](.\u002Fcopilot\u002Fvote.md) — `POST \u002Fv1\u002Fchats\u002Fmessages\u002F:messageId\u002Fvote`\n\n## Known specifics\n\n**Every operation in this section is a write.** A read-only key gets `403 WRITE_BLOCKED_READONLY_KEY` before any call to Bitrix24: switching the model or the role changes the chat, regenerating an answer starts a new generation, the draft chat is created on the first call, and any call that takes a chat or a message may make the key owner a chat member when the chat allows auto-join.\n\n**A CoPilot chat is a chat type of its own.** Switching the model and the role works only in a CoPilot chat. In a regular chat the response is `422 BITRIX_ERROR` with the code `WRONG_MESSAGE_TYPE` in `error.b24Code`. The current model and role of a CoPilot chat arrive in the `data.copilot` block of the [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload) response.\n\n**AI is not available on every Bitrix24 account.** When CoPilot is turned off on the account or not included in its plan, the response is `422 BITRIX_ERROR`, with the reason in `error.b24Code` — for example, `DRAFT_CHAT_NOT_AVAILABLE` or `AI_NOT_AVAILABLE`.\n\n## See also\n\n- [Chats and messages](\u002Fdocs\u002Fchats)\n- [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload)\n- [Transcribe an audio file](\u002Fdocs\u002Fchats\u002Ffiles\u002Ftranscribe)\n","2026-10-15",{"copilot\u002Fdraft.md":7,"copilot\u002Fengine.md":8,"copilot\u002Frole.md":9,"copilot\u002Fregenerate.md":10,"copilot\u002Fvote.md":11},"\n## CoPilot draft chat\n\n`POST \u002Fv1\u002Fchats\u002Fcopilot\u002Fdraft`\n\nOpens the current user's CoPilot draft chat. The response has the same structure as in [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload): the chat card, the first page of messages, pinned messages, participants, files and the `copilot` block. When there is no draft chat yet, the first call creates it.\n\n## Parameters\n\nThere are no path or query parameters. Any query parameter is rejected with `400 INVALID_PARAMS`.\n\n## Request fields (body)\n\nThe body is optional.\n\n| Field | Type | Required | Default | Description |\n|------|-----|:-----:|-----------|---------|\n| `messageLimit` | number | no | — | How many messages to return on the first page. 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` | number | no | — | How many pinned messages to return. From 1 to 200; the passed and applied values are in `meta.requestedPinLimit` and `meta.appliedPinLimit` |\n\nOther body fields are rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fcopilot\u002Fdraft \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"messageLimit\": 20}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fcopilot\u002Fdraft \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"messageLimit\": 20}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fcopilot\u002Fdraft', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ messageLimit: 20 }),\n})\n\nconst { data } = await res.json()\nconsole.log('Draft chat:', data.chat.dialogId)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fcopilot\u002Fdraft', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ messageLimit: 20 }),\n})\n\nconst { data } = await res.json()\nconsole.log('Draft chat:', data.chat.dialogId)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.chat` | object | The draft chat card: `id`, `dialogId`, `name`, `type`, `owner`, `role` and other fields |\n| `data.messages` | array | The first page of messages |\n| `data.pins` | array | Pinned messages |\n| `data.users` | array | Participants mentioned on the page |\n| `data.files` | array | Files of the messages on the page |\n| `data.reactions` | array | Reactions to the messages on the page |\n| `data.copilot` | object | The CoPilot block |\n| `data.copilot.chats` | array | CoPilot chats on the page: `dialogId`, `role` — the role code, `engine` — the model code, `titleIsCustom` |\n| `data.copilot.messages` | array\\|null | CoPilot roles of the messages on the page. `null` if there are no such messages |\n| `data.copilot.engines` | array\\|null | Models of the chats on the page: `code`, `name`, `supportsReasoning` |\n| `data.copilot.roles` | object\\|null | Roles keyed by role code: `code`, `name`, `desc`, `avatar`, `default`, `prompts` |\n| `data.copilot.aiProvider` | string | Name of the default model |\n| `data.hasPrevPage` | boolean | Whether there are messages older than the first page |\n| `data.hasNextPage` | boolean | Whether there are messages newer than the first page |\n| `meta.requestedMessageLimit` | number | The `messageLimit` sent, when it fell outside the range from 1 to 200 |\n| `meta.appliedMessageLimit` | number | The applied `messageLimit` — only when it was clamped to a bound |\n| `meta.requestedPinLimit` | number | The `pinLimit` sent, when it fell outside the range from 1 to 200 |\n| `meta.appliedPinLimit` | number | The applied `pinLimit` — 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\": 2001,\n      \"dialogId\": \"chat2001\",\n      \"name\": \"CoPilot\",\n      \"type\": \"copilot\",\n      \"owner\": 5,\n      \"role\": \"owner\"\n    },\n    \"messages\": [\n      {\n        \"id\": 9001,\n        \"chatId\": 2001,\n        \"authorId\": 0,\n        \"date\": \"2026-09-25T10:00:00+00:00\",\n        \"text\": \"Hi! How can I help?\",\n        \"params\": {}\n      }\n    ],\n    \"pins\": [],\n    \"users\": [],\n    \"files\": [],\n    \"reactions\": [],\n    \"copilot\": {\n      \"chats\": [\n        { \"dialogId\": \"chat2001\", \"role\": \"copilot_assistant\", \"engine\": \"b24ai\", \"titleIsCustom\": false }\n      ],\n      \"messages\": null,\n      \"engines\": [\n        { \"code\": \"b24ai\", \"name\": \"BitrixGPT 5.5\", \"supportsReasoning\": true }\n      ],\n      \"roles\": {\n        \"copilot_assistant\": {\n          \"code\": \"copilot_assistant\",\n          \"name\": \"BitrixGPT\",\n          \"desc\": \"Ready to answer any question in a general format\",\n          \"avatar\": { \"small\": \"\", \"medium\": \"\", \"large\": \"\" },\n          \"default\": true,\n          \"prompts\": []\n        }\n      },\n      \"aiProvider\": \"BitrixGPT 5.5\"\n    },\n    \"hasPrevPage\": false,\n    \"hasNextPage\": false\n  }\n}\n```\n\n## Error response example\n\n422 — the CoPilot draft chat is not available in the Bitrix24 account:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"DRAFT_CHAT_NOT_AVAILABLE\",\n    \"b24Code\": \"DRAFT_CHAT_NOT_AVAILABLE\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `messageLimit` or `pinLimit` is not an integer, or another body field or a query parameter was sent. Checked before any call to Bitrix24 |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused. The portal code is in `error.b24Code`. `DRAFT_CHAT_NOT_AVAILABLE` — the draft chat is turned off on the portal |\n| 403 | `BITRIX_ACCESS_DENIED` | The user is not allowed to create CoPilot chats — 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` | The key is read-only — the first call creates a chat |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nThe full list of general API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**Response keys.** Keys that name fields are converted to camelCase. 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` — the same value that `role` carries in `data.copilot.chats`, so you can look up a role directly as `roles[role]`.\n\n**Continue in the message history.** Load older messages with the [message history in the v2 mode](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist) using `data.chat.dialogId`.\n\n## See also\n\n- [CoPilot](\u002Fdocs\u002Fchats\u002Fcopilot)\n- [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload)\n- [Change the CoPilot model](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fengine)\n","\n## Change the CoPilot model\n\n`PUT \u002Fv1\u002Fchats\u002F:dialogId\u002Fcopilot\u002Fengine`\n\nSwitches the artificial intelligence (AI) model that CoPilot uses to answer in a chat. Works only in a CoPilot chat. After the switch, a system message about the new model appears in the chat.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `dialogId` (path) | string | yes | Dialog ID of a CoPilot chat — `chatN`. Get it from `data.chat.dialogId` of the [draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft) or from [recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) called with `onlyCopilot=true` |\n\nQuery parameters are not accepted and are rejected with `400 INVALID_PARAMS`.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `engineCode` | string | yes | Code of an AI model available in the Bitrix24 account. The chat's current model is `engine` in `data.copilot.chats` returned by [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload) |\n\nOther body fields are rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PUT https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Fengine \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"engineCode\": \"engine_code\"}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Fengine \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"engineCode\": \"engine_code\"}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Fengine', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ engineCode: 'engine_code' }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Model switched:', data.result)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Fengine', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ engineCode: 'engine_code' }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Model switched:', data.result)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.result` | boolean | `true` — the model was switched |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"result\": true\n  }\n}\n```\n\n## Error response example\n\n422 — the chat is not a CoPilot chat:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"WRONG_MESSAGE_TYPE\",\n    \"b24Code\": \"WRONG_MESSAGE_TYPE\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `engineCode` is missing or is not a non-empty string, or another body field or a query parameter was sent. 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 refused with `WRONG_MESSAGE_TYPE` in `error.b24Code` — the chat is not a CoPilot chat |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `IDENTICAL_ENGINE` in `error.b24Code` — the chat already uses this model |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `ENGINE_NOT_FOUND` in `error.b24Code` — no model with this code |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `COPILOT_NOT_INSTALLED` in `error.b24Code` — CoPilot is not installed on the portal |\n| 502 | `ME_ALIAS_RESOLUTION_FAILED` | Failed to resolve the user when using the `me` alias |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — the call changes the chat |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nThe full list of general API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**Switching to the same model again is refused.** Before switching, compare `engine` from `data.copilot.chats` with the model you need.\n\n**The choice is remembered.** The model is saved as the one the user selected last.\n\n## See also\n\n- [CoPilot](\u002Fdocs\u002Fchats\u002Fcopilot)\n- [Change the CoPilot role](\u002Fdocs\u002Fchats\u002Fcopilot\u002Frole)\n- [CoPilot draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft)\n","\n## Change the CoPilot role\n\n`PUT \u002Fv1\u002Fchats\u002F:dialogId\u002Fcopilot\u002Frole`\n\nSets the role CoPilot uses when answering in a chat. The role defines the style and specialization of the answers. Works only in a CoPilot chat.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `dialogId` (path) | string | yes | Dialog ID of a CoPilot chat — `chatN`. Get it from `data.chat.dialogId` of the [draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft) or from the [recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) list with `onlyCopilot=true` |\n\nQuery parameters are not accepted and are rejected with `400 INVALID_PARAMS`.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `role` | string\\|null | yes | A role code, or `null` for the default role. Role codes are the keys of `data.copilot.roles` returned by [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload) |\n\nOther body fields are rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PUT https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Frole \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"role\": \"copilot_assistant\"}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Frole \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"role\": \"copilot_assistant\"}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Frole', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ role: 'copilot_assistant' }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Role set:', data.result)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Frole', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ role: 'copilot_assistant' }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Role set:', data.result)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.result` | boolean | `true` — the role was set |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"result\": true\n  }\n}\n```\n\n## Error response example\n\n400 — the `role` field was not sent:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"`role` is required (a role code, or null for the default role).\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | The `role` field is missing, is neither a non-empty string nor `null`, or another body field or a query parameter was sent. 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 refused with `WRONG_MESSAGE_TYPE` in `error.b24Code` — the chat is not a CoPilot chat |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `IDENTICAL_ROLE` in `error.b24Code` — the chat already has this role |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `ROLE_NOT_FOUND` in `error.b24Code` — no role with this code |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `COPILOT_NOT_INSTALLED` in `error.b24Code` — CoPilot is not installed on the portal |\n| 502 | `ME_ALIAS_RESOLUTION_FAILED` | Failed to resolve the user when using the `me` alias |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — the call changes the chat |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nThe full list of general API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## See also\n\n- [CoPilot](\u002Fdocs\u002Fchats\u002Fcopilot)\n- [Change the CoPilot model](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fengine)\n- [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload)\n","\n## Regenerate a CoPilot answer\n\n`POST \u002Fv1\u002Fchats\u002Fmessages\u002F:messageId\u002Fregenerate`\n\nAsks CoPilot to answer the same question again. Works for a CoPilot answer in a CoPilot chat.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `messageId` (path) | number | yes | ID of a CoPilot answer. Get it from `data.messages[].id` of the [draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft) or of the [message history in the v2 mode](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist) |\n\nThe endpoint accepts no request body and no query parameters: any body field or query parameter is rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F9002\u002Fregenerate \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F9002\u002Fregenerate \\\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\u002F9002\u002Fregenerate', {\n  method: 'POST',\n  headers: { 'X-Api-Key': 'YOUR_API_KEY' },\n})\n\nconst { success, data } = await res.json()\nconsole.log('Generation started:', data.result)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F9002\u002Fregenerate', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\n\nconst { success, data } = await res.json()\nconsole.log('Generation started:', data.result)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.result` | boolean | `true` — the generation has started |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"result\": true\n  }\n}\n```\n\n## Error response example\n\n422 — the message is not from a CoPilot chat:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"WRONG_CHAT_TYPE\",\n    \"b24Code\": \"WRONG_CHAT_TYPE\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `messageId` is not a positive integer, or a body field or a query parameter was sent. 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 refused with `WRONG_CHAT_TYPE` in `error.b24Code` — the message is not from a CoPilot chat |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `NOT_BOT_MESSAGE` in `error.b24Code` — the message is not a CoPilot answer |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `REGENERATE_NOT_AVAILABLE` in `error.b24Code` — the original question is gone or not visible to the user |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `AI_NOT_AVAILABLE` in `error.b24Code` — AI is not available on the portal |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — the call starts a generation |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nThe full list of general API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**The call invokes the AI of your Bitrix24 account.** Every regeneration is a new request to the model and counts against the account's AI limit.\n\n**The answer arrives as a message.** The endpoint does not wait for the generation to finish. Read the new answer with the [message history in the v2 mode](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist) or receive it through [events](\u002Fdocs\u002Fchats\u002Fevents).\n\n## See also\n\n- [CoPilot](\u002Fdocs\u002Fchats\u002Fcopilot)\n- [Rate an answer](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fvote)\n- [CoPilot draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft)\n","\n## Rate an answer\n\n`POST \u002Fv1\u002Fchats\u002Fmessages\u002F:messageId\u002Fvote`\n\nRates a message with \"like\" or \"dislike\". Meant for rating CoPilot answers.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `messageId` (path) | number | yes | Message ID. Get it from `data.messages[].id` of the [draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft) or of the [message history in the v2 mode](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist) |\n\nQuery parameters are not accepted and are rejected with `400 INVALID_PARAMS`.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `value` | string | yes | The rating: `like` or `dislike` |\n\nOther body fields are rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F9002\u002Fvote \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"value\": \"like\"}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F9002\u002Fvote \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"value\": \"like\"}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F9002\u002Fvote', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ value: 'like' }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Rating sent:', data.result)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F9002\u002Fvote', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ value: 'like' }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Rating sent:', data.result)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.result` | boolean | `true` — the rating was sent |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"result\": true\n  }\n}\n```\n\n## Error response example\n\n400 — an invalid `value`:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"`value` must be `like` or `dislike`.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `messageId` is not a positive integer, `value` is missing or is neither `like` nor `dislike`, or another body field or a query parameter was sent. 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` |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — the call may make the key owner a chat member |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**The call may make you a member.** If the message's chat allows auto-join — for example, a comment chat, a collab or a task chat — the call adds the current user as a member, just as opening the chat in the Bitrix24 interface does. The call therefore counts as a write.\n\n**Rating any message.** The endpoint accepts a rating for any message and returns `result: true`. Only ratings of CoPilot answers in a CoPilot chat are taken into account. This endpoint cannot read a rating back.\n\n## See also\n\n- [CoPilot](\u002Fdocs\u002Fchats\u002Fcopilot)\n- [Regenerate a CoPilot answer](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fregenerate)\n- [CoPilot draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft)\n",1794739533154]