[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Ffiles\u002Fupload-to-folder":3,"docs-tabs-chats\u002Ffiles\u002Fupload-to-folder":6},{"content":4,"lastmod":5},"## Upload a file to a chat folder\n\n`POST \u002Fv1\u002Fchats\u002F:chatId\u002Ffiles\u002Fuploads`\n\n> **This method is rolling out in `im 26.1500.0`.** It is not available on every Bitrix24 account yet. Until the method arrives, the API returns `422 METHOD_NOT_YET_AVAILABLE` with `error.release`.\n\nUploads one file into the chat folder without posting a message. To publish it, call the [publish route](\u002Fdocs\u002Fchats\u002Ffiles\u002Fupload-publish) with `data.file.id` in `uploadIds`.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|-----------|------|:--------:|-------------|\n| `chatId` (path) | number | yes | Chat ID. Get it from: [`POST \u002Fv1\u002Fchats`](\u002Fdocs\u002Fchats\u002Fmanagement\u002Fcreate) or the `chatId` field of a [`GET \u002Fv1\u002Fchats\u002Frecent`](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) row |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|-------|------|:--------:|-------------|\n| `filename` | string | yes | File name with extension |\n| `content` | string | yes | Base64 content, up to 4 MiB after decoding |\n\nOther fields and query parameters are rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F42\u002Ffiles\u002Fuploads \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"filename\":\"a.txt\",\"content\":\"YWJj\"}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F42\u002Ffiles\u002Fuploads \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"filename\":\"a.txt\",\"content\":\"YWJj\"}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F42\u002Ffiles\u002Fuploads', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\"filename\": \"a.txt\", \"content\": \"YWJj\"}),\n})\nconst { success, data, error } = await res.json()\nconsole.log(success ? data : error)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F42\u002Ffiles\u002Fuploads', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\"filename\": \"a.txt\", \"content\": \"YWJj\"}),\n})\nconst { success, data, error } = await res.json()\nconsole.log(success ? data : error)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | `true` on success |\n| `data.file` | object | File in the chat folder. Token-bearing URLs are set to `null` |\n| `data.file.id` | number | Uploaded file ID. Pass it in `uploadIds` when publishing |\n| `data.file.name` | string | File name |\n| `data.file.size` | number | File size in bytes |\n| `data.chatId` | number | Chat ID |\n| `data.dialogId` | string | Dialog ID. No `messageId` |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"file\": {\n      \"id\": 7701,\n      \"name\": \"a.txt\",\n      \"size\": 3\n    },\n    \"chatId\": 42,\n    \"dialogId\": \"chat42\"\n  }\n}\n```\n\n## Error response example\n\n400 — the content exceeds 4 MiB:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"`content` exceeds the 4 MiB file limit.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | Invalid body or unexpected parameters |\n| 400 | `INVALID_CHAT_ID` | `chatId` in the path is not a positive integer |\n| 401 | `TOKEN_MISSING` | No Bitrix24 access tokens |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only |\n| 403 | `BITRIX_ACCESS_DENIED` | No access to the chat in Bitrix24 |\n| 413 | `PAYLOAD_TOO_LARGE` | JSON body exceeds 40 MiB. Reduce the request |\n| 422 | `METHOD_NOT_YET_AVAILABLE` | The method is not available on the Bitrix24 account yet — see the notice at the top of the page |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused the file |\n| 429 | `LARGE_BODY_BACKEND_BUSY` | Too many large bodies are being accepted right now. Retry according to `Retry-After` |\n| 429 | `QUEUE_TIMEOUT` | The Bitrix24 queue is overloaded. Retry according to `Retry-After` |\n\nFor the generic `422 BITRIX_ERROR`, the `error.b24Code` field is present only when the code is recognized. The platform does not retry an upload after an unknown outcome.\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## See also\n\n- [Check existence](\u002Fdocs\u002Fchats\u002Ffiles\u002Fupload-status)\n- [Discard file](\u002Fdocs\u002Fchats\u002Ffiles\u002Fupload-discard)\n- [Publish files](\u002Fdocs\u002Fchats\u002Ffiles\u002Fupload-publish)\n- [Chat files](\u002Fdocs\u002Fchats\u002Ffiles)\n","2026-10-07",{},1795000505114]