لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/entities/pages/blocks/restore.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Restore a block
POST /v1/pages/:pageId/blocks/:blockId/restore
Returns a block from the page trash to the page draft. You can restore a block that was moved to the trash by the block delete call.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ParameterpageId (path) |
Typenumber | Requiredyes | DescriptionPage ID. List: GET /v1/pages |
ParameterblockId (path) |
Typenumber | Requiredyes | DescriptionID of the block in the page trash. List: GET /v1/pages/:pageId/blocks?deleted=true. A ready-made call with this ID comes in the restoreWith field of the block delete response |
Parameterscope (query) |
Typestring | Requiredno | DescriptionSite type: KNOWLEDGE — knowledge base, GROUP — workgroup site, MAINPAGE — main page. Omit the parameter for pages of other sites |
No request body is needed.
Examples
curl — personal key
curl -X POST "https://vibecode.bitrix24.com/v1/pages/20/blocks/30/restore" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl -X POST "https://vibecode.bitrix24.com/v1/pages/20/blocks/30/restore" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN"
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/pages/20/blocks/30/restore', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
},
})
const body = await res.json()
if (body.success) {
console.log('Block is back in the draft, publish with:', body.data.publishWith)
}
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/pages/20/blocks/30/restore', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
const body = await res.json()
if (body.success) {
console.log('Block is back in the draft, publish with:', body.data.publishWith)
}
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | Descriptiontrue — the block was returned from the trash |
Fielddata.id |
Typenumber | DescriptionID of the restored block |
Fielddata.deleted |
Typeboolean | DescriptionAlways false: the block is back in the page draft |
Fielddata.version |
Typestring | DescriptionPage version the call changed. Always draft — the draft |
Fielddata.published |
Typeboolean | DescriptionAlways false: the published version of the page did not change |
Fielddata.publishWith |
Typestring | DescriptionCall that publishes the page draft, with the page ID filled in |
Response example
{
"success": true,
"data": {
"id": 30,
"deleted": false,
"version": "draft",
"published": false,
"publishWith": "POST /v1/pages/20/publication"
}
}
Error response example
404 — the block is not in the page trash, for example because it has already been restored:
{
"success": false,
"error": {
"code": "BLOCK_NOT_IN_DRAFT",
"message": "No such block in this page's trash. List it with GET /v1/pages/{pageId}/blocks?deleted=true."
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PAGE_ID |
DescriptionpageId is not a positive integer |
| HTTP400 | CodeINVALID_BLOCK_ID |
DescriptionblockId is not a positive integer |
| HTTP400 | CodeINVALID_SCOPE |
Descriptionscope is not one of KNOWLEDGE, GROUP, MAINPAGE |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionBitrix24 rejected the request: a required parameter is missing |
| HTTP404 | CodeBLOCK_NOT_IN_DRAFT |
DescriptionNo block with this ID in the page trash: the block is already restored, was never deleted, or does not exist. The error text differs from the delete response and refers to the trash |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionThe page does not exist or is not visible to the key. A knowledge base, workgroup or main page requires the scope parameter |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionThe trash check found the block, but during the restore Bitrix24 responded that the block is not on the page |
| HTTP502 | CodeBLOCK_LIST_UNCONFIRMED |
DescriptionBitrix24 did not return the page trash, so the block could not be checked before the restore. The block is untouched |
| HTTP502 | CodeBLOCK_RESTORE_UNCONFIRMED |
DescriptionBitrix24 did not confirm the restore. Check the draft block list before retrying |
| HTTP403 | CodeBITRIX_ACCESS_DENIED |
DescriptionThe employee the key was issued for has no permissions on the page in Bitrix24 |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionBitrix24 rejected the request, the error text is in message |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key has no landing scope |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe key is read-only |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe key has no Bitrix24 tokens configured |
Full list of common API errors: Errors.
Known specifics
- Retry after a lost response. A repeated call for a block that has already left the trash returns
404 BLOCK_NOT_IN_DRAFT, not success. To find out whether the first call worked, look for the block in the draft block list.