لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/entities/pages/block-attrs.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Update block attributes
PATCH /v1/pages/:pageId/blocks/:blockId/attrs
Changes 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.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ParameterpageId (path) |
Typenumber | Requiredyes | DescriptionPage ID. List: GET /v1/pages |
ParameterblockId (path) |
Typenumber | Requiredyes | DescriptionID of a block on this page. List: GET /v1/pages/:pageId/blocks |
Parameterscope (query) |
Typestring | Requiredno | DescriptionSite area: KNOWLEDGE — knowledge base, GROUP — workgroup pages, MAINPAGE — home pages. Omit the parameter for pages of all other sites |
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
Fieldattrs |
Typeobject | Requiredyes | DescriptionAn object of the form "selector → attributes". Must not be empty. The body has no other fields |
Fieldattrs.<selector> |
Typeobject | Requiredyes | DescriptionThe 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 /v1/pages/:pageId/blocks/:blockId/content: elements with the attribute key in the cards, style and attrs fields, and for a timer block — cards.<selector>.additional.attrs. The value is a non-empty object of attributes |
Fieldattrs.<selector>.<attribute> |
Typestring | Requiredyes | DescriptionThe new attribute value. For a timer block, data-end-date is the countdown end time in milliseconds |
Examples
curl — personal key
curl -X PATCH "https://vibecode.bitrix24.com/v1/pages/42/blocks/7/attrs" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"attrs": {
".landing-block-node-card@0": {
"data-end-date": "1798750800000"
}
}
}'
curl — OAuth application
curl -X PATCH "https://vibecode.bitrix24.com/v1/pages/42/blocks/7/attrs" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"attrs": {
".landing-block-node-card@0": {
"data-end-date": "1798750800000"
}
}
}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/pages/42/blocks/7/attrs', {
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
attrs: {
'.landing-block-node-card@0': {
'data-end-date': '1798750800000',
},
},
}),
})
const { success, data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/pages/42/blocks/7/attrs', {
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
attrs: {
'.landing-block-node-card@0': {
'data-end-date': '1798750800000',
},
},
}),
})
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. An automatic anchor has the form b<id>, for example b7 |
Fielddata.content |
Typestring | DescriptionThe full block HTML, read back after the change |
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 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.
{
"success": true,
"data": {
"id": 7,
"pageId": 42,
"anchor": "b7",
"content": "<div id=\"block7\" data-id=\"7\" class=\"block-wrapper block-51-4-countdown-music\">…<div 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\">…</div>…</div>",
"nodes": {},
"styles": {},
"attrs": {},
"cards": {},
"active": true
}
}
Error response example
400 — the selector is not among the nodes with editable attributes; the message lists the available ones:
{
"success": false,
"error": {
"code": "INVALID_PARAMS",
"message": "Unknown selector or index. Available selectors: .landing-block-node-card"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
DescriptionThe 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 |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionThe value for a selector is not an object, or is an empty object |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionThe selector is not in the .class or .class@N format. Service keys are not accepted in place of a selector |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionThe body contains a field other than attrs |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionpageId or blockId is not a positive integer |
| HTTP400 | CodeMISSING_REQUIRED_FIELDS |
DescriptionThe body is not a JSON object, it has no attrs field, or attrs is an empty 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 change was accepted, but the block could not be read back afterwards |
| HTTP409 | CodeLANDING_MODULE_NOT_ENABLED |
DescriptionThe Sites module is not enabled on the Bitrix24 account |
| HTTP409 | CodePORTAL_ADDRESS_CHANGED |
DescriptionA self-hosted 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 |
DescriptionBitrix24 did not confirm the block change |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe key is read-only. The request is refused before any call to the Bitrix24 account |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key does not have the landing scope |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe API key has no Bitrix24 access tokens |
Full list of common API errors — Errors.
Known specifics
- 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 withdata-fooandonclickto the.landing-block-node-card@0node of a timer block returned success, and neither attribute appeared incontent. Verify the result incontent.