For AI agents: markdown of this page — /docs-content-en/bots/messages/update.md documentation index — /llms.txt
Update message
PATCH /v1/bots/:botId/messages/:messageId
Updates a message previously sent by the bot. The bot can only update its own messages.
Request fields (body)
| Parameter | Type | Description |
|---|---|---|
message |
string | New message text (up to 20,000 characters). Supports BB-codes |
keyboard |
array | New keyboard. To remove it, pass "N" |
attach |
array/object | New ATTACH blocks |
urlPreview |
boolean | Show link previews |
Examples
curl — personal key
curl -X PATCH https://vibecode.bitrix24.com/v1/bots/42/messages/1502 \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Updated message text",
"keyboard": [
{
"TEXT": "Done",
"BG_COLOR_TOKEN": "primary",
"DISABLED": "Y"
}
]
}'
curl — OAuth application
curl -X PATCH https://vibecode.bitrix24.com/v1/bots/42/messages/1502 \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": "Updated message text",
"keyboard": [
{
"TEXT": "Done",
"BG_COLOR_TOKEN": "primary",
"DISABLED": "Y"
}
]
}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/messages/1502', {
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
message: 'Updated message text',
keyboard: [
{
TEXT: 'Done',
BG_COLOR_TOKEN: 'primary',
DISABLED: 'Y',
},
],
}),
})
const { success, data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/messages/1502', {
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
message: 'Updated message text',
keyboard: [
{
TEXT: 'Done',
BG_COLOR_TOKEN: 'primary',
DISABLED: 'Y',
},
],
}),
})
const { success, data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
data.result |
boolean | true on successful update |
Response example
{
"success": true,
"data": {
"result": true
}
}
Error response example
403 — the message does not belong to the bot or does not exist:
{
"success": false,
"error": {
"code": "BITRIX_ACCESS_DENIED",
"message": "Access denied"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_BOT_ID |
botId is not a number |
| 400 | MESSAGE_REQUIRED |
The body carries neither message nor any other content key. An empty message string does not count as content. Previously such a request returned 200 and changed nothing |
| 404 | BOT_NOT_FOUND |
No bot found with this ID |
| 403 | BOT_ACCESS_DENIED |
The bot belongs to a different API key |
| 403 | BITRIX_ACCESS_DENIED |
The message does not belong to the bot or does not exist. A bot updates only its own messages |
| 422 | BITRIX_ERROR |
Another Bitrix24 error, text in message |
| 403 | SCOPE_DENIED |
The API key does not have the imbot scope |
| 401 | TOKEN_MISSING |
The API key has no configured tokens |
Full list of common API errors — Errors.
Known specifics
System messages cannot be updated: messages sent with system: true have authorId = 0 and do not belong to the bot from a permissions standpoint. Bitrix24 returns an error.
Removing the keyboard: pass "keyboard": "N" to remove the keyboard from a message.