POST /v1/generate
Generate a PDF from HTML or a stored template.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| html | string | one of | Inline HTML document |
| template | string | one of | Template id or slug |
| data | object | no | Data passed to the template |
| options | object | no | PDF rendering options |
| async | boolean | no | If true, enqueue and return 202 |
| webhook_url | string | no | URL to POST on completion (async) |
Options
| Option | Type | Default |
|---|---|---|
| format | A4 | A3 | A5 | Letter | Legal | Tabloid | A4 |
| landscape | boolean | false |
| margin | { top, bottom, left, right } | 20/20/15/15 mm |
| header_html | string | — |
| footer_html | string | — |
| print_background | boolean | true |
| scale | number | 1 |
| page_ranges | string | all |
Response (sync, 200)
jsonexample
{
"id": "pdf_abc123",
"status": "completed",
"url": "https://files.pdfend.com/pdf_abc123.pdf",
"pages": 3,
"size": 45230,
"duration_ms": 1180
}Response (async, 202)
jsonexample
{
"id": "pdf_abc123",
"status": "queued",
"poll_url": "https://api.pdfend.com/v1/generations/pdf_abc123"
}Errors
jsonexample
{
"error": {
"code": "VALIDATION_ERROR",
"message": "html or template is required"
},
"request_id": "req_01HX..."
}cURL
bashexample
curl -X POST https://api.pdfend.com/v1/generate \
-H "Authorization: Bearer pk_live_..." \
-H "Content-Type: application/json" \
-d '{"html":"<h1>Hello</h1>","options":{"format":"A4"}}'