[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Ffiles\u002Fsave":3,"docs-tabs-chats\u002Ffiles\u002Fsave":6},{"content":4,"lastmod":5},"\n## Save files to Drive\n\n`POST \u002Fv1\u002Fchats\u002Ffiles\u002Fsave`\n\nCopies chat files to the current user's personal Drive — into the folder for files saved from chats. The file stays in the chat: Drive gets a copy.\n\n## Parameters\n\nThere are no path or query parameters. Any query parameter is rejected with `400 INVALID_PARAMS`.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `fileIds` | number[] | yes | 1 to 100 chat file IDs. Get them: `files[].id` in [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload) or in the [message history in the v2 mode](\u002Fdocs\u002Fchats\u002Fmessages\u002Flist), `data.file.id` after an [upload in the v2 mode](\u002Fdocs\u002Fchats\u002Ffiles\u002Fupload) |\n\nOther body fields are 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\u002Ffiles\u002Fsave \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"fileIds\": [7701, 7702]}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffiles\u002Fsave \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"fileIds\": [7701, 7702]}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffiles\u002Fsave', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ fileIds: [7701, 7702] }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Saved:', data.result)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffiles\u002Fsave', {\n  method: 'POST',\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({ fileIds: [7701, 7702] }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Saved:', data.result)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.result` | boolean | `true` — the copies were created |\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\n400 — an element of `fileIds` is not a positive integer:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"`fileIds[1]` must be a positive integer.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `fileIds` is missing, is not an array, is empty or holds more than 100 elements, an element is not a positive integer (the message names its index), or another body field or a query parameter was sent. Checked before any call to Bitrix24 |\n| 422 | `BITRIX_ERROR` | Bitrix24 returned an error. The Bitrix24 code is in `error.b24Code`. For example, `FILE_ACCESS_ERROR` — the user has no access to one of the files |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — the call changes the user's Drive |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nThe full list of general API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**`result: true` does not guarantee that every file was copied.** The ID of a file that does not exist is skipped silently, and the response stays successful. The endpoint rejects a malformed ID itself, before calling Bitrix24 — otherwise such an ID would also be skipped silently. Check the result in the folder of saved files on Drive.\n\n**No access means the whole call is refused.** If even one file is not available to the user, the entire call is rejected with `FILE_ACCESS_ERROR`, and nothing is copied.\n\n## See also\n\n- [Chat files](\u002Fdocs\u002Fchats\u002Ffiles)\n- [Upload a file to a chat](\u002Fdocs\u002Fchats\u002Ffiles\u002Fupload)\n- [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload)\n","2026-10-07",{},1794739537421]