Templates
List available templates for PDF generation.
Templates
List all available templates for Template to PDF conversion. Templates are pre-built document layouts that you populate with dynamic data.
GET
/v1/templates
Code Examples
curl https://api.pdfapi.dev/v1/templates \
-H "Authorization: Bearer sk_live_xxx"
const response = await fetch('https://api.pdfapi.dev/v1/templates', {
headers: {
'Authorization': `Bearer ${process.env.PDFAPI_KEY}`,
},
});
const { data } = await response.json();
console.log('Available templates:', data.map(t => t.id));
import requests
import os
response = requests.get(
'https://api.pdfapi.dev/v1/templates',
headers={
'Authorization': f'Bearer {os.environ["PDFAPI_KEY"]}',
}
)
templates = response.json()['data']
for template in templates:
available = "✓" if template['available'] else "✗"
print(f"{available} {template['id']}: {template['name']} ({template['plan']})")
req, _ := http.NewRequest("GET", "https://api.pdfapi.dev/v1/templates", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("PDFAPI_KEY"))
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
Response
{
"data": [
{
"id": "invoice",
"name": "Invoice",
"description": "Professional invoice template with line items",
"plan": "pro",
"available": true,
"preview_url": "https://pdfapi.dev/templates/invoice-preview.png",
"required_fields": ["invoice_number", "customer", "items", "total"],
"optional_fields": ["due_date", "tax", "notes", "logo_url"]
},
{
"id": "receipt",
"name": "Receipt",
"description": "Payment receipt template",
"plan": "pro",
"available": true,
"preview_url": "https://pdfapi.dev/templates/receipt-preview.png",
"required_fields": ["receipt_number", "date", "items", "total", "payment_method"],
"optional_fields": ["customer", "notes"]
},
{
"id": "quote",
"name": "Quote",
"description": "Price quote template",
"plan": "pro",
"available": true,
"preview_url": "https://pdfapi.dev/templates/quote-preview.png",
"required_fields": ["quote_number", "customer", "items"],
"optional_fields": ["valid_until", "terms", "notes"]
},
{
"id": "certificate",
"name": "Certificate",
"description": "Achievement or completion certificate",
"plan": "business",
"available": false,
"preview_url": "https://pdfapi.dev/templates/certificate-preview.png",
"required_fields": ["recipient", "title", "description", "date"],
"optional_fields": ["issuer", "signature_url", "badge_url"]
},
{
"id": "contract",
"name": "Contract",
"description": "Business contract template",
"plan": "business",
"available": false,
"preview_url": "https://pdfapi.dev/templates/contract-preview.png",
"required_fields": ["parties", "terms", "date"],
"optional_fields": ["witnesses", "attachments"]
}
]
}
Template Fields
| Field | Type | Description |
|---|---|---|
id | string | Template identifier (use this in API requests) |
name | string | Human-readable template name |
description | string | Template description |
plan | string | Minimum plan required (pro, business, enterprise) |
available | boolean | Whether template is available on your current plan |
preview_url | string | URL to template preview image |
required_fields | array | Fields that must be provided |
optional_fields | array | Optional fields for customization |
Available Templates
Pro Plan
| Template | Description | Required Fields |
|---|---|---|
invoice | Professional invoice | invoice_number, customer, items, total |
receipt | Payment receipt | receipt_number, date, items, total, payment_method |
quote | Price quote | quote_number, customer, items |
Business Plan
| Template | Description | Required Fields |
|---|---|---|
certificate | Achievement certificate | recipient, title, description, date |
contract | Business contract | parties, terms, date |
Enterprise Plan
| Template | Description | Required Fields |
|---|---|---|
report | Business report | title, sections, date |
proposal | Project proposal | title, scope, timeline, budget |
Usage
Use a template with the Template to PDF endpoint:
{
"template": "invoice",
"data": {
"invoice_number": "INV-2025-001",
"customer": {
"name": "Acme Corp",
"email": "billing@acme.com"
},
"items": [
{"description": "Widget", "quantity": 2, "unit_price": 29.99}
],
"total": 59.98
}
}
See Template to PDF for detailed usage examples.
Checking Availability
The available field indicates whether a template is available on your current plan:
const { data: templates } = await fetchTemplates();
const availableTemplates = templates.filter(t => t.available);
const unavailableTemplates = templates.filter(t => !t.available);
console.log('You can use:', availableTemplates.map(t => t.id));
console.log('Upgrade to access:', unavailableTemplates.map(t => t.id));
Upgrade your plan to access additional templates.