Skip to content

Export a PDF

POST /api/export/{id}/pdf

Renders the template {id} with the variable values you send, and returns the PDF. This is the endpoint most integrations need — often the only one.

Part Value
Path id Template ID — the last segment of the editor URL /editor/{id}
Header x-api-key: <your-api-key>
Header Content-Type: application/json
Body A flat JSON object: variable name → value
{
"client": "ACME Corp",
"discount": true,
"lines": [
{ "label": "A5 flyers", "price": "$85" },
{ "label": "A3 posters", "price": "$120" }
],
"total": "$205.00"
}
  • Keys are the variable names shown in the editor (case-sensitive).
  • Missing or empty variables fall back to their default.
  • Keys that match no variable are ignored.
  • A template without variables accepts an empty body ({}).

The value you send depends on the variable’s type — see Variables. In short: string takes a string (format dates and amounts yourself), boolean takes true/false, and object-list takes an array of objects.

200 OK with the PDF as the body.

Header Example
Content-Type application/pdf
Content-Disposition attachment; filename="Tutorial.pdf"; filename*=UTF-8''Tutorial.pdf
Content-Length 69136
X-Generation-Time 893 — rendering time in milliseconds

The file name comes from the template title. The PDF has one page per page of the template, at the template’s pageSize.

Terminal window
curl -X POST "https://app.imprime.io/api/export/$TEMPLATE_ID/pdf" \
-H "x-api-key: $IMPRIME_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "client": "ACME Corp", "total": "$205.00" }' \
--fail-with-body -o quote.pdf
Status Example body Cause
400 { "error": "Required variable \"total\" is missing" } A required variable has no value
400 { "code": "VARIABLE_TOO_LONG", "error": "Variable \"client\" is longer than its max length of 28 characters" } A value exceeds maxLength
401 { "code": "UNAUTHENTICATED", "error": "Authentication required" } Missing, invalid or revoked API key
404 { "code": "TEMPLATE_NOT_FOUND", "error": "Template not found" } Wrong ID, or not your template
408 { "error": "PDF generation timed out after 30s" } Rendering exceeded 30 seconds