Invoice PDF generation API

Generate an invoice PDF from a template and your billing JSON in a single call. Docweave binds line items, totals, and customer details into an HTML invoice template and returns a ready-to-send PDF — no headless browser to run yourself.

Generate an invoice PDF via the API

POST your template and data to /api/v1/pdf:

curl https://docweave.dev/api/v1/pdf \
  -H "Authorization: Bearer dw_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "source": {
      "type": "template",
      "template": "<h1>Invoice {{ number }}</h1><p>Billed to {{ customer }}</p><p>Total due: {{ total }}</p>",
      "data": {
        "number": "INV-042",
        "customer": "Acme Inc.",
        "total": "$1,280.00"
      }
    },
    "options": { "format": "A4" },
    "idempotencyKey": "inv-042"
  }'

…or from an AI agent

Add the Docweave MCP server and your agent gets a generate_pdf tool — the same orchestration, no HTTP boilerplate:

// From an AI agent over MCP — no HTTP plumbing:
generate_pdf({
  source: {
    type: "template",
    template: "<h1>Invoice {{ number }}</h1><p>Billed to {{ customer }}</p><p>Total due: {{ total }}</p>",
    data: { number: "INV-042", customer: "Acme Inc.", total: "$1,280.00" }
  },
  outputPath: "/tmp/invoice-042.pdf"
})

Template example

Any HTML works as a template. Use {{ placeholders }} for the values you pass in data:

<article style="font-family: sans-serif;">
  <header style="display:flex; justify-content:space-between;">
    <h1>Invoice {{ number }}</h1>
    <div>Issued {{ issued_date }}</div>
  </header>

  <p>Billed to: {{ customer }}</p>

  <table style="width:100%; border-collapse:collapse;">
    {{{ line_items }}}
  </table>

  <p style="text-align:right;">Subtotal: {{ subtotal }}</p>
  <p style="text-align:right;">Tax: {{ tax }}</p>
  <p style="text-align:right;"><strong>Total due: {{ total }}</strong></p>
</article>

FAQ

How do I generate an invoice PDF from the API?

Send a POST to /api/v1/pdf with a source of type "template": pass your invoice HTML template and a data object with the number, customer, and totals. Docweave binds the JSON into the {{ placeholders }} and returns the invoice PDF.

Can I reuse the same invoice template across requests?

Yes. Send the template inline on each request, or store a template and reference it, then pass only the per-invoice JSON. The layout stays identical while the line items and totals change per call.

How do I avoid generating a duplicate invoice PDF?

Include an idempotencyKey (for example the invoice number). A repeat request with the same key returns the stored result instead of re-rendering or re-billing, so retries are always safe.

How is invoice PDF generation priced?

Pricing is per document, not per page. A one-page invoice and a multi-page invoice with many line items count the same, so a long itemized bill never costs extra.

Ready to generate invoice PDFs in production?

Get an API key