[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Ffiles\u002Fupload-discard":3,"docs-tabs-chats\u002Ffiles\u002Fupload-discard":6},{"content":4,"lastmod":5},"## Discard an uploaded file\n\n`POST \u002Fv1\u002Fchats\u002F:chatId\u002Ffiles\u002Fuploads\u002Fdiscard`\n\nAsks Bitrix24 to delete a file from the chat folder. The `true` or `false` result is returned as is: the client decides whether it can treat the file as removed.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|-----------|------|:--------:|-------------|\n| `chatId` (path) | number | yes | Chat ID |\n| `fileId` (body) | number | yes | Positive file ID |\n\nRequires the `im` scope and a write-enabled key. Other 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\u002Fdiscard \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"fileId\":7701}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F42\u002Ffiles\u002Fuploads\u002Fdiscard \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"fileId\":7701}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F42\u002Ffiles\u002Fuploads\u002Fdiscard', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\"fileId\": 7701}),\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\u002Fdiscard', {\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({\"fileId\": 7701}),\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` | boolean | The Bitrix24 `true` or `false` value, unchanged |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": true\n}\n```\n\n## Error response example\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"`fileId` must be a positive integer.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `fileId` is not a positive integer, or another body field or a query parameter was sent |\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 or file in Bitrix24 |\n| 404 | `ENTITY_NOT_FOUND` | File or chat not found |\n| 422 | `BITRIX_ERROR` | Other Bitrix24 refusal |\n| 429 | `QUEUE_TIMEOUT` | Bitrix24 request queue is busy |\n\n`false` is still a successful response, distinct from a refusal. A named Bitrix24 refusal can map to `400`, `403`, or `404`; `error.b24Code` is not guaranteed. The platform does not retry after an unknown outcome.\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## See also\n\n- [Upload to folder](\u002Fdocs\u002Fchats\u002Ffiles\u002Fupload-to-folder)\n- [Check existence](\u002Fdocs\u002Fchats\u002Ffiles\u002Fupload-status)\n- [Publish files](\u002Fdocs\u002Fchats\u002Ffiles\u002Fupload-publish)\n- [Chat files](\u002Fdocs\u002Fchats\u002Ffiles)\n","2026-10-05",{},1795000504714]