## 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 |
|----------|-----|:-----:|----------|
| `pageId` (path) | number | yes | Page ID. List: [`GET /v1/pages`](/docs/entities/pages/list) |
| `blockId` (path) | number | yes | ID of a block on page `pageId`. List: [`GET /v1/pages/:pageId/blocks`](/docs/entities/pages/blocks/list) |
| `scope` (query) | string | no | Site type: `KNOWLEDGE` — knowledge base, `GROUP` — workgroup site, `MAINPAGE` — main page. Omit the parameter for pages of other sites |

## Examples

### curl — personal key

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

### curl — OAuth application

```bash
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 |
|------|-----|----------|
| `success` | boolean | Always `true` on success |
| `data` | object | Block content |
| `data.html` | string | Block HTML inside a container with the `block-wrapper` class |
| `data.anchor` | string | Block anchor. Optional field |
| `data.nodes` | object \| array | Description of editable nodes: the key is the node's CSS selector. Optional field |
| `data.cards` | object \| array | Description of block cards: the key is the card's CSS selector. Optional field |
| `data.style` | object \| array | Available styles of the block and its nodes. Optional field |
| `data.attrs` | object \| array | Editable node attributes. Optional field |
| `data.css` | array | Paths to the block's CSS files. Optional field |
| `data.js` | array | Paths to the block's JavaScript files. Optional field |
| `data.php` | boolean | `true` — 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 |
|------|-----|----------|
| 404 | `ENTITY_NOT_FOUND` | `Block or page not found.` — no block or page with these IDs exists, or the block belongs to another page |
| 400 | `INVALID_PARAMS` | `pageId and blockId must be positive safe integers.` — `pageId` or `blockId` is not a positive integer |
| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 502 | `BITRIX_INVALID_RESPONSE` | `Bitrix24 returned an invalid block.`, `Bitrix24 returned a different block.` or `Bitrix24 returned invalid block content.` — Bitrix24 returned an unexpected result |
| 502 | `BITRIX_INVALID_RESPONSE` | `Bitrix24 block response exceeds the 8 MiB limit.` — the Bitrix24 response is larger than 8 MiB |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request. The error text comes from Bitrix24 |
| 403 | `SCOPE_DENIED` | The API key does not have the `landing` scope |
| 403 | `BITRIX_ACCESS_DENIED` | The Bitrix24 user the key was issued for has no permission to read the page |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `INVALID_API_KEY` | The key in `X-Api-Key` is not found or has been revoked |
| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is unavailable on the Bitrix24 account |
| 409 | `PORTAL_ADDRESS_CHANGED` | The on-premise Bitrix24 moved to a new address, but the key's webhook was issued for the old one. Reissue the key's webhook |
| 429 | `RATE_LIMITED` | The Bitrix24 request limit is exceeded. Retry the request in 1-2 seconds |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 did not respond or responded with a server error |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond in the allotted time |

Full list of common API errors — [Errors](/docs/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

- [Read a page block](/docs/entities/pages/block-get)
- [List page blocks](/docs/entities/pages/blocks/list)
- [Pages](/docs/entities/pages)
