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. 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
FieldfileIds Typenumber[] Requiredyes Description1 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

Terminal
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

Terminal
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

javascript
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

javascript
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
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata.result Typeboolean Descriptiontrue — the copies were created

Response example

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

Error response example

400 — an element of fileIds is not a positive integer:

JSON
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "`fileIds[1]` must be a positive integer."
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptionfileIds 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
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 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
HTTP403 CodeSCOPE_DENIED DescriptionThe API key does not have the im scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is read-only — the call changes the user's Drive
HTTP401 CodeTOKEN_MISSING DescriptionThe 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. 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.

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.

See also