Generate a PDF
POST/api/v1/designs/:designId/generate
Renders one PDF from a design, substituting variable values, and returns a temporary presigned download URL. Costs 1 credit.
Path parameters
| Param | Type | Required | Notes |
|---|---|---|---|
designId | string | yes | The design id to render. |
Body
| Field | Type | Required | Notes |
|---|---|---|---|
data | object | no | Variable name → value. Omit for a design with no variables. |
pdfProfile | string | no | Compliance output: accessible (tagged PDF/UA-1 — screen-reader structure, reading order, alt text) or pdf-a (archival PDF/A-3b, also tagged). Omit or standard for regular output. Same credit cost. Validating with an accessibility checker (axesCheck, PAC, verapdf --flavour ua1)? Use accessible — pdf-a targets archival validation (veraPDF 3b) and does not claim PDF/UA. |
curl -X POST "https://api.imaginepdf.com/api/v1/designs/design_abc123/generate" \
-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"
},
"pdfProfile": "accessible"
}'Response 201 Created
{
"status": "success",
"data": {
"generationId": "gen_abc123",
"designId": "design_abc123",
"filename": "Invoice.pdf",
"downloadUrl": "https://storage.googleapis.com/...output.pdf?X-Goog-Signature=...",
"expiresIn": 3600,
"status": "completed"
},
"error": null
}generationId— stable identifier for this render. The PDF bytes expire, but this id does not — store it to correlate a document with the run that made it.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
| HTTP | error.code | Meaning |
|---|---|---|
| 402 | INSUFFICIENT_CREDITS | Workspace is out of credits. |
| 404 | DESIGN_NOT_FOUND | No design with that id in the workspace. |
| 400 | VALIDATION_ERROR | Malformed body. |
See Errors for the full table, and Credits & plans for credit behavior.
Related
- Generate a PDF in Node.js with the REST API
- Generate PDFs in Next.js Route Handlers
- Preview — render a page to PNG for free while iterating.
- Batch generation — one PDF per dataset row.
- Variables — how
datamaps onto the design.
Last updated on