[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Ffiles\u002Frestore":3,"docs-tabs-entities\u002Ffiles\u002Frestore":6},{"content":4,"lastmod":5},"## Restore file\n\n`POST \u002Fv1\u002Ffiles\u002F:id\u002Frestore`\n\nReturns a file from the Bitrix24 trash to its folder. If the folder is in the trash too, restores it as well, together with all folders above it.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|----------|\n| `id` (path) | number | yes | File ID. List: `GET \u002Fv1\u002Ffiles?folderId=X`. Trashed files do not appear in the list — save the `id` before deleting |\n\nNo request body is sent.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F10745\u002Frestore\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F10745\u002Frestore\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\"\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F10745\u002Frestore', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\nconst body = await res.json()\nif (!body.success) throw new Error(body.error.code)\nconsole.log('Restored by this call:', body.meta.restored, 'name:', body.data.name)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F10745\u002Frestore', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\nconst body = await res.json()\nif (!body.success) throw new Error(body.error.code)\nconsole.log('Restored by this call:', body.meta.restored, 'name:', body.data.name)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|----------|\n| `success` | boolean | `true` on success |\n| `data` | object | The file after the call. All fields — see [File fields](\u002Fdocs\u002Fentities\u002Ffiles\u002Ffields) |\n| `data.name` | string | Current file name. If the folder already has a file with the same name, a number is appended to the name: `report.txt` becomes `report (1).txt` |\n| `data.deletedType` | number | Deletion status: `0` — the file is not in the trash |\n| `data.deletedAt` | string \\| null | Time of the last deletion (ISO 8601). Restoring does not clear the field |\n| `data.deletedBy` | number \\| null | ID of the user who deleted the file. Restoring does not clear the field. List: `GET \u002Fv1\u002Fusers` |\n| `meta.restored` | boolean | `true` — the file was restored by this call. `false` — the file was not in the trash, and the call changed nothing |\n| `meta.renamedFrom` | string \\| null | File name before restoring, if it changed because of a name collision. `null` — the name is unchanged |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"id\": 10745,\n    \"name\": \"report.txt\",\n    \"code\": null,\n    \"storageId\": 1379,\n    \"type\": \"file\",\n    \"folderId\": 10739,\n    \"deletedType\": 0,\n    \"globalContentVersion\": 1,\n    \"fileId\": 39249,\n    \"size\": 33,\n    \"createdAt\": \"2026-10-15T18:25:17.000Z\",\n    \"updatedAt\": \"2026-10-15T18:27:26.000Z\",\n    \"deletedAt\": \"2026-10-15T18:26:24.000Z\",\n    \"createdBy\": 1295,\n    \"updatedBy\": 1295,\n    \"deletedBy\": 1295,\n    \"downloadUrl\": \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F10745\u002Fdownload\",\n    \"detailUrl\": \"https:\u002F\u002F\u003Cportal>.bitrix24.com\u002Fcompany\u002Fpersonal\u002Fuser\u002F1295\u002Fdisk\u002Ffile\u002FDocuments\u002Freport.txt\"\n  },\n  \"meta\": {\n    \"restored\": true,\n    \"renamedFrom\": null\n  }\n}\n```\n\n## Error response example\n\n404 — the file does not exist, including after permanent deletion:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"ENTITY_NOT_FOUND\",\n    \"message\": \"Could not find entity with id '10751'.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|----------|\n| 400 | `INVALID_ID` | `id` is not a positive integer |\n| 401 | `TOKEN_MISSING` | The key's portal has no authorization tokens |\n| 403 | `SCOPE_DENIED` | The key lacks the `disk` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode, and restoring changes portal data |\n| 403 | `BITRIX_ACCESS_DENIED` | The key owner has no permissions on the file in Bitrix24 |\n| 404 | `ENTITY_NOT_FOUND` | No file with this `id`, including after [permanent deletion](\u002Fdocs\u002Fentities\u002Ffiles\u002Fpurge) |\n| 422 | `DISK_RESTORE_REFUSED` | Bitrix24 did not confirm the restore. Re-read the file via [`GET \u002Fv1\u002Ffiles\u002F:id`](\u002Fdocs\u002Fentities\u002Ffiles\u002Fget) |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused to restore the file; the reason is in `message` |\n| 429 | `RATE_LIMITED` | Rate limit exceeded — wait 1-2 seconds and retry |\n| 502 | `DISK_OUTCOME_UNKNOWN` | The connection to Bitrix24 dropped after the restore was sent. The outcome is unknown and the request was not retried — re-read the file before calling the method again |\n| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 was unavailable while the file was being read; the restore was not sent |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**Neighboring objects stay in the trash.** Only the folders above the file come back from the trash together with it. Other files and folders in those folders stay in the trash — restore them with separate calls.\n\n**Public link.** While the file is in the trash, its [public link](\u002Fdocs\u002Fentities\u002Ffiles\u002Fpublic-link) does not open the file. After the file is restored, the previous link works again.\n\n**Batch calls.** Restoring is not part of [`POST \u002Fv1\u002Fbatch`](\u002Fdocs\u002Fbatch) — call it as a separate request.\n\n## See also\n\n- [Delete file](\u002Fdocs\u002Fentities\u002Ffiles\u002Fdelete)\n- [Permanently delete file](\u002Fdocs\u002Fentities\u002Ffiles\u002Fpurge)\n- [Get file](\u002Fdocs\u002Fentities\u002Ffiles\u002Fget)\n- [Public link to a file](\u002Fdocs\u002Fentities\u002Ffiles\u002Fpublic-link)\n- [Files](\u002Fdocs\u002Fentities\u002Ffiles)\n","2026-10-15",{},1795415249178]