Quickstart
cURL / REST
The PDF4.dev API is a plain REST API. If your language isn't listed, use its standard HTTP client — there's no SDK required.
Prerequisites
- A PDF4.dev account — sign up free
- An API key from Settings
1. Create a template
Go to the dashboard and click New template. Note the template ID or slug.
2. Render a PDF
curl -X POST https://pdf4.dev/api/v1/render \
-H "Authorization: Bearer p4_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"template_id": "invoice",
"data": {
"company_name": "Acme Corp",
"invoice_number": "INV-2025-001",
"total": "$4,500.00"
}
}' \
--output invoice.pdfThe response is a binary PDF file saved to invoice.pdf.
3. Render raw HTML
Skip templates for one-off documents:
curl -X POST https://pdf4.dev/api/v1/render \
-H "Authorization: Bearer p4_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"html": "<h1>Hello {{name}}</h1><p>Your order is confirmed.</p>",
"data": {"name": "John"}
}' \
--output hello.pdf4. Error handling
On error the API returns JSON (not a PDF):
{
"error": {
"type": "invalid_request_error",
"code": "missing_template",
"message": "Template not found"
}
}Check Content-Type: application/pdf in the response headers before writing to disk.
Next steps
- Authentication — API keys and permission scopes
- PDF format — page size, margins, custom dimensions
- API reference — all endpoints with request/response schemas