---
title: "Render a page as a PNG"
method: POST
path: "/v1/preview"
tags: ["preview"]
---

# Render a page as a PNG

`POST /v1/preview`

## Request

- Base URL: `https://api.niubai.vip` (the document declares no server; this is the origin it was published from)
- URL: `https://api.niubai.vip/v1/preview`
- Auth: HTTP bearer

A PNG of one page (or a region of it), optionally with highlight boxes, to look before editing or to show a person what changed. At most 200 KB. Free.

## Request body

- PreviewRequest: ``POST /v1/preview``'s body (spec §2.2).
  - `source` SourceModel, required
    - `url` string, uri, nullable
    - `file_id` string, nullable
    - `password` string, nullable
  - `page` integer
  - `region` number[], nullable
  - `scale` 1 | 2 | 3
  - `highlight` array[], nullable
    - number[]

## Response `200`

The rendered page, at most 200 KB.

## Other responses

- `400`: error.code is one of: invalid_request
- `401`: error.code is one of: unauthorized
- `404`: error.code is one of: not_found
- `413`: error.code is one of: too_large
- `422`: error.code is one of: document_encrypted, document_unsupported, signed_document, edit_failed
- `429`: error.code is one of: rate_limited
- `500`: error.code is one of: engine_error
- `502`: error.code is one of: upstream_error
- `504`: error.code is one of: engine_timeout

---

[API](https://skmtc.dev/niubai/apis/pdf-edit-api-gateway.md) · [All operations](https://skmtc.dev/niubai/apis/pdf-edit-api-gateway/llms.txt) · [OpenAPI document](https://skmtc.dev/niubai/apis/pdf-edit-api-gateway/revisions/1ad0ce16ca04?raw)
