---
title: "Generate PDF from template"
method: POST
path: "/v1/pdf/create"
tags: ["PDF"]
---

# Generate PDF from template

`POST /v1/pdf/create`

Generate a PDF from a saved template with dynamic data.

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

## Request Body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `template_id` | string | ✅ Yes | Template short ID (12 characters) |
| `data` | object | ✅ Yes | Key-value data to render in template |
| `export_type` | string | No | `url` (default) or `binary` |
| `expiration` | integer | No | URL 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.

## Request body

- CreatePdfRequest — Request model for PDF generation
  - `template_id` string, required — Template short ID (12 characters)
  - `data` object, required — Key-value data to render in the template. Keys must match template variables.
  - `export_type` 'url' | 'binary' — Output delivery type options
  - `expiration` integer — URL expiration in seconds. Min: 60 (1 min), Max: 604800 (7 days). Only applies to `url` export type.
  - `filename` string, nullable — Custom filename for the PDF (without .pdf extension). If not provided, defaults to 'document'. Only applies to `url` export type.
  - `store_s3` boolean — Upload to your configured S3 bucket instead of CDN
  - `s3_filepath` string, nullable — Custom path prefix in your S3 bucket. Uses default prefix if not provided.
  - `s3_bucket` string, 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).
  - `version` string, nullable — Optional version tag (e.g. `prod`) or version number (e.g. `3`). When omitted, uses the current draft.

## Response `200`

PDF generated successfully

- CreatePdfResponse — Response for URL export type
  - `url` string, required — Signed URL to download the PDF (expires after specified time)
  - `filename` string, required — Filename of the generated PDF
  - `credits_remaining` integer, required — Remaining credits after this request
  - `expires_in` integer, required — Seconds until the signed URL expires

## Other responses

- `402` — Insufficient credits
- `403` — Access denied - not your template
- `404` — Template not found
- `422` — Validation Error
- `429` — Rate limit exceeded

---

[API](https://skmtc.net/pdftemplateapi/apis/templatefox-api.md) · [All operations](https://skmtc.net/pdftemplateapi/apis/templatefox-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pdftemplateapi/templatefox-api/revisions/5673fc0d5fad/schema)
