## Read a catalog sample

`GET /v1/block-repository/:code/content`

Returns the HTML sample of a block from the block catalog. The sample shows the markup and node classes before the block is added to a page.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `code` (path) | string | yes | Catalog block code without the `bitrix:` prefix, for example `27.3.one_col_fix_title`. A code with the prefix returns `404`. To get the list, call [`GET /v1/block-repository`](/docs/entities/pages/catalog): the code is the key of an element in a section's `items`. It comes without the prefix and can be passed as is. Application block codes `repo_N` and "My blocks" template codes of the form `sourceCode@blockId` are also accepted. Encode the `@` character with `encodeURIComponent` |
| `scope` (query) | string | no | Internal landing area: `KNOWLEDGE` — knowledge base, `GROUP` — group knowledge base, `MAINPAGE` — home page. Omit it for a regular site |

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/block-repository/27.3.one_col_fix_title/content" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/block-repository/27.3.one_col_fix_title/content" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const code = encodeURIComponent("27.3.one_col_fix_title")
const response = await fetch(`https://vibecode.bitrix24.com/v1/block-repository/${code}/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 code = encodeURIComponent("27.3.one_col_fix_title")
const response = await fetch(`https://vibecode.bitrix24.com/v1/block-repository/${code}/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.code` | string | Block code in the form it was passed in the path |
| `data.html` | string | HTML sample of the block. If the markup contains an address with credentials, the whole string is replaced with `[REDACTED]` |

## Response example

```json
{
  "success": true,
  "data": {
    "code": "27.3.one_col_fix_title",
    "html": "<section class=\"landing-block js-animation g-pt-30 g-pb-30\">\n\t<h2 class=\"landing-block-node-title js-animation fadeIn g-my-0 container g-max-width-container g-pl-15 g-pr-15 g-color\">The title</h2>\n</section>"
  }
}
```

## Error response example

404 — there is no sample with this code, or the code was passed with the `bitrix:` prefix:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Block sample not found."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 404 | `ENTITY_NOT_FOUND` | `Block sample not found.` — there is no sample with this code, or the code was passed with the `bitrix:` prefix |
| 404 | `ENTITY_NOT_FOUND` | `Block or page not found.` — the catalog of the current Bitrix24 account has no block with this code. Which of the two messages arrives depends on the step at which the block was not found |
| 400 | `INVALID_PARAMS` | `code must be a non-empty block code.` — `code` is empty or contains only spaces |
| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 502 | `BITRIX_INVALID_RESPONSE` | `Bitrix24 returned an invalid block sample.` — Bitrix24 returned a sample that is not a string |
| 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 on whose behalf the key was issued has no permission to read the catalog |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `INVALID_API_KEY` | The key in `X-Api-Key` was not found or has been revoked |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 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 was 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 within the allotted time |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

- **Application blocks are read from the current Bitrix24 account.** The `repo_N` code refers to blocks that applications added to the catalog of the current Bitrix24 account.
- **A read-only key works.** The method only reads data, so a key in read-only mode gets a response.

## See also

- [Block catalog](/docs/entities/pages/catalog)
- [Catalog manifest](/docs/entities/pages/catalog-manifest)
- [Add a block to a page](/docs/entities/pages/blocks/create)
- [Saved blocks](/docs/entities/block-repository)
- [Pages](/docs/entities/pages)
