[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Ffiles\u002Fversion-download":3,"docs-tabs-entities\u002Ffiles\u002Fversion-download":6},{"content":4,"lastmod":5},"## Download a file version\n\n`GET \u002Fv1\u002Ffiles\u002F:id\u002Fversions\u002F:versionId\u002Fdownload`\n\nDownloads 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.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|----------|\n| `id` (path) | number | yes | File ID. Get it: `GET \u002Fv1\u002Ffiles?folderId=X` |\n| `versionId` (path) | number | yes | ID of a version of this file. List: [`GET \u002Fv1\u002Ffiles\u002F:id\u002Fversions`](.\u002Fversions.md) |\n\nThe request has no body.\n\n## Examples\n\n### curl — personal key\n\n```bash\n# Save under the name from the Content-Disposition header\ncurl -OJ -H \"X-Api-Key: YOUR_API_KEY\" \\\n  https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F205\u002Fversions\u002F410\u002Fdownload\n\n# Set the file name explicitly\ncurl -H \"X-Api-Key: YOUR_API_KEY\" \\\n  https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F205\u002Fversions\u002F410\u002Fdownload \\\n  -o report-v3.txt\n```\n\n### curl — OAuth application\n\n```bash\ncurl -OJ \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F205\u002Fversions\u002F410\u002Fdownload\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F205\u002Fversions\u002F410\u002Fdownload', {\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\n\nif (!res.ok) {\n  const body = await res.json()\n  throw new Error(body.error?.code ?? String(res.status))\n}\n\nconst fileName = decodeURIComponent(\n  res.headers.get('Content-Disposition')?.match(\u002Ffilename=\"(.+?)\"\u002F)?.[1] ?? 'file'\n)\nconst bytes = new Uint8Array(await res.arrayBuffer())\nconsole.log(fileName, bytes.length, 'bytes')\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F205\u002Fversions\u002F410\u002Fdownload', {\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\n\nif (!res.ok) {\n  const body = await res.json()\n  throw new Error(body.error?.code ?? String(res.status))\n}\n\nconst bytes = new Uint8Array(await res.arrayBuffer())\n```\n\n## Response fields\n\nOn success, the HTTP status is `200 OK` and the response body is the bytes of the version content. File details come in the headers.\n\n| Header | Example value | Description |\n|-----------|-----------------|----------|\n| `Content-Type` | `text\u002Fplain; charset=UTF-8` | Content type that Bitrix24 returned for the file |\n| `Content-Disposition` | `attachment; filename=\"report.txt\"` | File name in this version. Non-Latin characters and spaces in the name arrive percent-encoded — decode the name with the `decodeURIComponent` function |\n| `Content-Length` | `10` | Size of the version content in bytes |\n\n## Response example\n\n```http\nHTTP\u002F1.1 200 OK\nContent-Type: text\u002Fplain; charset=UTF-8\nContent-Disposition: attachment; filename=\"report.txt\"\nContent-Length: 10\n\n\u003Cversion content, 10 bytes>\n```\n\n## Error response example\n\n404 — this file has no such version:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"ENTITY_NOT_FOUND\",\n    \"message\": \"File version not found.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|----------|\n| 404 | `ENTITY_NOT_FOUND` | The version with this `versionId` does not exist, was removed from the history, or belongs to a different file |\n| 404 | `DOWNLOAD_URL_NOT_FOUND` | The version has no download address |\n| 400 | `INVALID_ID` | `id` or `versionId` is not a positive integer |\n| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |\n| 401 | `TOKEN_MISSING` | Bitrix24 access tokens are unavailable |\n| 403 | `SCOPE_DENIED` | The key lacks the `disk` scope |\n| 502 | `DOWNLOAD_FAILED` | Bitrix24 returned an error during the download |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **The `disk` scope is required.** Unlike [`GET \u002Fv1\u002Ffiles\u002F:id\u002Fdownload`](.\u002Fdownload.md), downloading a version does not accept a key that holds only the `crm` scope.\n- **A version's `downloadUrl` is a path without the domain.** In the responses of [`GET \u002Fv1\u002Ffiles\u002F:id\u002Fversions`](.\u002Fversions.md) and [`GET \u002Fv1\u002Ffiles\u002F:id\u002Fversions\u002F:versionId`](.\u002Fversion.md) it looks like `\u002Fv1\u002Ffiles\u002F205\u002Fversions\u002F410\u002Fdownload`: prepend `https:\u002F\u002Fvibecode.bitrix24.com` to it before sending the request. The address is permanent and contains no authorization token.\n\n## See also\n\n- [File version history](\u002Fdocs\u002Fentities\u002Ffiles\u002Fversions)\n- [Read a file version](\u002Fdocs\u002Fentities\u002Ffiles\u002Fversion)\n- [Download file](\u002Fdocs\u002Fentities\u002Ffiles\u002Fdownload)\n- [Files](\u002Fdocs\u002Fentities\u002Ffiles)\n","2026-10-15",{},1795415250068]