For AI agents: markdown of this page — /docs-content-en/chats/files/save.md documentation index — /llms.txt
Save files to Drive
POST /v1/chats/files/save
Copies chat files to the current user's personal Drive — into the folder for files saved from chats. Calls the v2 messenger method im.v2.Disk.File.save. The file stays in the chat: Drive gets a copy.
Parameters
There are no path or query parameters. Any query parameter is rejected with 400 INVALID_PARAMS.
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
fileIds |
number[] | yes | 1 to 100 chat file IDs. Get them: files[].id in Load a chat or in the message history in the v2 mode, data.file.id after an upload in the v2 mode |
Other body fields are rejected with 400 INVALID_PARAMS.
Examples
curl — personal key
curl -X POST https://vibecode.bitrix24.com/v1/chats/files/save \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"fileIds": [7701, 7702]}'
curl — OAuth application
curl -X POST https://vibecode.bitrix24.com/v1/chats/files/save \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"fileIds": [7701, 7702]}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/files/save', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ fileIds: [7701, 7702] }),
})
const { success, data } = await res.json()
console.log('Saved:', data.result)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/files/save', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({ fileIds: [7701, 7702] }),
})
const { success, data } = await res.json()
console.log('Saved:', data.result)
Response fields
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data.result |
boolean | true — the copies were created |
Response example
{
"success": true,
"data": {
"result": true
}
}
Error response example
400 — an element of fileIds is not a positive integer:
{
"success": false,
"error": {
"code": "INVALID_PARAMS",
"message": "`fileIds[1]` must be a positive integer."
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 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 |
| 422 | BITRIX_ERROR |
Bitrix24 returned an error; the portal code is in error.b24Code. For example, FILE_ACCESS_ERROR — the user has no access to one of the files |
| 403 | SCOPE_DENIED |
The API key does not have the im scope |
| 403 | WRITE_BLOCKED_READONLY_KEY |
The key is read-only — the call changes the user's Drive |
| 401 | TOKEN_MISSING |
The API key has no Bitrix24 tokens configured |
The full list of general API errors — Errors.
Known specifics
result: true does not guarantee that every file was copied. Bitrix24 silently skips the ID of a file that does not exist and still returns success. 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.
No access means the whole call is refused. If even one file is not available to the user, Bitrix24 rejects the entire call with FILE_ACCESS_ERROR, and nothing is copied.