لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/entities/pages/block-content.md فهرس التوثيق — /llms.txt

مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.

Read block content

GET /v1/pages/:pageId/blocks/:blockId/content

Returns the HTML of a page block and the data for editing it. The draft is always read, so unpublished changes are visible too.

Requires the landing scope. A read-only key works. No request body is sent.

Parameters

Parameter Type Required Description
ParameterpageId (path) Typenumber Requiredyes DescriptionPage ID. List: GET /v1/pages
ParameterblockId (path) Typenumber Requiredyes DescriptionID of a block on page pageId. List: GET /v1/pages/:pageId/blocks
Parameterscope (query) Typestring Requiredno DescriptionSite type: KNOWLEDGE — knowledge base, GROUP — workgroup site, MAINPAGE — main page. Omit the parameter for pages of other sites

Examples

curl — personal key

Terminal
curl "https://vibecode.bitrix24.com/v1/pages/3/blocks/4975/content" \
  -H "X-Api-Key: YOUR_API_KEY"

curl — OAuth application

Terminal
curl "https://vibecode.bitrix24.com/v1/pages/3/blocks/4975/content" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"

JavaScript — personal key

javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/pages/3/blocks/4975/content", {
  headers: {"X-Api-Key": "YOUR_API_KEY"},
})
const result = await response.json()
if (!response.ok) throw new Error(result.error.message)
console.log(result.data)

JavaScript — OAuth application

javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/pages/3/blocks/4975/content", {
  headers: {"X-Api-Key": "YOUR_APP_KEY", "Authorization": "Bearer USER_SESSION_TOKEN"},
})
const result = await response.json()
if (!response.ok) throw new Error(result.error.message)
console.log(result.data)

Response fields

Field Type Description
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata Typeobject DescriptionBlock content
Fielddata.html Typestring DescriptionBlock HTML inside a container with the block-wrapper class
Fielddata.anchor Typestring DescriptionBlock anchor. Optional field
Fielddata.nodes Typeobject | array DescriptionDescription of editable nodes: the key is the node's CSS selector. Optional field
Fielddata.cards Typeobject | array DescriptionDescription of block cards: the key is the card's CSS selector. Optional field
Fielddata.style Typeobject | array DescriptionAvailable styles of the block and its nodes. Optional field
Fielddata.attrs Typeobject | array DescriptionEditable node attributes. Optional field
Fielddata.css Typearray DescriptionPaths to the block's CSS files. Optional field
Fielddata.js Typearray DescriptionPaths to the block's JavaScript files. Optional field
Fielddata.php Typeboolean Descriptiontrue — the block contains PHP code, and editing its content is restricted. Optional field

Response example

JSON
{
  "success": true,
  "data": {
    "html": "<div id=\"block4975\" data-id=\"4975\" class=\"block-wrapper block-26-3-separator\"><div class=\"landing-block g-pt-0 g-pb-0 g-height-70 g-my-minus-2 g-fill-first g-fill-second g-height-50--md landing-block-separator\" style=\"--fill-first: #ffffff;--fill-second: hsla(0, 0%, 86%, 1);\">\r\n\t<svg class=\"g-width-100x g-height-100x\" viewbox=\"0 0 1100 200\" preserveaspectratio=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n\t\t<path class=\"fill-first\" d=\"M0 0H1100V2V3H1097.19L550 198L2.80612 3H0V2V0Z\" />\r\n\t\t<path class=\"fill-second\" d=\"M1100 197V198V200H0V198V197V2L547.194 197H552.806L1100 2V197Z\" />\r\n\t</svg>\r\n</div></div>",
    "nodes": [],
    "cards": [],
    "style": {
      "block": {
        "type": [
          "display",
          "fill-first",
          "fill-second",
          "height-increased--md"
        ]
      },
      "nodes": []
    },
    "attrs": [],
    "anchor": "b4975",
    "css": [],
    "js": [
      "/bitrix/js/pull/protobuf/protobuf.min.js?178773668523214",
      "/bitrix/js/pull/protobuf/model.min.js?178773668521204",
      "/bitrix/js/main/core/core_promise.min.js?17906071592494",
      "/bitrix/js/rest/client/rest.client.min.js?16015491189240",
      "/bitrix/js/pull/client/pull.client.min.js?174471771449849"
    ],
    "php": false
  }
}

Error response example

404 — there is no such block on page pageId:

JSON
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Block or page not found."
  }
}

Errors

HTTP Code Description
HTTP404 CodeENTITY_NOT_FOUND DescriptionBlock or page not found. — no block or page with these IDs exists, or the block belongs to another page
HTTP400 CodeINVALID_PARAMS DescriptionpageId and blockId must be positive safe integers. — pageId or blockId is not a positive integer
HTTP400 CodeINVALID_SCOPE Descriptionscope is not KNOWLEDGE, GROUP or MAINPAGE
HTTP502 CodeBITRIX_INVALID_RESPONSE DescriptionBitrix24 returned an invalid block., Bitrix24 returned a different block. or Bitrix24 returned invalid block content. — Bitrix24 returned an unexpected result
HTTP502 CodeBITRIX_INVALID_RESPONSE DescriptionBitrix24 block response exceeds the 8 MiB limit. — the Bitrix24 response is larger than 8 MiB
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 rejected the request. The error text comes from Bitrix24
HTTP403 CodeSCOPE_DENIED DescriptionThe API key does not have the landing scope
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe Bitrix24 user the key was issued for has no permission to read the page
HTTP401 CodeTOKEN_MISSING DescriptionThe API key has no configured tokens
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header is missing
HTTP401 CodeINVALID_API_KEY DescriptionThe key in X-Api-Key is not found or has been revoked
HTTP409 CodeLANDING_MODULE_NOT_ENABLED DescriptionThe Sites module is unavailable on the Bitrix24 account
HTTP409 CodePORTAL_ADDRESS_CHANGED DescriptionThe on-premise Bitrix24 moved to a new address, but the key's webhook was issued for the old one. Reissue the key's webhook
HTTP429 CodeRATE_LIMITED DescriptionThe Bitrix24 request limit is exceeded. Retry the request in 1-2 seconds
HTTP502 CodeBITRIX_UNAVAILABLE DescriptionBitrix24 did not respond or responded with a server error
HTTP503 CodeBITRIX_TIMEOUT DescriptionBitrix24 did not respond in the allotted time

Full list of common API errors — Errors.

Known specifics

  • An empty dictionary comes back as an empty array. For a block without nodes, cards or attributes, the nodes, cards and attrs fields are [], not {}. Check the type before iterating over keys.
  • Editing data is filled in from the manifest. A nodes, cards, style or attrs field missing from the top level of the Bitrix24 response is taken from the block manifest.
  • Links with credentials are hidden. A response string that contains a Bitrix24 webhook URL or a token in URL parameters comes back as [REDACTED]. If such a URL is in the HTML, the whole html is replaced with [REDACTED].

See also