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
ParameterdialogId (path) Typestring Requiredyes DescriptionID 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
Fieldposition Typeinteger Requiredyes DescriptionThe 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

Terminal
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

Terminal
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

javascript
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

javascript
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
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata.result Typeboolean Descriptiontrue — the order is saved

Response example

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

Error response example

422 — the position is greater than 45:

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

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptionNo 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
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 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
HTTP404 CodeENTITY_NOT_FOUND DescriptionBitrix24 answered "not found"; the Bitrix24 code is in error.b24Code
HTTP502 CodeME_ALIAS_RESOLUTION_FAILED DescriptionThe user could not be resolved for the me alias
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe user has no access to the chat
HTTP403 CodeSCOPE_DENIED DescriptionThe API key does not have the im scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionRead-only key: changing the pin order is a write, see access rights
HTTP401 CodeTOKEN_MISSING DescriptionThe API key has no Bitrix24 tokens configured
HTTP502 CodeBITRIX_UNAVAILABLE DescriptionBitrix24 is unavailable or returned a server error

Full list of common API errors — Errors.

Known specifics

The dialog list does not reflect the stored order. After the call, recent dialogs return pinned chats by last activity time. Keep the order of pinned chats for 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.

See also