PDFs

Create a PDF

Renders a template (template_id) or raw html. response: binary (default, the PDF) or url (JSON with a signed link). With async: true the answer is 202 and the result arrives as pdf.created or pdf.failed. deliver.email emails the PDF. test: true makes a watermarked test document (not counted) even with a live key. e_invoice issues a structured invoice as Factur-X / ZUGFeRD (a PDF/A-3b with the XML embedded) or XRechnung (the XML itself, application/xml); see the EInvoice schema. merge_data is for no-code forms (GET /v1/templates/{id}/fields, tree): its empty values (null, empty strings, empty objects and arrays) are dropped and the rest is deep-merged over data. The JSON answer (response: url) carries every Document field, plus filename, metadata, warnings and blocked_resources.

post/v1/pdf

Request

  • Base URL: https://api.castpdf.com
  • URL: https://api.castpdf.com/v1/pdf
  • Auth: HTTP bearer

Headers

Idempotency-Keystring

1 to 255 printable ASCII characters. The same key and body within 24 hours return the first result instead of doing the work again.

Request body

template_idstring
template_versioninteger
htmlstring
cssstring
dataobject
merge_dataobject
mode'fast' | 'print'
orientation'portrait' | 'landscape'
marginsstring
filenamestring
response'binary' | 'url'
metadataobject
asyncboolean
testboolean

Response

The PDF (response: binary) or its JSON (response: url). An XRechnung e_invoice answers with the XML (application/xml). E-invoices carry the header x-e-invoice: <standard>/<profile>.

idstring uuid
status'queued' | 'processing' | 'succeeded' | 'failed' | 'canceled'
pagesinteger nullable
bytesinteger nullable
mode'fast' | 'print' | 'null' nullable
testboolean
template_idstring nullable
template_versioninteger nullable
error_codestring nullable
created_atstring date-time
expires_atstring date-time nullable
urlstring uri nullable

Signed download link, valid until expires_at.

thumbnail_urlstring uri nullable

Signed PNG of the first page (480 px wide) while the PDF is stored; made on first request. In GET /v1/pdf/{id} and GET /v1/documents, not in webhook events.

filenamestring
metadataobject nullable
warningsobject[]
blocked_resourcesstring[]

Changes

No recorded changes to this operation across all 1 revision of this API.