Docs

POST /v1/pdf

Use POST /v1/pdf to print HTML, a public URL, GitHub-flavoured Markdown, or a published Handlebars template to a production PDF with Chromium. Choose it for invoices, reports, and any page you can already render in a browser. Office files go to POST /v1/convert; merging existing PDFs is POST /v1/pdf/merge.

Provide exactly one of html, url, markdown, or templateId. HTML is UTF-8 JSON — not Base64. The same endpoint powers the Node fromHtml / fromUrl / fromMarkdown / fromTemplate helpers.

Body fields

One source plus optional filename, response mode, callback, and Chromium options.

FieldRequiredDescription
htmlone ofRaw HTML document
urlone ofPublic http(s) URL. Private, loopback, and metadata hosts are rejected
markdownone ofGFM Markdown, rendered via Chromium
templateIdone ofPublished template UUID or slug
templateDatawith templateIdJSON object injected into Handlebars
templateVersionnoPin a published version; default is latest published
strictnoFail if a Handlebars path is missing
filenamenoMust end with .pdf
responsenobinary (default), url, or async
callbackUrlnoHTTPS URL POSTed when this job finishes
optionsnoChromium print options — see Rendering options

HTML to PDF

Send the document as a JSON string. printBackground defaults to true.

POST /v1/pdf
{
  "html": "<h1>Invoice #1042</h1><p>Total: $1,200.00</p>",
  "filename": "invoice.pdf",
  "options": {
    "format": "letter",
    "printBackground": true
  }
}

URL to PDF

RelayPDF fetches the page and prints it. The host must be public.

POST /v1/pdf
{
  "url": "https://example.com",
  "response": "url",
  "filename": "example.pdf"
}

Markdown to PDF

Same endpoint. Markdown is rendered to HTML then printed.

POST /v1/pdf
{
  "markdown": "# Hello from Markdown\n\nA table-ready document API."
}

Template to PDF

Create and publish a Handlebars draft first (dashboard or Template API). Then pass templateId plus templateData.

POST /v1/pdf
{
  "templateId": "invoice",
  "templateData": { "number": "INV-1042", "total": 1458 },
  "filename": "invoice.pdf"
}

Binary response

Default. 200 application/pdf with x-relaypdf-id, x-relaypdf-size, and content-disposition.

URL response

JSON with a public download that expires in 24 hours.

response: url
{
  "id": "pdf_...",
  "status": "completed",
  "url": "https://api.relaypdf.com/v1/files/pdf_...",
  "filename": "document.pdf",
  "sizeBytes": 12345,
  "expiresAt": "2026-08-19T13:51:00.000Z"
}