v1

latestOpenAPI 3.1.02026-08-06244570.4 KB
PDF

Generate PDF from template

Generate a PDF from a saved template with dynamic data.

Authentication: API Key required (x-api-key header)

Request Body

FieldTypeRequiredDescription
template_idstring✅ YesTemplate short ID (12 characters)
dataobject✅ YesKey-value data to render in template
export_typestringNourl (default) or binary
expirationintegerNoURL expiration in seconds (60-604800, default: 86400)

Export Types

  • url (default): PDF is uploaded to CDN, returns JSON with URL
  • binary: Returns raw PDF bytes directly

Credits: 1 credit deducted per successful generation.

Rate Limits: 60 requests/min (free), 120 requests/min (paid). Headers included in response.

post/v1/pdf/create

Request body

template_idstring required

Template short ID (12 characters)

dataobject required

Key-value data to render in the template. Keys must match template variables.

export_type'url' | 'binary'

Output delivery type options

expirationinteger

URL expiration in seconds. Min: 60 (1 min), Max: 604800 (7 days). Only applies to url export type.

filenamestring nullable

Custom filename for the PDF (without .pdf extension). If not provided, defaults to 'document'. Only applies to url export type.

store_s3boolean

Upload to your configured S3 bucket instead of CDN

s3_filepathstring nullable

Custom path prefix in your S3 bucket. Uses default prefix if not provided.

s3_bucketstring nullable

Override the default bucket configured in your S3 integration.

pdf_variant'pdf/a-1b' | 'pdf/a-2b' | 'pdf/a-3b'

PDF variant for standards-compliant output (PDF/A).

versionstring nullable

Optional version tag (e.g. prod) or version number (e.g. 3). When omitted, uses the current draft.

Example request

{
  "data": {
    "invoice_number": "INV-001",
    "name": "John Doe"
  },
  "expiration": 86400,
  "export_type": "url",
  "filename": "invoice-001",
  "template_id": "HMQywVpZxqAM"
}

Response

PDF generated successfully

urlstring required

Signed URL to download the PDF (expires after specified time)

filenamestring required

Filename of the generated PDF

credits_remaininginteger required

Remaining credits after this request

expires_ininteger required

Seconds until the signed URL expires

Example response

{
  "credits_remaining": 99,
  "expires_in": 86400,
  "filename": "invoice-001.pdf",
  "url": "https://cdn.templatefox.com/generated/abc123/invoice.pdf"
}
All 24 operations