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. The bigger your HTML, the more you save.

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 sizeJust the variablesThe full HTML, every time
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; values are plain strings)

// Step 2: Generate a PDF by passing variables
const res = await fetch("/api/pdf/generate-from-template", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    template: "invoice",
    variables: {
      customer: "Acme Corp",
      total: "12,980",
    },
  }),
});

Wire it into your workflow

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

Powered by FUNBREW PDF