Skip to Content
API ReferenceGenerate a PDF

Generate a PDF

POST /generate?design=:designId

Renders one PDF from a design, substituting variable values, and returns a temporary presigned download URL. Costs 1 credit.

Query parameters

ParamTypeRequiredNotes
designstringyesThe design id to render.

Body

FieldTypeRequiredNotes
dataobjectnoVariable name → value. Omit for a design with no variables.
curl -X POST "https://api.imaginepdf.com/api/v1/generate?design=design_abc123" \ -H "X-API-Key: $IMAGINEPDF_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "data": { "invoice_number": "INV-001", "customer_name": "Acme Corp", "amount": "$1,000.00" } }'

Response 201 Created

{ "status": "success", "data": { "designId": "design_abc123", "filename": "Invoice.pdf", "downloadUrl": "https://storage.imaginepdf.com/....pdf?signature=...", "expiresIn": 3600, "status": "completed" }, "error": null }
  • downloadUrl — presigned URL to the rendered PDF.
  • expiresIn — seconds the URL stays valid (3600 = one hour).
  • filename — suggested filename, derived from the design name.

Download it:

curl -L -o invoice.pdf "<downloadUrl>"

The download URL expires after expiresIn seconds. Fetch and store the PDF promptly rather than passing the URL around long-term.

Errors

HTTPerror.codeMeaning
402INSUFFICIENT_CREDITSWorkspace is out of credits.
404DESIGN_NOT_FOUNDNo design with that id in the workspace.
400VALIDATION_ERRORMissing design query param or malformed body.

See Errors for the full table, and Credits & plans for credit behavior.