[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fpages\u002Fcards\u002Fupdate":3,"docs-tabs-entities\u002Fpages\u002Fcards\u002Fupdate":6},{"content":4,"lastmod":5},"## Rebuild a card set\n\n`PUT \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Fcards`\n\nRebuilds a block's card set from source cards and, in the same call, sets the node content of the new cards.\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). A block of another page returns `404` |\n| `scope` (query) | string | no | Internal landing area: `KNOWLEDGE` — knowledge base, `GROUP` — workgroup knowledge base, `MAINPAGE` — main page. Omit for a regular site |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|----------|\n| `selector` | string | yes | Card set selector without `@N`, for example `.landing-block-card`. This method takes no index. Set selectors are the keys of the `cards` object in the [`GET \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Fcontent`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-content) response |\n| `source` | array | yes | Sources of the new cards, in order: after the write, the set contains one card per element. An empty array is not accepted |\n| `source[].type` | string | no | `card` — a copy of a card from the current set, `preset` — a card preset from the block manifest. Defaults to `card` |\n| `source[].value` | number \\| string | no | For `card` — the zero-based index of a card in the current set. For `preset` — the preset key from `cards.\u003Cselector>.presets` in the [`GET \u002Fv1\u002Fblock-repository\u002F:code\u002Fmanifest`](\u002Fdocs\u002Fentities\u002Fpages\u002Fcatalog-manifest) response, or the position in it for a `presets` array. The block code is `data.code` in the [`GET \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-get) response. Defaults to `0` |\n| `values` | object | yes | Node content after the rebuild. Top-level keys are arbitrary edit group names. Inside a group, the key is a node selector with an index, and the value is the new content |\n| `values.\u003Cgroup>.\u003Cnode>@N` | string \\| number \\| object | yes | Node content. `N` is the position among all nodes with this selector in the block after the rebuild, not within the card. A text node accepts a string, an integer or an object with a `text` field. `null` is not accepted. Node selectors are the keys of the `nodes` object in the [`GET \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Fcontent`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-content) response |\n\n## Examples\n\nThe block has the cards `First` and `Second`. The request keeps both, adds a third one as a copy of the second, and names it `Third`.\n\n### curl — personal key\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F50\u002Fcards\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"selector\":\".landing-block-card\",\"source\":[{\"type\":\"card\",\"value\":0},{\"type\":\"card\",\"value\":1},{\"type\":\"card\",\"value\":1}],\"values\":{\"third\":{\".landing-block-node-title@2\":\"Third\"}}}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F50\u002Fcards\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"selector\":\".landing-block-card\",\"source\":[{\"type\":\"card\",\"value\":0},{\"type\":\"card\",\"value\":1},{\"type\":\"card\",\"value\":1}],\"values\":{\"third\":{\".landing-block-node-title@2\":\"Third\"}}}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst response = await fetch(\"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F50\u002Fcards\", {\n  method: \"PUT\",\n  headers: {\"X-Api-Key\": \"YOUR_API_KEY\", \"Content-Type\": \"application\u002Fjson\"},\n  body: JSON.stringify({\"selector\": \".landing-block-card\", \"source\": [{\"type\": \"card\", \"value\": 0}, {\"type\": \"card\", \"value\": 1}, {\"type\": \"card\", \"value\": 1}], \"values\": {\"third\": {\".landing-block-node-title@2\": \"Third\"}}}),\n})\nconst result = await response.json()\nif (!response.ok) throw new Error(result.error.message)\nconsole.log(result.data)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst response = await fetch(\"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F50\u002Fcards\", {\n  method: \"PUT\",\n  headers: {\"X-Api-Key\": \"YOUR_APP_KEY\", \"Authorization\": \"Bearer USER_SESSION_TOKEN\", \"Content-Type\": \"application\u002Fjson\"},\n  body: JSON.stringify({\"selector\": \".landing-block-card\", \"source\": [{\"type\": \"card\", \"value\": 0}, {\"type\": \"card\", \"value\": 1}, {\"type\": \"card\", \"value\": 1}], \"values\": {\"third\": {\".landing-block-node-title@2\": \"Third\"}}}),\n})\nconst result = await response.json()\nif (!response.ok) throw new Error(result.error.message)\nconsole.log(result.data)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|----------|\n| `success` | boolean | Always `true` on success |\n| `data.cards` | object | Block cards after the write. The key is the set selector, the value is the array of the set's cards in order |\n| `data.cards.\u003Cselector>[].index` | number | Current zero-based position of the card in the set |\n| `data.cards.\u003Cselector>[].content` | string | Card HTML |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"cards\": {\n      \".landing-block-card\": [\n        {\n          \"index\": 0,\n          \"content\": \"\u003Cdiv class=\\\"landing-block-card\\\">\u003Ch3 class=\\\"landing-block-node-title\\\">First\u003C\u002Fh3>\u003C\u002Fdiv>\"\n        },\n        {\n          \"index\": 1,\n          \"content\": \"\u003Cdiv class=\\\"landing-block-card\\\">\u003Ch3 class=\\\"landing-block-node-title\\\">Second\u003C\u002Fh3>\u003C\u002Fdiv>\"\n        },\n        {\n          \"index\": 2,\n          \"content\": \"\u003Cdiv class=\\\"landing-block-card\\\">\u003Ch3 class=\\\"landing-block-node-title\\\">Third\u003C\u002Fh3>\u003C\u002Fdiv>\"\n        }\n      ]\n    }\n  }\n}\n```\n\n## Error response example\n\n400 — `source` contains the index of a card that is not in the current set:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"source card index does not exist.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|----------|\n| 400 | `INVALID_PARAMS` | `source card index does not exist.` — `source` contains the index of a card that is not in the current set |\n| 400 | `INVALID_PARAMS` | `source preset does not exist in the block manifest.` — the block manifest has no preset with this key |\n| 400 | `INVALID_PARAMS` | `Each source needs a card index or a preset key and type card or preset.` — a `source` element is not an object, contains a field other than `type` and `value`, `type` is not `card` or `preset`, or `value` does not match the type |\n| 400 | `INVALID_PARAMS` | `selector must address an existing card set.` — the block has no set with this selector or the set is empty |\n| 400 | `INVALID_PARAMS` | `selector must omit the card index; DELETE uses the index path parameter.` — `selector` contains `@N` |\n| 400 | `INVALID_PARAMS` | `selector has no card parent.` — the cards of the set have no parent element |\n| 400 | `INVALID_PARAMS` | `Each values entry must map node selectors with @index to content.` — a group in `values` is not an object or is an empty object |\n| 400 | `INVALID_PARAMS` | `values node selectors need a non-negative node index.` — a node selector has no `@N`, or `N` is not a non-negative integer |\n| 400 | `INVALID_PARAMS` | `values references a node absent from the rebuilt block.` — the node is not in the block manifest, or after the rebuild there are fewer than `N + 1` nodes with this selector |\n| 400 | `INVALID_PARAMS` | `Node content cannot be null: Bitrix24 ignores it.` — the node content is `null` |\n| 400 | `INVALID_PARAMS` | `Text nodes require a string, integer, or an object with text.` — a text node received something other than a string or an integer: `true`, `false`, a fractional number, an array, or an object whose `text` is neither a string nor an integer |\n| 400 | `MISSING_REQUIRED_FIELDS` | `source must be a non-empty array and values must be an object.` — `source` is missing or empty, or `values` is missing or not an object |\n| 400 | `MISSING_REQUIRED_FIELDS` | `selector is required.` — `selector` is missing, empty or whitespace-only |\n| 400 | `INVALID_PARAMS` | `pageId and blockId must be positive safe integers.` — `pageId` or `blockId` is not a positive integer |\n| 400 | `INVALID_PARAMS` | `Body must be a JSON object.` — the body is not a JSON object |\n| 400 | `INVALID_PARAMS` | `Body contains an unsupported field.` — the body contains a field other than `selector`, `source` and `values` |\n| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |\n| 404 | `ENTITY_NOT_FOUND` | `Page, block or card not found.` — the block does not belong to page `pageId` or does not exist |\n| 413 | `PAYLOAD_TOO_LARGE` | `Expanded card HTML exceeds 8 MiB.` — the combined markup of the cards from `source` exceeds 8 MiB. The request is rejected before the write |\n| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not confirm the card action.` — Bitrix24 did not confirm the write |\n| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not return cards after the action.` — after the write, Bitrix24 did not return the block content |\n| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not persist the requested card count.` — the card count after the write does not match the length of `source` |\n| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not persist the rebuilt cards.` — the rebuild was supposed to change the block, but the markup stayed the same |\n| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not persist the requested node text.` — the node text from `values` was not saved |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the action. The error text comes from Bitrix24 |\n| 502 | `BITRIX_ERROR` | `Bitrix24 returned invalid or oversized card content.` — the block markup cannot be parsed or the cards exceed 8 MiB |\n| 403 | `SCOPE_DENIED` | The API key does not have the `landing` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. The request is rejected before Bitrix24 is called |\n| 403 | `BITRIX_ACCESS_DENIED` | The Bitrix24 user the key is issued for has no permission to edit the page |\n| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |\n| 401 | `INVALID_API_KEY` | The key in `X-Api-Key` is not found or has been revoked |\n| 401 | `TOKEN_MISSING` | The API key has no configured tokens |\n| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is not available 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| 429 | `RATE_LIMITED` | The Bitrix24 request limit is exceeded. Retry the request in 1-2 seconds |\n| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 did not respond or returned a server error |\n| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond in time |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **A rebuild replaces the entire content of the card parent.** Elements next to the cards that are not cards themselves, and other sets inside the same parent, are removed. To change a single card, use [Clone a block card](\u002Fdocs\u002Fentities\u002Fpages\u002Fcards\u002Fclone), [Remove a card by index](\u002Fdocs\u002Fentities\u002Fpages\u002Fcards\u002Fremove) and [Edit block text and images](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-nodes).\n- **Validation runs before the write.** An unknown selector, a nonexistent source and a node outside the rebuilt block are rejected before the block changes.\n- **A failure after the write does not undo the rebuild.** The `422`, `502` and `503` responses do not mean the set stayed the same. Before retrying, re-read the block via [`GET \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Fcontent`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-content): the `source` indexes refer to the set before the write.\n\n## See also\n\n- [Block cards](\u002Fdocs\u002Fentities\u002Fpages\u002Fcards)\n- [Clone a block card](\u002Fdocs\u002Fentities\u002Fpages\u002Fcards\u002Fclone)\n- [Add a card with HTML](\u002Fdocs\u002Fentities\u002Fpages\u002Fcards\u002Fadd)\n- [Remove a card by index](\u002Fdocs\u002Fentities\u002Fpages\u002Fcards\u002Fremove)\n- [Edit block text and images](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-nodes)\n- [Catalog manifest](\u002Fdocs\u002Fentities\u002Fpages\u002Fcatalog-manifest)\n","2026-10-20",{},1795415271592]