For AI agents: markdown of this page — /docs-content-en/chats/messages/send.md documentation index — /llms.txt
Send a message
POST /v1/chats/:dialogId/messages
Sends a text message to the given dialog. The text supports BB codes for formatting; you can add a keyboard and attachments to the message.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
dialogId (path) |
string | yes | Dialog identifier. Numeric user ID for personal messages (user list: GET /v1/users). chatXXX for group chats. Accepts the value me — see below |
format (query) |
string | no | v2 turns on the v2 mode — see "The v2 mode" below. Any other value is ignored and the response is unchanged. A repeated format is not rejected: with format=v1&format=v2 the last value wins, so the v2 mode is on, while format=v2&format=v1 returns the legacy response. The bracket form format[]=v2 turns on the v2 mode when all its values are v2 |
The me alias. Instead of a numeric user ID you can pass the string me: the dialog opens with the current key owner. Learn more in Chats and messages.
The v2 mode. format=v2 sends the message with im.v2.Chat.Message.send. The body stays flat — the same fields as below — and data carries the object { id, uuidMap, failureMap } instead of a number. The mode accepts only the fields in the table below, including those marked "the v2 mode only"; any other body field, uppercase forms (MESSAGE, REPLY_ID) and query parameters other than format are rejected with 400 INVALID_PARAMS, which names the field without repeating its value. In the v2 mode message must be a string. Under the Bitrix24 rule, the message must have content: non-empty text; whitespace-only text is accepted only with a non-empty attach; without message, a non-empty attach, stickerParams or block is required. Otherwise the route returns 400 MESSAGE_REQUIRED before any call to the Bitrix24 account. Forwarding goes through POST /v1/chats/:dialogId/forward: in the v2 mode the forwardIds field is rejected with an error that points to that endpoint, and botId with one that points to sending as a bot.
Request body fields
| Field | Type | Required | Description |
|---|---|---|---|
message |
string | yes | Message text (up to 20,000 characters). Supports BB codes |
attach |
array | no | Attachments: cards, tables, images, files, dividers |
keyboard |
array | no | Interactive buttons under the message |
menu |
array | no | Message context menu items |
replyId |
number | no | ID of the quoted message |
system |
boolean | no | When true, the message uses the system style (no avatar, authorId = 0) |
urlPreview |
boolean | no | When false, disables link preview in the text |
skipConnector |
boolean | no | The v2 mode only: do not pass the message to the Open Channels connector. true/false or "Y"/"N" |
silentConnector |
boolean | no | The v2 mode only: pass the message to the Open Channels connector without notifying the client. true/false or "Y"/"N" |
templateId |
string | no | The v2 mode only: your own message identifier, from 1 to 255 characters. A longer value is rejected with 400 rather than truncated |
stickerParams |
object | no | The v2 mode only: a sticker — id, packId, packType (vendor or custom) |
block |
object|array | no | The v2 mode only: message blocks in the Bitrix24 format; the Bitrix24 account validates them and builds the text from them |
copilot |
object | no | The v2 mode only: CoPilot parameters for the message, passed as is |
aiAssistant |
object | no | The v2 mode only: AI assistant parameters for the message, passed as is |
Message layout
- Text formatting — BB codes: bold, italic, links, color
- Keyboard — interactive buttons under the message
- Attachments — cards, tables, images, files
Examples
In the examples, dialogId is 42 — the recipient's numeric user ID.
curl — personal key
curl -X POST https://vibecode.bitrix24.com/v1/chats/42/messages \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Invoice issued. Please await confirmation."
}'
curl — OAuth application
curl -X POST https://vibecode.bitrix24.com/v1/chats/42/messages \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": "Invoice issued. Please await confirmation."
}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/42/messages', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
message: 'Invoice issued. Please await confirmation.',
}),
})
const { success, data } = await res.json()
console.log('Message ID:', data)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/42/messages', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
message: 'Invoice issued. Please await confirmation.',
}),
})
const { success, data } = await res.json()
console.log('Message ID:', data)
curl — the v2 mode
curl -X POST "https://vibecode.bitrix24.com/v1/chats/42/messages?format=v2" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Invoice issued. Please await confirmation.",
"urlPreview": false
}'
Response fields
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data |
number | ID of the created message |
data.id |
number | The v2 mode: ID of the created message |
data.uuidMap |
array|object | The v2 mode: mapping of forwarding identifiers to messages; empty for a regular send |
data.failureMap |
array|object | The v2 mode: forwarding failures; empty for a regular send |
Response example
{
"success": true,
"data": 36889
}
Error response example
422 — Bitrix24 returned an error (dialog not found or unavailable):
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "Dialog not found"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | MESSAGE_REQUIRED |
The message field is empty and there is no attach block. A common cause is text passed under an unknown field name, for example text. The error message lists the unrecognized fields. In the v2 mode, the Bitrix24 rule applies — see "The v2 mode" |
| 400 | INVALID_PARAMS |
The v2 mode only: a body field outside the list, a query parameter other than format or an invalid value. Checked before any call to Bitrix24 |
| 403 | WRITE_BLOCKED_READONLY_KEY |
The key is read-only — see access rights |
| 422 | BITRIX_ERROR |
Bitrix24 returned an error — dialog not found or unavailable (details in message) |
| 502 | ME_ALIAS_RESOLUTION_FAILED |
dialogId=me — failed to resolve the current user's ID |
| 403 | BITRIX_ACCESS_DENIED |
The v2 mode only: the user has no access to the chat — Bitrix24 refused with the ACCESS_DENIED code |
| 403 | SCOPE_DENIED |
The key does not have the im scope |
| 401 | TOKEN_MISSING |
The key has no configured tokens |
Full list of common API errors — Errors.
Known specifics
System messages. When system: true, the message is shown without the sender's avatar and the authorId field equals 0. Such a message cannot be edited or deleted via the API.
Long text truncation. Text longer than 20,000 characters is truncated to 20,000, with (...) appended at the end.
The v2 mode and Bitrix24 errors. In the v2 mode the Bitrix24 error code arrives in error.b24Code.