[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fpages\u002Ffavorite":3,"docs-tabs-entities\u002Fpages\u002Ffavorite":6},{"content":4,"lastmod":5},"## Save a block to \"My blocks\"\n\n`POST \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Ffavorite`\n\nSaves a page block as a template in the \"My blocks\" section of the Bitrix24 account block catalog. Every editor of the account sees the template — it is not a personal bookmark.\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 the block on this page that becomes the template. List: [`GET \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblocks\u002Flist). A block from another page returns `404` |\n| `scope` (query) | string | no | Internal landing scope: `KNOWLEDGE` — knowledge base, `GROUP` — group knowledge base, `MAINPAGE` — home page. Omit for a regular site |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|----------|\n| `name` | string | yes | Template name in \"My blocks\". An empty string or a whitespace-only string is rejected |\n| `sections` | array of string | no | Catalog sections the template goes into, for example `[\"text\"]`. Section codes are the `data` keys in the [`GET \u002Fv1\u002Fblock-repository`](\u002Fdocs\u002Fentities\u002Fpages\u002Fcatalog) response. An empty array `[]` is accepted, empty strings in the array are not |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F50\u002Ffavorite\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"name\":\"Reusable block\",\"sections\":[\"text\"]}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F50\u002Ffavorite\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"name\":\"Reusable block\",\"sections\":[\"text\"]}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst response = await fetch(\"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F50\u002Ffavorite\", {\n  method: \"POST\",\n  headers: {\"X-Api-Key\": \"YOUR_API_KEY\", \"Content-Type\": \"application\u002Fjson\"},\n  body: JSON.stringify({\"name\": \"Reusable block\", \"sections\": [\"text\"]}),\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\u002Ffavorite\", {\n  method: \"POST\",\n  headers: {\"X-Api-Key\": \"YOUR_APP_KEY\", \"Authorization\": \"Bearer USER_SESSION_TOKEN\", \"Content-Type\": \"application\u002Fjson\"},\n  body: JSON.stringify({\"name\": \"Reusable block\", \"sections\": [\"text\"]}),\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.blockId` | number | Template ID in \"My blocks\". Differs from the source block's `blockId` in the path. Pass this ID to [template deletion](\u002Fdocs\u002Fentities\u002Fblock-repository\u002Ffavorites\u002Fdelete) |\n| `data.code` | string | Template code in the form `sourceCode@blockId`. The template appears in the [block catalog](\u002Fdocs\u002Fentities\u002Fpages\u002Fcatalog) under this code |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"blockId\": 29441,\n    \"code\": \"03.1.three_cols_big_with_text_and_titles@29441\"\n  }\n}\n```\n\n## Error response example\n\n400 — template name not provided:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"MISSING_REQUIRED_FIELDS\",\n    \"message\": \"name is required.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|----------|\n| 400 | `MISSING_REQUIRED_FIELDS` | `name is required.` — `name` is missing, empty or whitespace-only |\n| 400 | `INVALID_PARAMS` | `sections must be an array of non-empty strings.` — `sections` is not an array, or the array contains a non-string, an empty string or a whitespace-only string |\n| 400 | `INVALID_PARAMS` | `Body contains an unsupported field.` — the body has a field other than `name` and `sections`, for example `preview` |\n| 404 | `ENTITY_NOT_FOUND` | `Page, block or card not found.` — the block does not belong to page `pageId` or does not exist |\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_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |\n| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not return a saved block ID.` — Bitrix24 did not return the ID of the saved template |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the action. The error text comes from Bitrix24 |\n| 502 | `BITRIX_ERROR` | `Bitrix24 returned an invalid block code.` — the source block has no catalog block code |\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 reaching Bitrix24 |\n| 403 | `BITRIX_ACCESS_DENIED` | The Bitrix24 user the key was issued for has no permission for this action |\n| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |\n| 401 | `INVALID_API_KEY` | The key in `X-Api-Key` was 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` | The on-premise Bitrix24 moved to a new address, while the key webhook was issued for the old one. Reissue the key webhook |\n| 429 | `RATE_LIMITED` | Bitrix24 request limit exceeded. Retry 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- **Every call creates a new template.** Repeating the call with the same block and the same name does not update the previous template — it adds another one with a new `blockId`. Delete unneeded templates with [`DELETE \u002Fv1\u002Fblock-repository\u002Ffavorites\u002F:blockId`](\u002Fdocs\u002Fentities\u002Fblock-repository\u002Ffavorites\u002Fdelete).\n- **The source block does not change.** The template is a copy of the block at the time of the call. Later edits to the block on the page do not reach the template.\n\n## See also\n\n- [Saved blocks](\u002Fdocs\u002Fentities\u002Fblock-repository)\n- [Delete a template from \"My blocks\"](\u002Fdocs\u002Fentities\u002Fblock-repository\u002Ffavorites\u002Fdelete)\n- [Block catalog](\u002Fdocs\u002Fentities\u002Fpages\u002Fcatalog)\n- [Page block list](\u002Fdocs\u002Fentities\u002Fpages\u002Fblocks\u002Flist)\n","2026-10-20",{},1795415272816]