[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fpages\u002Fblock-anchor":3,"docs-tabs-entities\u002Fpages\u002Fblock-anchor":6},{"content":4,"lastmod":5},"## Set a block anchor\n\n`PUT \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Fanchor`\n\nSets or removes the anchor of a block on a site page. Use it to replace a block's automatic anchor with your own value.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|----------|\n| `pageId` (path) | number | yes | Page ID. List: [`GET \u002Fv1\u002Fpages`](\u002Fdocs\u002Fentities\u002Fpages\u002Flist) |\n| `blockId` (path) | number | yes | Block ID on this page. List: [`GET \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblocks\u002Flist) |\n| `scope` (query) | string | no | Site scope: `KNOWLEDGE` — knowledge base, `GROUP` — workgroup pages, `MAINPAGE` — main pages. Omit for pages of all other sites |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|----------|\n| `anchor` | string | yes | New 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 |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Fanchor\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"anchor\": \"spring\"\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Fanchor\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"anchor\": \"spring\"\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Fanchor', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    anchor: 'spring',\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Fanchor', {\n  method: 'PUT',\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({\n    anchor: 'spring',\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|----------|\n| `success` | boolean | `true` on success |\n| `data.id` | number | Block ID |\n| `data.pageId` | number | Page ID |\n| `data.anchor` | string | Block anchor after the write. An automatic anchor has the form `b\u003Cid>`, for example `b7`. After removal — an empty string |\n| `data.content` | string | Full block HTML, re-read after the write |\n| `data.nodes` | object | Empty object. The block state is in `content` |\n| `data.styles` | object | Empty object. The block state is in `content` |\n| `data.attrs` | object | Empty object. The block state is in `content` |\n| `data.cards` | object | Empty object. The block state is in `content` |\n| `data.active` | boolean | Whether the block is active |\n\n## Response example\n\nThe paragraph text in `content` is shortened with an ellipsis; the markup is unchanged.\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"id\": 7,\n    \"pageId\": 42,\n    \"anchor\": \"spring\",\n    \"content\": \"\u003Cdiv id=\\\"block7\\\" data-id=\\\"7\\\" class=\\\"block-wrapper block-27-one-col-fix-title-and-text-2\\\">\u003Csection class=\\\"landing-block js-animation g-pt-30 g-pb-30\\\">\\r\\n\\t\u003Cdiv class=\\\"landing-block-node-text-container container g-max-width-container\\\">\\r\\n\\t\\t\u003Ch3 class=\\\"landing-block-node-title g-color-red g-mb-20\\\">Spring sale\u003C\u002Fh3>\\r\\n\\t\\t\u003Cdiv 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\u003C\u002Fdiv>\\r\\n\\t\u003C\u002Fdiv>\\r\\n\u003C\u002Fsection>\u003C\u002Fdiv>\",\n    \"nodes\": {},\n    \"styles\": {},\n    \"attrs\": {},\n    \"cards\": {},\n    \"active\": true\n  }\n}\n```\n\n## Error response example\n\n404 — the block is not on this page:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"ENTITY_NOT_FOUND\",\n    \"message\": \"Page or block not found\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|----------|\n| 400 | `INVALID_PARAMS` | `pageId` or `blockId` is not a positive integer |\n| 400 | `INVALID_PARAMS` | `anchor` is not a string |\n| 400 | `INVALID_PARAMS` | The body contains a field other than `anchor` |\n| 400 | `MISSING_REQUIRED_FIELDS` | The body has no `anchor` field or is not a JSON object |\n| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |\n| 404 | `ENTITY_NOT_FOUND` | The page does not exist, the block does not exist, or the block belongs to another page |\n| 404 | `ENTITY_NOT_FOUND` | The anchor was written, but the block could not be re-read afterwards |\n| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is not enabled on the Bitrix24 account |\n| 409 | `PORTAL_ADDRESS_CHANGED` | The on-premise Bitrix24 moved to a new address, but the key's webhook was issued for the old one. Reissue the key's webhook |\n| 422 | `BITRIX_ERROR` | The 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 |\n| 422 | `BITRIX_ERROR` | Bitrix24 did not confirm the anchor write |\n| 403 | `SCOPE_DENIED` | The key lacks the `landing` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. The request is rejected before reaching Bitrix24 |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 access tokens |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## See also\n\n- [Read block content](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-content)\n- [List page blocks](\u002Fdocs\u002Fentities\u002Fpages\u002Fblocks\u002Flist)\n- [Publish a block](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-publication)\n- [Pages](\u002Fdocs\u002Fentities\u002Fpages)\n- [Errors](\u002Fdocs\u002Ferrors)\n","2026-10-20",{},1795415267347]