[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-bots\u002Fcommands\u002Fanswer":3,"docs-tabs-bots\u002Fcommands\u002Fanswer":6},{"content":4,"lastmod":5},"\n## Answer a command\n\n`POST \u002Fv1\u002Fbots\u002F:botId\u002Fcommands\u002F:commandId\u002Fanswer`\n\nSends a reply to a slash-command invocation. Call it from the `ONIMBOTV2COMMANDADD` event handler.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `botId` (path) | number | yes | Bot ID. List: [`GET \u002Fv1\u002Fbots`](\u002Fdocs\u002Fbots\u002Fmanagement\u002Flist) |\n| `commandId` (path) | number | yes | Command ID. Returned in the `command.id` field of the `ONIMBOTV2COMMANDADD` [bot event](\u002Fdocs\u002Fbots\u002Fevents\u002Fbot-events). The bot's commands: [`GET \u002Fv1\u002Fbots\u002F:botId\u002Fcommands`](\u002Fdocs\u002Fbots\u002Fcommands\u002Flist) |\n\n## Request fields (body)\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `messageId` | number | yes | ID of the message that invoked the command. Returned in the `message.id` field of the `ONIMBOTV2COMMANDADD` event |\n| `dialogId` | string | yes | Dialog ID. For a group chat — `chat{chatId}`, for a private chat — `{userId}`. Returned in the `chat.dialogId` field of the `ONIMBOTV2COMMANDADD` event |\n| `fields` | object | no | Reply message fields |\n| `fields.message` | string | no | Reply text. Supports [BB-codes](\u002Fdocs\u002Fbots\u002Fmessages\u002Fformatting) |\n| `fields.keyboard` | array | no | Interactive [keyboard](\u002Fdocs\u002Fbots\u002Fmessages\u002Fkeyboard) |\n| `fields.attach` | array\u002Fobject | no | [ATTACH blocks](\u002Fdocs\u002Fbots\u002Fmessages\u002Fattach) |\n| `fields.system` | boolean | no | System message. Defaults to `false` |\n| `fields.urlPreview` | boolean | no | Show link previews. Defaults to `true` |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fbots\u002F42\u002Fcommands\u002F7\u002Fanswer \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"messageId\": 1510,\n    \"dialogId\": \"chat123\",\n    \"fields\": {\n      \"message\": \"[b]Task help[\u002Fb]\\n\\nAvailable actions:\\n[SEND=\u002Fstatus]Check status[\u002FSEND]\\n[SEND=\u002Fcreate]Create task[\u002FSEND]\"\n    }\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fbots\u002F42\u002Fcommands\u002F7\u002Fanswer \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"messageId\": 1510,\n    \"dialogId\": \"chat123\",\n    \"fields\": {\n      \"message\": \"[b]Task help[\u002Fb]\\n\\nAvailable actions:\\n[SEND=\u002Fstatus]Check status[\u002FSEND]\\n[SEND=\u002Fcreate]Create task[\u002FSEND]\"\n    }\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fbots\u002F42\u002Fcommands\u002F7\u002Fanswer', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    messageId: 1510,\n    dialogId: 'chat123',\n    fields: {\n      message: '[b]Task help[\u002Fb]\\n\\nAvailable actions:\\n[SEND=\u002Fstatus]Check status[\u002FSEND]',\n    },\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fbots\u002F42\u002Fcommands\u002F7\u002Fanswer', {\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({\n    messageId: 1510,\n    dialogId: 'chat123',\n    fields: {\n      message: '[b]Task help[\u002Fb]\\n\\nAvailable actions:\\n[SEND=\u002Fstatus]Check status[\u002FSEND]',\n    },\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data` | object | Result of sending the reply |\n| `data.result` | boolean | `true` when the reply was sent successfully |\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\n404 — bot not found:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BOT_NOT_FOUND\",\n    \"message\": \"Bot 999 not found. Register it first via POST \u002Fv1\u002Fbots.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_BOT_ID` | `botId` is not a number |\n| 400 | `INVALID_PARAMS` | `commandId` in the path must be a positive integer from `1` to `9007199254740991`, without a sign, leading zeros, fraction, exponent or whitespace. Rejected before calling Bitrix24 |\n| 404 | `BOT_NOT_FOUND` | No bot found with this ID |\n| 403 | `BOT_ACCESS_DENIED` | The bot belongs to a different API key |\n| 422 | `BITRIX_ERROR` | Bitrix24 error (error text in `message`) |\n| 403 | `SCOPE_DENIED` | API key lacks the `imbot` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](\u002Fdocs\u002Faccess-rights) |\n| 410 | `BOT_DISABLED` | The bot is disabled and does not process API calls. How to restore it — [Bot disabled](\u002Fdocs\u002Fbots\u002Ftroubleshooting#bot-disabled-bot_disabled) |\n| 401 | `TOKEN_MISSING` | API key has no configured tokens |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**No chat membership required:** the bot can answer a command even if it is not a member of the chat. Access is granted temporarily through the `messageId` + `commandId` pair. If the bot is not a member, the reply is sent as a system message under the bot's name.\n\n## See also\n\n- [Register a command](\u002Fdocs\u002Fbots\u002Fcommands\u002Fregister)\n- [Events](\u002Fdocs\u002Fbots\u002Fevents)\n- [Text formatting](\u002Fdocs\u002Fbots\u002Fmessages\u002Fformatting)\n- [Keyboard](\u002Fdocs\u002Fbots\u002Fmessages\u002Fkeyboard)\n- [Bot platform](\u002Fdocs\u002Fbots)\n- [Limits and optimization](\u002Fdocs\u002Foptimization)\n","2026-10-13",{},1794739446625]