---
title: "POST /api/documents/{documentId}"
method: POST
path: "/api/documents/{documentId}"
---

# POST /api/documents/{documentId}

`POST /api/documents/{documentId}`

Generates a PDF document from a published document template.

## Path parameters

- `documentId` string, required

## Request body

- object
  - `props` object, required — Props to pass to the document component
  - `format` 'pdf' | 'base64' | 'json' — Response format. `pdf` returns a binary PDF file, `base64` returns the PDF encoded as base64 in JSON, `json` returns a URL to download the PDF. Defaults to `pdf`
  - `size` string — Page size (A3, A4, A5, letter, legal, or custom size like '8.5in 11in')
  - `orientation` 'portrait' | 'landscape'

## Response `200`

Generated document in requested format

- union
  - object — Base64 encoded PDF (when format=base64)
    - `data` string, base64
  - object — PDF URL (when format=json)
    - `url` string, uri

## Other responses

- `404` — Document template not found
- `422` — Generation limit exceeded
- `500` — Internal server error

---

[API](https://skmtc.dev/htmldocs-js/apis/htmldocs-api.md) · [All operations](https://skmtc.dev/htmldocs-js/apis/htmldocs-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/htmldocs-js/htmldocs-api/revisions/e3c5bbaba462/schema)
