لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/entities/pages/block-anchor.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Set a block anchor
PUT /v1/pages/:pageId/blocks/:blockId/anchor
Sets or removes the anchor of a block on a site page. Use it to replace a block's automatic anchor with your own value.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ParameterpageId (path) |
Typenumber | Requiredyes | DescriptionPage ID. List: GET /v1/pages |
ParameterblockId (path) |
Typenumber | Requiredyes | DescriptionBlock ID on this page. List: GET /v1/pages/:pageId/blocks |
Parameterscope (query) |
Typestring | Requiredno | DescriptionSite scope: KNOWLEDGE — knowledge base, GROUP — workgroup pages, MAINPAGE — main pages. Omit for pages of all other sites |
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
Fieldanchor |
Typestring | Requiredyes | DescriptionNew block anchor. Starts with a Latin letter, followed by Latin letters, digits and the characters -, _, ., :. An empty string "" removes the anchor, and anchor comes back empty in the response |
Examples
curl — personal key
curl -X PUT "https://vibecode.bitrix24.com/v1/pages/42/blocks/7/anchor" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"anchor": "spring"
}'
curl — OAuth application
curl -X PUT "https://vibecode.bitrix24.com/v1/pages/42/blocks/7/anchor" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"anchor": "spring"
}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/pages/42/blocks/7/anchor', {
method: 'PUT',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
anchor: 'spring',
}),
})
const { success, data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/pages/42/blocks/7/anchor', {
method: 'PUT',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
anchor: 'spring',
}),
})
const { success, data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | Descriptiontrue on success |
Fielddata.id |
Typenumber | DescriptionBlock ID |
Fielddata.pageId |
Typenumber | DescriptionPage ID |
Fielddata.anchor |
Typestring | DescriptionBlock anchor after the write. An automatic anchor has the form b<id>, for example b7. After removal — an empty string |
Fielddata.content |
Typestring | DescriptionFull block HTML, re-read after the write |
Fielddata.nodes |
Typeobject | DescriptionEmpty object. The block state is in content |
Fielddata.styles |
Typeobject | DescriptionEmpty object. The block state is in content |
Fielddata.attrs |
Typeobject | DescriptionEmpty object. The block state is in content |
Fielddata.cards |
Typeobject | DescriptionEmpty object. The block state is in content |
Fielddata.active |
Typeboolean | DescriptionWhether the block is active |
Response example
The paragraph text in content is shortened with an ellipsis; the markup is unchanged.
{
"success": true,
"data": {
"id": 7,
"pageId": 42,
"anchor": "spring",
"content": "<div id=\"block7\" data-id=\"7\" class=\"block-wrapper block-27-one-col-fix-title-and-text-2\"><section class=\"landing-block js-animation g-pt-30 g-pb-30\">\r\n\t<div class=\"landing-block-node-text-container container g-max-width-container\">\r\n\t\t<h3 class=\"landing-block-node-title g-color-red g-mb-20\">Spring sale</h3>\r\n\t\t<div class=\"landing-block-node-text js-animation g-mb-20 g-pb-1 g-color\">\r\n\t\t\tSed feugiat porttitor nunc, non dignissim ipsum vestibulum in...\r\n\t\t</div>\r\n\t</div>\r\n</section></div>",
"nodes": {},
"styles": {},
"attrs": {},
"cards": {},
"active": true
}
}
Error response example
404 — the block is not on this page:
{
"success": false,
"error": {
"code": "ENTITY_NOT_FOUND",
"message": "Page or block not found"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
DescriptionpageId or blockId is not a positive integer |
| HTTP400 | CodeINVALID_PARAMS |
Descriptionanchor is not a string |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionThe body contains a field other than anchor |
| HTTP400 | CodeMISSING_REQUIRED_FIELDS |
DescriptionThe body has no anchor field or is not a JSON object |
| HTTP400 | CodeINVALID_SCOPE |
Descriptionscope is not KNOWLEDGE, GROUP or MAINPAGE |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionThe page does not exist, the block does not exist, or the block belongs to another page |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionThe anchor was written, but the block could not be re-read afterwards |
| HTTP409 | CodeLANDING_MODULE_NOT_ENABLED |
DescriptionThe Sites module is not enabled on the Bitrix24 account |
| HTTP409 | CodePORTAL_ADDRESS_CHANGED |
DescriptionThe on-premise Bitrix24 moved to a new address, but the key's webhook was issued for the old one. Reissue the key's webhook |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionThe anchor has an invalid format: it does not start with a Latin letter or contains a space, Cyrillic characters, # or other disallowed characters. The response carries b24Code: BAD_ANCHOR; the message comes in the Bitrix24 account language |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionBitrix24 did not confirm the anchor write |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key lacks the landing scope |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe key is read-only. The request is rejected before reaching Bitrix24 |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe API key has no Bitrix24 access tokens |
Full list of common API errors — Errors.