POST /api/pdf/generate-from-template

Centralize the design, send only variables

Register your HTML layout via dashboard or API. At generation time, send just the template slug and variables — every PDF comes out with the same layout. Perfect for invoices, certificates, and contracts.

Key points

1

Tiny payloads

Send a variables object instead of full HTML on every request. Payload size drops by 10×–100×.

2

Design changes in one place

Update the template once and every subsequent generation reflects it. No client redeploy needed.

3

Editable from the dashboard

Syntax highlighting and live preview in the editor — non-engineers can update copy and layout safely.

With this feature vs. without

Use templatesSend raw HTML each time
Request sizeHundreds of bytes – a few KBTens to hundreds of KB
Design changeOne update in the dashboardRedeploy client code
Best forRecurring layouts (invoices, certs)One-off dynamic reports
Non-engineer editsYes, via dashboardNo, requires a code change

How it looks in code

// Step 1: Register a template once via the dashboard or API
// (HTML body uses {{variable}} placeholders)

// Step 2: Generate a PDF by passing variables
const res = await fetch("/api/pdf/generate-from-template", {
  method: "POST",
  headers: { "Authorization": `Bearer ${API_KEY}` },
  body: JSON.stringify({
    template: "invoice",
    variables: {
      customer: "Acme Corp",
      total: 12980,
      items: [{ name: "Pro plan", amount: 12980 }],
    },
  }),
});

Wire it into your workflow

Validate the integration on the Free plan, then scale up when you're ready.

Powered by FUNBREW PDF