لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/entities/files/restore.md فهرس التوثيق — /llms.txt

مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.

Restore file

POST /v1/files/:id/restore

Returns 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.

Parameters

Parameter Type Required Description
Parameterid (path) Typenumber Requiredyes DescriptionFile ID. List: GET /v1/files?folderId=X. Trashed files do not appear in the list — save the id before deleting

No request body is sent.

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/files/10745/restore" \
  -H "X-Api-Key: YOUR_API_KEY"

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/files/10745/restore" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/files/10745/restore', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})
const body = await res.json()
if (!body.success) throw new Error(body.error.code)
console.log('Restored by this call:', body.meta.restored, 'name:', body.data.name)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/files/10745/restore', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})
const body = await res.json()
if (!body.success) throw new Error(body.error.code)
console.log('Restored by this call:', body.meta.restored, 'name:', body.data.name)

Response fields

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue on success
Fielddata Typeobject DescriptionThe file after the call. All fields — see File fields
Fielddata.name Typestring DescriptionCurrent 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
Fielddata.deletedType Typenumber DescriptionDeletion status: 0 — the file is not in the trash
Fielddata.deletedAt Typestring | null DescriptionTime of the last deletion (ISO 8601). Restoring does not clear the field
Fielddata.deletedBy Typenumber | null DescriptionID of the user who deleted the file. Restoring does not clear the field. List: GET /v1/users
Fieldmeta.restored Typeboolean Descriptiontrue — the file was restored by this call. false — the file was not in the trash, and the call changed nothing
Fieldmeta.renamedFrom Typestring | null DescriptionFile name before restoring, if it changed because of a name collision. null — the name is unchanged

Response example

JSON
{
  "success": true,
  "data": {
    "id": 10745,
    "name": "report.txt",
    "code": null,
    "storageId": 1379,
    "type": "file",
    "folderId": 10739,
    "deletedType": 0,
    "globalContentVersion": 1,
    "fileId": 39249,
    "size": 33,
    "createdAt": "2026-10-15T18:25:17.000Z",
    "updatedAt": "2026-10-15T18:27:26.000Z",
    "deletedAt": "2026-10-15T18:26:24.000Z",
    "createdBy": 1295,
    "updatedBy": 1295,
    "deletedBy": 1295,
    "downloadUrl": "https://vibecode.bitrix24.com/v1/files/10745/download",
    "detailUrl": "https://<portal>.bitrix24.com/company/personal/user/1295/disk/file/Documents/report.txt"
  },
  "meta": {
    "restored": true,
    "renamedFrom": null
  }
}

Error response example

404 — the file does not exist, including after permanent deletion:

JSON
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Could not find entity with id '10751'."
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_ID Descriptionid is not a positive integer
HTTP401 CodeTOKEN_MISSING DescriptionThe key's portal has no authorization tokens
HTTP403 CodeSCOPE_DENIED DescriptionThe key lacks the disk scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is in read-only mode, and restoring changes portal data
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe key owner has no permissions on the file in Bitrix24
HTTP404 CodeENTITY_NOT_FOUND DescriptionNo file with this id, including after permanent deletion
HTTP422 CodeDISK_RESTORE_REFUSED DescriptionBitrix24 did not confirm the restore. Re-read the file via GET /v1/files/:id
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 refused to restore the file; the reason is in message
HTTP429 CodeRATE_LIMITED DescriptionRate limit exceeded — wait 1-2 seconds and retry
HTTP502 CodeDISK_OUTCOME_UNKNOWN DescriptionThe 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
HTTP502 CodeBITRIX_UNAVAILABLE DescriptionBitrix24 was unavailable while the file was being read; the restore was not sent

Full list of common API errors — Errors.

Known specifics

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.

Public link. While the file is in the trash, its public link does not open the file. After the file is restored, the previous link works again.

Batch calls. Restoring is not part of POST /v1/batch — call it as a separate request.

See also