For AI agents: markdown of this page — /docs-content-en/chats/messages/pins-create.md documentation index — /llms.txt

Pin a message

POST /v1/chats/messages/:messageId/pin

Pins a message in the chat it belongs to and adds it to the list of pinned messages. The chat is resolved from the message, so no dialogId is needed.

Parameters

Parameter Type Required Description
ParametermessageId (path) Typenumber Requiredyes DescriptionMessage ID, a positive integer — from the chat feed (GET /v1/chats/:dialogId/messages) or from the send response

No body and no query parameters are accepted: any body field or query parameter is rejected with 400 INVALID_PARAMS.

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/chats/messages/1001/pin" \
  -H "X-Api-Key: YOUR_API_KEY"

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/chats/messages/1001/pin" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/1001/pin', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success } = await res.json()
console.log('Pinned:', success)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/1001/pin', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success } = await res.json()
console.log('Pinned:', success)

Response fields

Field Type Description
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata Typearray DescriptionAn empty array

Response example

JSON
{
  "success": true,
  "data": []
}

Error response example

422 — the message is already pinned:

JSON
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "MESSAGE_IS_ALREADY_PIN",
    "b24Code": "MESSAGE_IS_ALREADY_PIN"
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptionmessageId is not a positive integer, or a body field or query parameter was passed. Checked before any call to Bitrix24
HTTP404 CodeENTITY_NOT_FOUND DescriptionBitrix24 reported "not found"; the portal code is in error.b24Code
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 returned an error; the code is in error.b24Code: MESSAGE_IS_ALREADY_PIN — the message is already pinned, MESSAGE_NOT_FOUND — there is no such message
HTTP403 CodeSCOPE_DENIED DescriptionThe API key does not have the im scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionA read-only key cannot pin messages — see access rights
HTTP401 CodeTOKEN_MISSING DescriptionThe API key has no Bitrix24 tokens configured

Full list of common API errors — Errors.

Known specifics

Pinning shows in the chat. A system message about the pin appears in the chat, quoting the pinned text. It stays in the chat after the message is unpinned.

See also