[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Factivities\u002Ffile-download":3,"docs-tabs-entities\u002Factivities\u002Ffile-download":6},{"content":4,"lastmod":5},"## Download an activity file\n\n`GET \u002Fv1\u002Factivities\u002F:activityId\u002Ffiles\u002F:fileId\u002Fdownload`\n\nDownloads a file attached to a CRM activity, including a call recording. The response is a binary stream with a `Content-Disposition` header.\n\nThis endpoint exists because an activity file is **not a Drive file**. `GET \u002Fv1\u002Factivities\u002F:id` returns each file as `{ id, url }`, where the `id` lives in a separate identifier space that overlaps Drive object IDs. Passing such an `id` to [Drive file download](\u002Fdocs\u002Fentities\u002Ffiles\u002Fdownload) is not safe: it may return a different file. The address in the `url` field arrives with an empty authorization parameter, so requesting it returns the sign-in page with code `200` — not a file. This endpoint adds the authorization itself and returns the content.\n\n## Parameters\n\n| Parameter | In | Type | Required | Description |\n|----------|---|-----|:-----:|----------|\n| `activityId` | path | number | yes | Activity ID. Get it from [`GET \u002Fv1\u002Factivities`](\u002Fdocs\u002Fentities\u002Factivities\u002Flist) |\n| `fileId` | path | number | yes | File ID from the activity `files` array. Get it from [`GET \u002Fv1\u002Factivities\u002F:id`](\u002Fdocs\u002Fentities\u002Factivities\u002Fget) with `files` included in `select` |\n\nThe request body is empty.\n\n## Examples\n\n### curl — personal key\n\n```bash\n# Save under the original name from the Content-Disposition header\ncurl -OJ -H \"X-Api-Key: YOUR_API_KEY\" \\\n  https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Factivities\u002F4257\u002Ffiles\u002F5387\u002Fdownload\n\n# Set the file name explicitly\ncurl -H \"X-Api-Key: YOUR_API_KEY\" \\\n  https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Factivities\u002F4257\u002Ffiles\u002F5387\u002Fdownload \\\n  -o call-record.mp3\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\u002Factivities\u002F4257\u002Ffiles\u002F5387\u002Fdownload\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch(\n  'https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Factivities\u002F4257\u002Ffiles\u002F5387\u002Fdownload',\n  { headers: { 'X-Api-Key': 'YOUR_API_KEY' } },\n)\n\nif (!res.ok) {\n  const { error } = await res.json()\n  throw new Error(`${error.code}: ${error.message}`)\n}\n\nconst audio = await res.arrayBuffer()\nconsole.log('bytes received:', audio.byteLength)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch(\n  'https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Factivities\u002F4257\u002Ffiles\u002F5387\u002Fdownload',\n  {\n    headers: {\n      'X-Api-Key': 'YOUR_APP_KEY',\n      'Authorization': 'Bearer USER_SESSION_TOKEN',\n    },\n  },\n)\n\nconst audio = await res.arrayBuffer()\n```\n\n## Response headers\n\nOn success the binary file content is returned (HTTP 200). There is no `## Response fields` section — the response body is not JSON.\n\n| Header | Example value | Description |\n|-----------|-----------------|----------|\n| `Content-Type` | `audio\u002Fmpeg` | Content type exactly as Bitrix24 returned it |\n| `Content-Disposition` | `attachment; filename=\"call-record.mp3\"` | File name to save under |\n| `Content-Length` | `22509` | Size in bytes when Bitrix24 reported it |\n\n## Error response example\n\n404 — the file does not belong to this activity:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"NOT_FOUND\",\n    \"message\": \"File 999999 does not belong to activity 4257\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|----------|\n| 400 | `INVALID_PARAMS` | `activityId` or `fileId` is not a positive integer |\n| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens configured |\n| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |\n| 404 | `NOT_FOUND` | The activity does not exist, the file does not belong to it, or the file has no download address |\n| 502 | `DOWNLOAD_FAILED` | Bitrix24 named an address outside the account domain (no request is sent to such an address), or did not return the file. This includes Bitrix24 answering with a page instead of the content, which means the key could not be authorized for that file |\n\nThe full list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **The file must belong to the named activity.** Otherwise `404`, even when the file exists. The check is not pedantry: Bitrix24 answers a request for another activity's file with `200` and a sign-in page, so without it you would receive HTML posing as the file.\n- **Permissions are not bypassed.** Reading the activity is itself the access check: if the key has no access to the activity, the request is refused. Bitrix24 additionally verifies the user's access to the activity on its side.\n- **The address is never returned.** The download address contains an authorization code, so the endpoint returns bytes only.\n- **Files are not always present in the activity response.** In the [activity list](\u002Fdocs\u002Fentities\u002Factivities\u002Flist) the `files` field is returned only when named in `select`. For a [single activity](\u002Fdocs\u002Fentities\u002Factivities\u002Fget) it arrives with no extra conditions.\n\n## See also\n\n- [Get an activity](\u002Fdocs\u002Fentities\u002Factivities\u002Fget)\n- [Download a timeline comment attachment](\u002Fdocs\u002Fentities\u002Ftimelines\u002Ffile-download)\n- [Download a Drive file](\u002Fdocs\u002Fentities\u002Ffiles\u002Fdownload)\n- [Activities](\u002Fdocs\u002Fentities\u002Factivities)\n","2026-09-23",{},1794739305014]