Skip to main content

Before you start

You need:
  1. A PDF Gorilla account: sign up
  2. An API key: API keys
  3. A saved template: use the Playground, save it, and copy the template ID from the URL

Step 1: Create a template

Open the Playground, paste this minimal invoice, and click Save as template:
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <style>
    body { font-family: Arial, sans-serif; padding: 40px; }
    h1   { color: #1a1a1a; }
    .total { font-size: 1.4em; font-weight: bold; margin-top: 24px; }
  </style>
</head>
<body>
  <h1>Invoice {{ invoice.number }}</h1>
  <p>Customer: <strong>{{ customer.name }}</strong></p>
  <p>Date: {{ invoice.date }}</p>

  <table style="width:100%; border-collapse:collapse; margin-top:16px">
    <thead>
      <tr style="background:#f5f5f5">
        <th style="padding:8px; text-align:left">Description</th>
        <th style="padding:8px; text-align:right">Amount</th>
      </tr>
    </thead>
    <tbody>
      {% for item in items %}
      <tr>
        <td style="padding:8px; border-top:1px solid #eee">{{ item.description }}</td>
        <td style="padding:8px; border-top:1px solid #eee; text-align:right">{{ item.amount }}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>

  <p class="total">Total: {{ totals.grand }}</p>
</body>
</html>
After saving, note the template ID (for example cma1b2c3d4e5f6g7).

Step 2: Call sync generate

Replace YOUR_API_KEY and YOUR_TEMPLATE_ID. Run:
curl -X POST https://pdfgorilla.io/api/v1/templates/YOUR_TEMPLATE_ID/generate \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "invoice": { "number": "INV-001", "date": "2026-04-06" },
      "customer": { "name": "Acme Corp" },
      "items": [
        { "description": "Consulting", "amount": "$400.00" },
        { "description": "Setup fee",  "amount": "$250.00" }
      ],
      "totals": { "grand": "$650.00" }
    }
  }' \
  --output invoice.pdf
You should get a file named invoice.pdf with your data filled in.

Step 3 (optional): Async generation

For heavier documents, enqueue a job and poll:
curl -X POST https://pdfgorilla.io/api/v1/templates/YOUR_TEMPLATE_ID/generate-async \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data": {"invoice": {"number": "INV-002"}, "customer": {"name": "Globex"}, "items": [], "totals": {"grand": "$0"}}}'

curl https://pdfgorilla.io/api/v1/jobs/JOB_ID \
  -H "x-api-key: YOUR_API_KEY"
See the async workflow guide for polling patterns and webhooks.

Common errors

StatusMeaningWhat to do
401Invalid or missing API keyCheck x-api-key
404Wrong template IDCopy the ID from Templates
429Rate or quota limitWait or see Limits
Full list: Errors.