---
title: "Generate PDF document."
method: POST
path: "/documents/v1/generate"
tags: ["documents"]
---

# Generate PDF document.

`POST /documents/v1/generate`

Generate PDF document from JSON design, HTML content, or URL.

## Query parameters

- `projectId` string, required

## Request body

- union
  - object
    - `design` object, required — Proprietary design format JSON
    - `html` string — HTML content to convert to PDF
    - `url` string, uri — URL to convert to PDF
    - `mergeTags` object — Optional merge tags for personalization
    - `filename` string — Optional filename for the generated PDF
  - object
    - `design` object — Proprietary design format JSON
    - `html` string, required — HTML content to convert to PDF
    - `url` string, uri — URL to convert to PDF
    - `mergeTags` object — Optional merge tags for personalization
    - `filename` string — Optional filename for the generated PDF
  - object
    - `design` object — Proprietary design format JSON
    - `html` string — HTML content to convert to PDF
    - `url` string, uri, required — URL to convert to PDF
    - `mergeTags` object — Optional merge tags for personalization
    - `filename` string — Optional filename for the generated PDF

## Response `200`

Default Response

- object
  - `data` object
    - `documentId` string — Unique document identifier
    - `pdfUrl` string, uri — URL to download the generated PDF
    - `status` 'generating' | 'completed' | 'failed'
    - `filename` string — Generated filename

## Other responses

- `400` — Default Response
- `401` — Default Response
- `403` — Default Response
- `404` — Default Response

## Changes

- **2026-01-19** `42ce261f6dec` — 1 breaking, 4 warning, 10 info
  - the `query` request parameter `projectId` became required
  - removed the optional property `documentId` from the response with the `200` status
  - removed the optional property `filename` from the response with the `200` status
  - removed the optional property `pdfUrl` from the response with the `200` status
  - …11 more
- **2026-01-13** `343ccfa7da7d` — 3 info
  - added the new optional `query` request parameter `projectId`
  - added the non-success response with the status `401`
  - added the non-success response with the status `403`
- **2025-12-10** `168db8cc4eb5` — 2 breaking
  - removed `subschema #1, subschema #2, subschema #3` from the request body `anyOf` list
  - the request property `design` became required
- **2025-12-09** `9c0284025bec` — 1 breaking, 1 info
  - api path removed without deprecation
  - endpoint added

[Change history](https://skmtc.dev/unlayer/apis/unlayer-api/changes/documents/v1/generate/post.md)

---

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