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 |
|---|---|---|---|
messageId (path) |
number | yes | Message 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
curl -X POST "https://vibecode.bitrix24.com/v1/chats/messages/1001/pin" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
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
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
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 |
|---|---|---|
success |
boolean | Always true on success |
data |
array | An empty array |
Response example
{
"success": true,
"data": []
}
Error response example
422 — the message is already pinned:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "MESSAGE_IS_ALREADY_PIN",
"b24Code": "MESSAGE_IS_ALREADY_PIN"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS |
messageId is not a positive integer, or a body field or query parameter was passed. Checked before any call to Bitrix24 |
| 404 | ENTITY_NOT_FOUND |
Bitrix24 reported "not found"; the portal code is in error.b24Code |
| 422 | BITRIX_ERROR |
Bitrix24 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 |
| 403 | SCOPE_DENIED |
The API key does not have the im scope |
| 403 | WRITE_BLOCKED_READONLY_KEY |
A read-only key cannot pin messages — see access rights |
| 401 | TOKEN_MISSING |
The 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.