API Documentation
Everything you need to generate PDFs with the PDFGen AI API. Simple REST endpoints, AI-powered features, and clear examples.
Authentication
All API requests require an API key passed as a Bearer token in the Authorization header.
Authorization: Bearer pk_your_api_key_hereGet your API key from the Dashboard → API Keys page after signing up.
Base URL
https://pdfgen.ai/apiRate Limits
| Plan | Price | PDFs/month | AI calls/month |
|---|---|---|---|
| Free | $0 | 50 | 10 |
| Starter | $19 | 2,000 | 100 |
| Pro | $49 | 15,000 | 500 |
| Business | $99 | 100,000 | 2,000 |
| Enterprise | $299 | Unlimited | Unlimited |
/api/generateGenerate PDF
Generate a PDF from HTML content or a saved template with data.
Request Body
{
// Option 1: Raw HTML
"html": "<h1>Hello {{name}}</h1>",
"data": { "name": "World" },
// Option 2: Saved template
"template_id": "uuid-here",
"data": { "name": "World" }
}Response (200)
{
"job_id": "uuid",
"status": "completed",
"url": "https://...supabase.co/storage/.../file.pdf"
}Error Responses
| Status | Description |
|---|---|
| 400 | Missing html or template_id |
| 401 | Missing or invalid API key |
| 429 | Rate limit exceeded |
/api/ai/templateAI Template Generation
Describe a document in plain English and the AI generates a professional HTML template with {{variables}}.
Request Body
{
"prompt": "Professional invoice with company name, date, line items table, and total",
"save": true,
"name": "My Invoice"
}Response (200)
{
"html": "<!DOCTYPE html><html>...</html>",
"variables": ["company_name", "invoice_date", "line_items", "total"],
"template_id": "uuid or null"
}Error Responses
| Status | Description |
|---|---|
| 400 | Missing prompt |
| 401 | Missing or invalid API key |
| 429 | AI rate limit exceeded |
/api/ai/fillAI Data Mapping
Send raw JSON data and a list of template variables. The AI intelligently maps fields — e.g. first_name + last_name → full_name.
Request Body
{
"data": {
"first": "John",
"last": "Doe",
"amt": 99.99,
"order_date": "2026-04-24"
},
"variables": ["full_name", "amount", "date"],
"context": "This is for an invoice"
}Response (200)
{
"mapped": {
"full_name": "John Doe",
"amount": "99.99",
"date": "2026-04-24"
}
}Error Responses
| Status | Description |
|---|---|
| 400 | Missing data or variables |
| 401 | Missing or invalid API key |
| 429 | AI rate limit exceeded |
| 502 | AI returned invalid JSON |
Quick Start
Generate your first PDF in 3 steps:
Sign up and get your API key
Create an account, then go to Dashboard → API Keys.
Generate a PDF from HTML
curl -X POST https://pdfgen.ai/api/generate \
-H "Authorization: Bearer pk_your_key" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Hello World</h1><p>My first PDF!</p>"}'Or let AI create a template
curl -X POST https://pdfgen.ai/api/ai/template \
-H "Authorization: Bearer pk_your_key" \
-H "Content-Type: application/json" \
-d '{"prompt": "Professional invoice with line items", "save": true}'Ready to start building?
Get your free API key and generate your first PDF in seconds.
Get Your Free API Key