لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/entities/files/version-download.md فهرس التوثيق — /llms.txt

مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.

Download a file version

GET /v1/files/:id/versions/:versionId/download

Downloads the content of the selected file version through the Vibecode API. The platform adds the Bitrix24 authorization itself, so you do not need to pass a Bitrix24 account token.

Parameters

Parameter Type Required Description
Parameterid (path) Typenumber Requiredyes DescriptionFile ID. Get it: GET /v1/files?folderId=X
ParameterversionId (path) Typenumber Requiredyes DescriptionID of a version of this file. List: GET /v1/files/:id/versions

The request has no body.

Examples

curl — personal key

Terminal
# Save under the name from the Content-Disposition header
curl -OJ -H "X-Api-Key: YOUR_API_KEY" \
  https://vibecode.bitrix24.com/v1/files/205/versions/410/download

# Set the file name explicitly
curl -H "X-Api-Key: YOUR_API_KEY" \
  https://vibecode.bitrix24.com/v1/files/205/versions/410/download \
  -o report-v3.txt

curl — OAuth application

Terminal
curl -OJ \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  https://vibecode.bitrix24.com/v1/files/205/versions/410/download

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/files/205/versions/410/download', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

if (!res.ok) {
  const body = await res.json()
  throw new Error(body.error?.code ?? String(res.status))
}

const fileName = decodeURIComponent(
  res.headers.get('Content-Disposition')?.match(/filename="(.+?)"/)?.[1] ?? 'file'
)
const bytes = new Uint8Array(await res.arrayBuffer())
console.log(fileName, bytes.length, 'bytes')

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/files/205/versions/410/download', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

if (!res.ok) {
  const body = await res.json()
  throw new Error(body.error?.code ?? String(res.status))
}

const bytes = new Uint8Array(await res.arrayBuffer())

Response fields

On success, the HTTP status is 200 OK and the response body is the bytes of the version content. File details come in the headers.

Header Example value Description
HeaderContent-Type Example valuetext/plain; charset=UTF-8 DescriptionContent type that Bitrix24 returned for the file
HeaderContent-Disposition Example valueattachment; filename="report.txt" DescriptionFile name in this version. Non-Latin characters and spaces in the name arrive percent-encoded — decode the name with the decodeURIComponent function
HeaderContent-Length Example value10 DescriptionSize of the version content in bytes

Response example

http
HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8
Content-Disposition: attachment; filename="report.txt"
Content-Length: 10

<version content, 10 bytes>

Error response example

404 — this file has no such version:

JSON
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "File version not found."
  }
}

Errors

HTTP Code Description
HTTP404 CodeENTITY_NOT_FOUND DescriptionThe version with this versionId does not exist, was removed from the history, or belongs to a different file
HTTP404 CodeDOWNLOAD_URL_NOT_FOUND DescriptionThe version has no download address
HTTP400 CodeINVALID_ID Descriptionid or versionId is not a positive integer
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header is missing
HTTP401 CodeTOKEN_MISSING DescriptionBitrix24 access tokens are unavailable
HTTP403 CodeSCOPE_DENIED DescriptionThe key lacks the disk scope
HTTP502 CodeDOWNLOAD_FAILED DescriptionBitrix24 returned an error during the download

Full list of common API errors — Errors.

Known specifics

  • The disk scope is required. Unlike GET /v1/files/:id/download, downloading a version does not accept a key that holds only the crm scope.
  • A version's downloadUrl is a path without the domain. In the responses of GET /v1/files/:id/versions and GET /v1/files/:id/versions/:versionId it looks like /v1/files/205/versions/410/download: prepend https://vibecode.bitrix24.com to it before sending the request. The address is permanent and contains no authorization token.

See also