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.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ParameterbotId (path) |
Typenumber | Requiredyes | DescriptionBot ID. List: GET /v1/bots |
ParametermessageId (path) |
Typenumber | Requiredyes | DescriptionBot message ID. It arrives in the data.id field of the POST /v1/bots/:botId/messages response and in the message.id field of bot events |
Request fields (body)
All fields are optional, but the body must contain at least one of them.
| Field | Type | Required | Description |
|---|---|---|---|
Fieldmessage |
Typestring | Requiredno | DescriptionNew message text (up to 20,000 characters). Supports BB-codes |
Fieldkeyboard |
Typearray | Requiredno | DescriptionNew keyboard. To remove it, pass "N" |
Fieldattach |
Typearray/object | Requiredno | DescriptionNew ATTACH blocks |
FieldurlPreview |
Typeboolean | Requiredno | DescriptionShow 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 |
|---|---|---|
Fielddata.result |
Typeboolean | Descriptiontrue 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 |
|---|---|---|
| HTTP400 | CodeINVALID_BOT_ID |
DescriptionbotId is not a number |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionmessageId 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 |
| HTTP400 | CodeMESSAGE_REQUIRED |
DescriptionThe body carries neither message nor any other content key. An empty message string does not count as content |
| HTTP404 | CodeBOT_NOT_FOUND |
DescriptionNo bot found with this ID |
| HTTP403 | CodeBOT_ACCESS_DENIED |
DescriptionThe bot belongs to a different API key |
| HTTP403 | CodeBITRIX_ACCESS_DENIED |
DescriptionThe message does not belong to the bot or does not exist. A bot updates only its own messages |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionAnother Bitrix24 error, text in message |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe API key does not have the imbot scope |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe key is read-only — see access rights |
| HTTP410 | CodeBOT_DISABLED |
DescriptionThe bot is disabled and does not process API calls. How to restore it — Bot disabled |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe 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, so a request to update them fails with an error.