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
ParameterdialogId (path) Typestring Requiredyes DescriptionDialog identifier. Numeric user ID for personal messages (user list: GET /v1/users). chatXXX for group chats. Accepts the value me — see below
Parameterformat (query) Typestring Requiredno Descriptionv2 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. 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. 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
Fieldmessage Typestring Requiredno DescriptionMessage text — up to 20000 Unicode code points. Supports BB codes. Can be omitted when a non-empty attach, keyboard or menu is passed; in the v2 mode — a non-empty attach, stickerParams or block
Fieldattach Typearray Requiredno DescriptionAttachments: cards, tables, images, files, dividers
Fieldkeyboard Typearray Requiredno DescriptionInteractive buttons under the message
Fieldmenu Typearray Requiredno DescriptionMessage context menu items
FieldreplyId Typenumber Requiredno DescriptionID of the quoted message
Fieldsystem Typeboolean Requiredno DescriptionWhen true, the message uses the system style (no avatar, authorId = 0)
FieldurlPreview Typeboolean Requiredno DescriptionWhen false, disables link preview in the text
FieldskipConnector Typeboolean Requiredno DescriptionThe v2 mode only: do not pass the message to the Open Channels connector. true/false or "Y"/"N"
FieldsilentConnector Typeboolean Requiredno DescriptionThe v2 mode only: pass the message to the Open Channels connector without notifying the client. true/false or "Y"/"N"
FieldtemplateId Typestring Requiredno DescriptionThe v2 mode only: your own message identifier, from 1 to 255 characters. A longer value is rejected with 400 rather than truncated
FieldstickerParams Typeobject Requiredno DescriptionThe v2 mode only: a sticker. If any of the three fields below is missing, the Bitrix24 account rejects the send with 422 BITRIX_ERROR and b24Code STICKER_SENDING_ERROR
FieldstickerParams.id Typenumber Requiredyes DescriptionSticker ID — the data.stickers[].id field of the list of sticker packs. Required when stickerParams is passed
FieldstickerParams.packId Typenumber Requiredyes DescriptionSticker pack ID — the data.stickers[].packId field of the list of sticker packs. Required when stickerParams is passed
FieldstickerParams.packType Typestring Requiredyes DescriptionPack type: vendor — built-in, custom — a user's pack. The data.stickers[].packType field of the list of sticker packs. Required when stickerParams is passed
Fieldblock Typeobject|array Requiredno DescriptionThe v2 mode only: message blocks in the Bitrix24 format. The Bitrix24 account validates them and builds the text from them
Fieldcopilot Typeobject Requiredno DescriptionThe v2 mode only: CoPilot parameters for the message, passed as is
FieldaiAssistant Typeobject Requiredno DescriptionThe v2 mode only: AI assistant parameters for the message, passed as is

Message layout

The message text is limited to 20000 Unicode code points. The complete outgoing string is counted, including markup, URLs and mentions, without truncation or trimming. For example, 😀 is one code point, while a compound emoji may occupy several. The request is rejected before any call to Bitrix24.

Without format=v2, matching text aliases message, MESSAGE, Message and fields.message are accepted, including other case variants. Their values must agree. A conflict returns 400 INVALID_PARAMS. An object is never converted to text. The v2 mode keeps its flat body whitelist: case variants and fields are not accepted.

Examples

In the examples, dialogId is 42 — the recipient's numeric user ID.

curl — personal key

Terminal
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

Terminal
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

javascript
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

javascript
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

Terminal
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
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata Typenumber DescriptionID of the created message
Fielddata.id Typenumber DescriptionThe v2 mode: ID of the created message
Fielddata.uuidMap Typearray|object DescriptionThe v2 mode: mapping of forwarding identifiers to messages. Empty for a regular send
Fielddata.failureMap Typearray|object DescriptionThe v2 mode: forwarding failures. Empty for a regular send

Response example

The regular mode:

JSON
{
  "success": true,
  "data": 36889
}

The v2 mode — format=v2:

JSON
{
  "success": true,
  "data": {
    "id": 36889,
    "uuidMap": [],
    "failureMap": []
  }
}

Error response example

400 — no message text was passed:

JSON
{
  "success": false,
  "error": {
    "code": "MESSAGE_REQUIRED",
    "message": "Message is empty. Put the message text in the \"message\" field (or send an \"attach\" block)."
  }
}

Errors

HTTP Code Description
HTTP400 CodeMESSAGE_TOO_LONG DescriptionMore than 20000 Unicode code points in the outgoing text. error.details contains only field: "message", used, limit: 20000, unit: "unicode-code-points". No Bitrix24 call is made
HTTP400 CodeMESSAGE_REQUIRED DescriptionThe message field is empty and there is no non-empty attach, keyboard or menu. One of the causes is text passed under an unknown field name, for example text. The error message lists the unrecognized fields. In the v2 mode, the rule from "The v2 mode" paragraph above applies instead
HTTP400 CodeINVALID_PARAMS DescriptionConflicting legacy text aliases. 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
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is read-only — see access rights
HTTP404 CodeENTITY_NOT_FOUND DescriptionBitrix24 reported "not found". The Bitrix24 code is in error.b24Code — only in the v2 mode
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 returned an error — dialog not found or unavailable (details in message). The Bitrix24 code is in error.b24Code
HTTP502 CodeME_ALIAS_RESOLUTION_FAILED DescriptiondialogId=me — failed to resolve the current user's ID
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe v2 mode only: the user has no access to the chat — Bitrix24 refused with the ACCESS_DENIED code
HTTP403 CodeSCOPE_DENIED DescriptionThe key does not have the im scope
HTTP401 CodeTOKEN_MISSING DescriptionThe key has no configured tokens

Full list of common API errors — Errors.

Known specifics

The Bitrix24 refusal code. The Bitrix24 refusal code arrives in error.b24Code. In a 404 ENTITY_NOT_FOUND response this field is present only in the v2 mode.

See also