[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fcopilot\u002Fregenerate":3,"docs-tabs-chats\u002Fcopilot\u002Fregenerate":6},{"content":4,"lastmod":5},"\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","2026-10-07",{},1794739533534]