
## Page preview

`GET /v1/pages/:id/preview`

Returns the absolute URL of a site page's preview image. The method does not download the image file itself.

Requires the `landing` scope. A read-only key works.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | Page ID. List: [`GET /v1/pages`](/docs/entities/pages/list) |
| `scope` (query) | string | no | Site type: `KNOWLEDGE` — knowledge base, `GROUP` — workgroup site, `MAINPAGE` — main page. Omit the parameter for pages of all other sites |

## Examples

### curl — personal key

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

### curl — OAuth application

```bash
curl -X GET "https://vibecode.bitrix24.com/v1/pages/3/preview" \
  -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/preview", {
  method: "GET",
  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/preview", {
  method: "GET",
  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 | Page preview |
| `data.previewUrl` | string | Absolute URL of the preview image |

## Response example

The page preview has been generated, and the URL serves the page image:

```json
{
  "success": true,
  "data": {
    "previewUrl": "https://example.bitrix24.site/preview.jpg"
  }
}
```

## Error response example

404 — no page with this `id`:

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

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 404 | `ENTITY_NOT_FOUND` | `Page not found.` — no page with this `id` |
| 404 | `ENTITY_NOT_FOUND` | `Page or folder not found.` — Bitrix24 did not find the page when the preview was requested |
| 400 | `INVALID_PAGE_ID` | `id must be a positive safe integer.` — `id` is not a positive integer |
| 400 | `INVALID_SCOPE` | `scope must be KNOWLEDGE, GROUP or MAINPAGE, or omitted.` — `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not return a page URL.` — Bitrix24 did not return a preview URL |
| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 returned an invalid page URL.` — Bitrix24 returned a URL that is not an `http` or `https` URL, or a URL containing a username and password |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request. The error message 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` was not found or has been revoked |
| 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

- **Until the preview is generated, a placeholder is returned.** In that case the `previewUrl` address serves a placeholder image instead of the page image.

## See also

- [Page public URL](/docs/entities/pages/public-url)
- [Get a page](/docs/entities/pages/get)
- [Pages](/docs/entities/pages)
