[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fpages\u002Fblock-attrs":3,"docs-tabs-entities\u002Fpages\u002Fblock-attrs":6},{"content":4,"lastmod":5},"## Update block attributes\n\n`PATCH \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Fattrs`\n\nChanges the attributes of block nodes on a site page, for example the countdown end date of a timer block. Only attributes that the block manifest declares as editable can be changed.\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 | ID of a block on this page. List: [`GET \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblocks\u002Flist) |\n| `scope` (query) | string | no | Site area: `KNOWLEDGE` — knowledge base, `GROUP` — workgroup pages, `MAINPAGE` — home pages. Omit the parameter for pages of all other sites |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|----------|\n| `attrs` | object | yes | An object of the form \"selector → attributes\". Must not be empty. The body has no other fields |\n| `attrs.\u003Cselector>` | object | yes | The key is a node selector `.class` or `.class@N`, where `N` is a zero-based index among the nodes with that class. Without `@N`, the change applies to all nodes with that class. Only nodes for which the block manifest declares editable attributes are allowed. They are visible in the response of [`GET \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Fcontent`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-content): elements with the `attribute` key in the `cards`, `style` and `attrs` fields, and for a timer block — `cards.\u003Cselector>.additional.attrs`. The value is a non-empty object of attributes |\n| `attrs.\u003Cselector>.\u003Cattribute>` | string | yes | The new attribute value. For a timer block, `data-end-date` is the countdown end time in milliseconds |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PATCH \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Fattrs\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"attrs\": {\n      \".landing-block-node-card@0\": {\n        \"data-end-date\": \"1798750800000\"\n      }\n    }\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PATCH \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Fattrs\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"attrs\": {\n      \".landing-block-node-card@0\": {\n        \"data-end-date\": \"1798750800000\"\n      }\n    }\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Fattrs', {\n  method: 'PATCH',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    attrs: {\n      '.landing-block-node-card@0': {\n        'data-end-date': '1798750800000',\n      },\n    },\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\u002Fattrs', {\n  method: 'PATCH',\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    attrs: {\n      '.landing-block-node-card@0': {\n        'data-end-date': '1798750800000',\n      },\n    },\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. An automatic anchor has the form `b\u003Cid>`, for example `b7` |\n| `data.content` | string | The full block HTML, read back after the change |\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 timer block markup is long, so `content` is shortened: it shows the `.landing-block-node-card` node with the saved attribute, and the rest is replaced with an ellipsis.\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"id\": 7,\n    \"pageId\": 42,\n    \"anchor\": \"b7\",\n    \"content\": \"\u003Cdiv id=\\\"block7\\\" data-id=\\\"7\\\" class=\\\"block-wrapper block-51-4-countdown-music\\\">…\u003Cdiv class=\\\"landing-block-node-card row g-mb-50 js-countdown u-countdown\\\" data-end-date=\\\"1798750800000\\\" data-days-format=\\\"%D\\\" data-hours-format=\\\"%H\\\" data-minutes-format=\\\"%M\\\" data-seconds-format=\\\"%S\\\" data-days-expired-classes=\\\"u-countdown--days-expiried\\\">…\u003C\u002Fdiv>…\u003C\u002Fdiv>\",\n    \"nodes\": {},\n    \"styles\": {},\n    \"attrs\": {},\n    \"cards\": {},\n    \"active\": true\n  }\n}\n```\n\n## Error response example\n\n400 — the selector is not among the nodes with editable attributes; the message lists the available ones:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"Unknown selector or index. Available selectors: .landing-block-node-card\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|----------|\n| 400 | `INVALID_PARAMS` | The selector is not among the nodes with editable attributes, or the `@N` index exceeds the number of nodes with that class. The message lists the available selectors. For a block without such nodes, the list after `Available selectors:` is empty |\n| 400 | `INVALID_PARAMS` | The value for a selector is not an object, or is an empty object |\n| 400 | `INVALID_PARAMS` | The selector is not in the `.class` or `.class@N` format. Service keys are not accepted in place of a selector |\n| 400 | `INVALID_PARAMS` | The body contains a field other than `attrs` |\n| 400 | `INVALID_PARAMS` | `pageId` or `blockId` is not a positive integer |\n| 400 | `MISSING_REQUIRED_FIELDS` | The body is not a JSON object, it has no `attrs` field, or `attrs` is an empty 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 change was accepted, but the block could not be read back afterwards |\n| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is not enabled on the Bitrix24 account |\n| 409 | `PORTAL_ADDRESS_CHANGED` | A self-hosted 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` | Bitrix24 did not confirm the block change |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. The request is refused before any call to the Bitrix24 account |\n| 403 | `SCOPE_DENIED` | The key does not have the `landing` scope |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 access tokens |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **An undeclared attribute is dropped without an error.** If the node matches but the attribute is not among those declared in the manifest, the response comes back with `200`, but the attribute is not saved. A request with `data-foo` and `onclick` to the `.landing-block-node-card@0` node of a timer block returned success, and neither attribute appeared in `content`. Verify the result in `content`.\n\n## See also\n\n- [Update block text and images](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-nodes)\n- [Update block styles](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-styles)\n- [Change a block node tag](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-tags)\n- [Read block content](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-content)\n- [List page blocks](\u002Fdocs\u002Fentities\u002Fpages\u002Fblocks\u002Flist)\n- [Errors](\u002Fdocs\u002Ferrors)\n","2026-10-20",{},1795415267527]