[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmessages\u002Fpins-create":3,"docs-tabs-chats\u002Fmessages\u002Fpins-create":6},{"content":4,"lastmod":5},"## Pin a message\n\n`POST \u002Fv1\u002Fchats\u002Fmessages\u002F:messageId\u002Fpin`\n\nPins 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.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `messageId` (path) | number | yes | Message ID, a positive integer — from the [chat feed](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist) (`GET \u002Fv1\u002Fchats\u002F:dialogId\u002Fmessages`) or from the [send](\u002Fdocs\u002Fchats\u002Fmessages\u002Fsend) response |\n\nNo body and no query parameters are accepted: any body field or query parameter is rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F1001\u002Fpin\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F1001\u002Fpin\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\"\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F1001\u002Fpin', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\n\nconst { success } = await res.json()\nconsole.log('Pinned:', success)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fmessages\u002F1001\u002Fpin', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\n\nconst { success } = await res.json()\nconsole.log('Pinned:', success)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data` | array | An empty array |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": []\n}\n```\n\n## Error response example\n\n422 — the message is already pinned:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"MESSAGE_IS_ALREADY_PIN\",\n    \"b24Code\": \"MESSAGE_IS_ALREADY_PIN\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `messageId` is not a positive integer, or a body field or query parameter was passed. Checked before any call to Bitrix24 |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 reported \"not found\"; the portal code is in `error.b24Code` |\n| 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 |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | A read-only key cannot pin messages — see [access rights](\u002Fdocs\u002Faccess-rights) |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**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.\n\n## See also\n\n- [List pinned messages](\u002Fdocs\u002Fchats\u002Fmessages\u002Fpins)\n- [Unpin a message](\u002Fdocs\u002Fchats\u002Fmessages\u002Fpins-delete)\n- [Number of pinned messages](\u002Fdocs\u002Fchats\u002Fmessages\u002Fpins-count)\n- [Messages](\u002Fdocs\u002Fchats\u002Fmessages)\n","2026-10-06",{},1795415438478]