[Go to site: main page, start]

Skip to content

Create PDF — Synchronous PDF Generation API

Generate a PDF from a template with a single synchronous call. The request blocks until the PDF is rendered and returns either a signed URL or the raw PDF bytes.

POST https://api.templatefox.com/v1/pdf/create

Authentication: API key in x-api-key header. Credits: 1 credit per successful generation (refunded automatically if rendering fails).

For large documents, batch jobs, or webhook-driven flows, use create-pdf-async instead.

Only two body fields are strictly required:

FieldTypeDescription
template_idstringThe 12-character ID of your template (copy from the templates dashboard).
dataobjectKey-value pairs to inject into the template. Keys must match {{variable}} placeholders in your design.
curl -X POST https://api.templatefox.com/v1/pdf/create \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "template_id": "HMQywVpZxqAM",
  "data": {
    "customer_name": "John Doe",
    "invoice_number": "INV-001",
    "amount": "$1,234.56"
  }
}'

Or use one of our official SDKs — TypeScript, Python, Go, PHP, Ruby, Java, C#.

FieldTypeRequiredDefaultDescription
template_idstring12-character template short ID.
dataobjectKey-value data merged into the template. See Data Binding.
export_typestring"url""url" uploads the PDF to our CDN and returns a signed URL. "binary" returns the raw PDF bytes as application/pdf.
expirationinteger86400URL expiration in seconds. Min: 60, max: 604800 (7 days). Only applies when export_type="url".
filenamestring"document"Custom filename (without .pdf extension). Alphanumeric, _, -, . only. Max 100 chars.
store_s3booleanfalseUpload to your configured S3 bucket instead of our CDN. Requires an S3 integration.
s3_filepathstringPath prefix inside your S3 bucket. Overrides default_prefix. Max 500 chars.
s3_bucketstringOverride the bucket name from your S3 integration (3–63 chars, lowercase).
pdf_variantstringGenerate a standards-compliant PDF. Values: "pdf/a-1b", "pdf/a-2b", "pdf/a-3b". See PDF Standards.
versionstringTemplate version tag (e.g. "prod") or numeric version (e.g. "3"). Omit to use the current draft. Max 50 chars.

Returns JSON with a signed URL to the generated PDF.

{
"url": "https://cdn.templatefox.com/generated/abc123/invoice.pdf",
"filename": "invoice-001.pdf",
"credits_remaining": 99,
"expires_in": 86400
}
FieldTypeDescription
urlstringSigned URL to download the PDF (expires after expires_in seconds).
filenamestringFinal filename of the generated PDF.
credits_remainingnumberCredits left in your team’s balance after this call.
expires_innumberSeconds until the signed URL expires.

Returns the raw PDF file with content type application/pdf. Useful when you want to stream the file directly to a user or store it yourself. expiration, filename, and S3 options are ignored.

Response headers:

Content-Type: application/pdf
Content-Disposition: attachment; filename="HMQywVpZxqAM.pdf"
X-Credits-Remaining: 99

When S3 upload is requested, the response describes where the file landed in your bucket instead of returning a URL:

{
"s3_bucket": "my-pdf-bucket",
"s3_key": "invoices/2026/01/invoice-001.pdf",
"filename": "invoice-001.pdf",
"credits_remaining": 99
}

Example:

curl -X POST https://api.templatefox.com/v1/pdf/create \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "template_id": "HMQywVpZxqAM",
  "data": { "customer_name": "John Doe" },
  "store_s3": true,
  "filename": "invoice-001",
  "s3_filepath": "2026/01/"
}'

Set pdf_variant to produce a PDF that passes PDF/A compliance checks — useful for e-invoicing (Factur-X, ZUGFeRD), archival, or regulated industries.

curl -X POST https://api.templatefox.com/v1/pdf/create \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "template_id": "HMQywVpZxqAM",
  "data": { "customer_name": "John Doe" },
  "pdf_variant": "pdf/a-3b"
}'

Set export_type to "binary" to receive the raw PDF bytes directly — useful for streaming to the user or saving to disk without a CDN round-trip.

curl -X POST https://api.templatefox.com/v1/pdf/create \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
--output invoice.pdf \
-d '{
  "template_id": "HMQywVpZxqAM",
  "data": { "customer_name": "John Doe" },
  "export_type": "binary"
}'
StatusErrorWhen
400BAD_REQUESTThe template is an image template — use create-image instead.
401UNAUTHORIZEDMissing or invalid API key.
402INSUFFICIENT_CREDITSYour team’s credit balance is 0.
403FORBIDDENThe template does not belong to your team.
404TEMPLATE_NOT_FOUNDtemplate_id does not exist.
429RATE_LIMIT_EXCEEDEDRate limit hit (see response headers).
500INTERNAL_ERRORRendering failed. Credit is automatically refunded.

See the full list in the API Reference overview.