# Preview a status page

`POST /api/v1/status-pages/{pageId}/previews`

A link to the page as it would look with unsaved edits, valid for 10 minutes. Nothing changes. The edits are checked by the same rules as saving them. Needs the editor role.

Sign-in: a dashboard session only. API tokens and OAuth sign-ins get `403 token.not_allowed`.

Section: Status pages. Operation id in openapi.json: `create_status_page_preview`.

## Parameters

| Name | In | Required | Type | Description |
|---|---|---|---|---|
| `pageId` | path | yes | string (uuid) | The status page's id. |

## Request body

Required: yes.

`application/json`: StatusPagePreviewInput

| Field | Type | Required | Description |
|---|---|---|---|
| `accentColor` | string \| null | no | As in `PATCH /status-pages/{pageId}` (contrast with white text at least 4.5:1); `null` is the product accent. |
| `components` | array of ComponentInput \| null | no | As in `PUT /status-pages/{pageId}/components`, in display order. |
| `theme` | PageTheme \| null | no |  |
| `title` | string \| null | no |  |
| `websiteUrl` | string \| null | no | As in `PATCH /status-pages/{pageId}`; `null` shows the page without the link. |

## Responses

Errors are `application/problem+json` (`Problem`); branch on `type`.

### 201

The preview's address and when it expires.

`application/json`: StatusPagePreviewView

| Field | Type | Required | Description |
|---|---|---|---|
| `expiresAt` | string | yes |  |
| `url` | string | yes | `<MONITORLY_STATUS_PUBLIC_URL>/_preview/<token>`: the page as edited, for an iframe of the dashboard. |

### 400

Bad Request.

- `request.malformed`: the body or a parameter is not of the expected shape
- `auth.credentials_conflict`: the request carries both a session cookie and a token

### 401

Unauthorized.

- `auth.unauthenticated`, `auth.session_expired`: no session, or it ended
- `token.invalid`: the token is malformed, unknown, revoked or expired, or its creator left the workspace

### 403

Forbidden.

- `auth.forbidden`: your role is too low for this
- `token.not_allowed`: this operation needs a signed-in session; tokens cannot call it
- `request.origin_mismatch`, `request.header_required`: a changing request with a session comes from another site or lacks `X-Monitorly-Request: 1`

### 404

Not Found.

- `request.not_found`: it does not exist, or you cannot see it

### 413

Payload Too Large.

- `request.too_large`: the body is larger than 256 KiB

### 422

Unprocessable Entity.

- `field.required`, `field.too_long`, `field.invalid`: a field breaks a rule; `errors` points at it
- `status_page.check_not_in_project`: component check is not from the page's project
- `status_page.accent_contrast_low`: contrast of white text on the accent color is less than 4.5:1 (`params.ratio`)

### 429

Too Many Requests.

- `session.rate_limited`: more than 5 changes a second from your sessions

### 503

Service Unavailable.

- `server.unavailable`: temporarily unavailable; retry later

Schemas named above are listed with their fields in [the schema list](https://docs.monitorly.cloud/api/reference/schemas.md).
