PDF4.dev
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

1. Create a template

Go to the dashboard and click New template. Note the template ID or slug.

2. Render a PDF

cURL
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.pdf

The response is a binary PDF file saved to invoice.pdf.

3. Render raw HTML

Skip templates for one-off documents:

cURL — raw HTML
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.pdf

4. Error handling

On error the API returns JSON (not a PDF):

400 Bad Request
{
  "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