[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmanagement\u002Fpin-sort":3,"docs-tabs-chats\u002Fmanagement\u002Fpin-sort":6},{"content":4,"lastmod":5},"## Pinned chat order\n\n`PUT \u002Fv1\u002Fchats\u002F:dialogId\u002Fpin`\n\nMoves 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.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `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](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) |\n\nQuery parameters are not accepted: any of them is rejected with `400 INVALID_PARAMS`.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `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 |\n\nOther body fields are rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PUT https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat456\u002Fpin \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"position\": 1}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat456\u002Fpin \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"position\": 1}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat456\u002Fpin', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ position: 1 }),\n})\n\nconst { success, data } = await res.json()\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat456\u002Fpin', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ position: 1 }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.result` | boolean | `true` — the order is saved |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"result\": true\n  }\n}\n```\n\n## Error response example\n\n422 — the position is greater than 45:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"INVALID_PIN_POSITION\",\n    \"b24Code\": \"INVALID_PIN_POSITION\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 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 |\n| 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` |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 answered \"not found\"; the Bitrix24 code is in `error.b24Code` |\n| 502 | `ME_ALIAS_RESOLUTION_FAILED` | The user could not be resolved for the `me` alias |\n| 403 | `BITRIX_ACCESS_DENIED` | The user has no access to the chat |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | Read-only key: changing the pin order is a write, see [access rights](\u002Fdocs\u002Faccess-rights) |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**The dialog list does not reflect the stored order.** After the call, [recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) return pinned chats by last activity time. Keep the order of pinned chats for your interface on your side.\n\n**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](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) before the call.\n\n**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.\n\n## See also\n\n- [Pin a chat](\u002Fdocs\u002Fchats\u002Fmanagement\u002Fpin)\n- [Unpin a chat](\u002Fdocs\u002Fchats\u002Fmanagement\u002Funpin)\n- [Recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent)\n- [Chat management](\u002Fdocs\u002Fchats\u002Fmanagement)\n","2026-10-15",{},1794739542409]