For AI agents: markdown of this page — /docs-content-en/chats/management/pin-sort.md documentation index — /llms.txt
Pinned chat order
PUT /v1/chats/:dialogId/pin
Moves a pinned chat to the given position among the current user's pinned chats. Use it to store the order the user set by dragging chats in your interface.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
dialogId (path) |
string | yes | ID of a pinned dialog: a numeric user ID for a direct dialog, chatXXX for a group chat, me for the current user's own dialog. Pinned chats are the rows with pinned: true in recent dialogs |
Query parameters are not accepted: any of them is rejected with 400 INVALID_PARAMS.
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
position |
integer | yes | The chat's position among the pinned chats, starting at 1. A JSON integer; the string "3" is not accepted. The maximum position is 45, the number of pinned chats Bitrix24 allows |
Other body fields are rejected with 400 INVALID_PARAMS.
Examples
curl — personal key
curl -X PUT https://vibecode.bitrix24.com/v1/chats/chat456/pin \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"position": 1}'
curl — OAuth application
curl -X PUT https://vibecode.bitrix24.com/v1/chats/chat456/pin \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"position": 1}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat456/pin', {
method: 'PUT',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ position: 1 }),
})
const { success, data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat456/pin', {
method: 'PUT',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({ position: 1 }),
})
const { success, data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data.result |
boolean | true — the order is saved |
Response example
{
"success": true,
"data": {
"result": true
}
}
Error response example
422 — the position is greater than 45:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "INVALID_PIN_POSITION",
"b24Code": "INVALID_PIN_POSITION"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS |
No position, no request body, position is not a JSON integer or is less than 1, an extra body field or a query parameter. Checked before the Bitrix24 call |
| 422 | BITRIX_ERROR |
Bitrix24 returned an error; the Bitrix24 code is in error.b24Code. INVALID_PIN_POSITION — position is greater than 45. CHAT_NOT_FOUND — there is no chat with this dialogId |
| 404 | ENTITY_NOT_FOUND |
Bitrix24 answered "not found"; the Bitrix24 code is in error.b24Code |
| 502 | ME_ALIAS_RESOLUTION_FAILED |
The user could not be resolved for the me alias |
| 403 | BITRIX_ACCESS_DENIED |
The user has no access to the chat |
| 403 | SCOPE_DENIED |
The API key does not have the im scope |
| 403 | WRITE_BLOCKED_READONLY_KEY |
Read-only key: changing the pin order is a write, see access rights |
| 401 | TOKEN_MISSING |
The API key has no Bitrix24 tokens configured |
| 502 | BITRIX_UNAVAILABLE |
Bitrix24 is unavailable or returned a server error |
Full list of common API errors — Errors.
Known specifics
The order is stored, but the dialog list does not show it yet. After the call, recent dialogs still return pinned chats in the previous order — by last activity time. The stored position takes effect once the list starts honouring it; until then, keep the order of pinned chats in your interface on your side.
An unpinned chat and a position beyond the pinned ones. For a chat that is not pinned, and for a position greater than the number of pinned chats but not greater than 45, the response is true and the order does not change. Check pinned in recent dialogs before the call.
The call may make you a member. When the chat allows auto-join — for example, a comment chat, a collab or a task chat — the call adds the current user as a member, just as opening the chat in the Bitrix24 interface does.