Guide · Zapier
Generate PDF documents from Zapier
Turn any Zap into a document pipeline with Docmill's Generate Document action: pick a template, map your fields into one JSON box, and every later step receives a finished PDF, DOCX, or XLSX file — not a blob of text.
What you need
- A Zapier account (the Docmill action works on any Zapier plan that allows multi-step Zaps).
- A Docmill API key. The free tier includes 50 documents a month (watermarked), no credit card required.
Step 1 — Connect Docmill to Zapier
Add a Docmill step
In the Zap editor, add an action step and search for Docmill. Choose the Generate Document event.
Connect your account
Click Sign in and paste your API Key (
dk_live_…) — that's the only field. Zapier immediately verifies the key against your Docmill account, so typos surface right here, not at run time.
Step 2 — The Generate Document action's fields
| Field | Required | What goes in it |
|---|---|---|
| Template | Yes | A dropdown of the templates in your Docmill account plus the built-in starters:
starter:invoice, starter:quote,
starter:report, starter:certificate. |
| Data (JSON) | Yes | One JSON object with the values the template binds. Map fields from earlier steps straight into it — Zapier substitutes them before Docmill renders. |
| Output Format | No | PDF (default), DOCX, or XLSX — same template, three file types. |
The action outputs two fields for later steps: Generated File — a real file object Zapier passes to any attachment/upload input — and Format.
A worked Zap: Google Sheets row → invoice PDF → Gmail
Trigger — Google Sheets: New Spreadsheet Row
Say each row has columns Client, Item, Price, Email.
Action — Docmill: Generate Document
Template:
starter:invoice· Output Format: PDF · Data (JSON), with the sheet columns mapped in (shown here as{{Client}}-style placeholders):{ "client": { "name": "{{Client}}" }, "items": [ { "description": "{{Item}}", "quantity": 1, "unitPrice": {{Price}} } ], "total": {{Price}} }Keep mapped text values inside quotes and numbers bare — the whole box must remain valid JSON after substitution.
Action — Gmail: Send Email
Set Attachment to the Generated File field from the Docmill step and To to the row's Email column. The same Generated File field also plugs into Google Drive's Upload File, Dropbox, Slack file uploads, and any other file input.
Test the Zap: Zapier renders a real document during the test, so you can open the PDF and check the layout before turning the Zap on.
What the action does under the hood
One authenticated POST that returns the file itself; Zapier stores it and hands later steps a file reference. If you ever need the same thing outside Zapier (a Code step, a script, another tool), it's this:
# one POST, one invoice curl https://api.docmill.io/v1/documents \ -H "Authorization: Bearer dk_live_…" \ -H "Content-Type: application/json" \ -d '{ "template_id": "starter:invoice", "data": { "client": {"name": "Northwind Traders"}, "items": [{"description": "Design sprint", "quantity": 1, "unitPrice": 4800}], "total": 4800 }, "output": "pdf" }' --output invoice.pdf # → %PDF-1.7 …
Making your own template (AI prompt-to-template)
The starters get you moving, but real documents carry your logo, your columns, your terms. Describe the document once in plain language and Docmill drafts a reusable template, saved to your account:
curl https://api.docmill.io/v1/templates/generate \ -H "Authorization: Bearer dk_live_…" \ -H "Content-Type: application/json" \ -d '{ "prompt": "An invoice for a design studio with line items, 8% tax, EU VAT number, 30-day payment terms." }' # → template id + sample data showing exactly which fields to send
The new template then appears in the Zapier Template dropdown on the next refresh — pick it and map your fields to the sample data's shape. (The n8n node also exposes this as a built-in Generate Template (AI) operation, if you prefer doing it from a workflow — see the n8n guide.)
Troubleshooting
| Symptom | Cause & fix |
|---|---|
401 — invalid or missing API key |
The connected account's key is wrong or revoked. Reconnect the Docmill account in the Zap editor with a fresh key from docmill.io. |
429 — monthly quota reached |
You've used all documents on your plan this month (50 on Free). Upgrade at docmill.io/#pricing — each generated file meters as exactly one document. |
| "Data must be valid JSON" | A mapped field broke the JSON — usually an unquoted text value or a value containing a stray quote. Wrap text mappings in quotes and re-test the step. |
422 — render error |
The JSON is valid but doesn't match the template's fields. Check the sample data for the template you selected. |
| Attachment arrives as text, not a file | Map the Generated File output field, not the Format field or the raw step output, into the attachment input. |
Ready to add the document step?
Free tier: 50 documents/month, watermarked. Then $19/1,000 · $49/5,000 · $99/15,000 documents per month.