Receipt PDF generation API

Generate a receipt PDF from a template and your order JSON in a single call. Docweave binds the amount, payment method, and customer details into an HTML receipt template and returns a PDF you can email or store the instant a charge succeeds.

Generate a receipt 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>Receipt {{ number }}</h1><p>Paid by {{ customer }} on {{ paid_date }}</p><p>Amount: {{ amount }}</p>",
      "data": {
        "number": "RCPT-1188",
        "customer": "Acme Inc.",
        "paid_date": "2026-07-14",
        "amount": "$49.00"
      }
    },
    "options": { "format": "A4" },
    "idempotencyKey": "rcpt-1188"
  }'

…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>Receipt {{ number }}</h1><p>Paid by {{ customer }} on {{ paid_date }}</p><p>Amount: {{ amount }}</p>",
    data: { number: "RCPT-1188", customer: "Acme Inc.", paid_date: "2026-07-14", amount: "$49.00" }
  },
  outputPath: "/tmp/receipt-1188.pdf"
})

Template example

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

<article style="font-family: sans-serif; max-width: 400px;">
  <h1>Receipt {{ number }}</h1>
  <p>Merchant: {{ merchant }}</p>
  <p>Paid by: {{ customer }}</p>
  <p>Date: {{ paid_date }}</p>
  <p>Payment method: {{ method }}</p>

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

  <p style="text-align:right;"><strong>Amount paid: {{ amount }}</strong></p>
  <p style="font-size:12px; color:#666;">Transaction {{ transaction_id }}</p>
</article>

FAQ

How do I generate a receipt PDF from the API?

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

Can I generate a receipt PDF right after a payment succeeds?

Yes. Call /api/v1/pdf from your payment webhook handler with the charge details as data, and store or email the returned PDF. The call is synchronous, so you get the receipt back in the same request.

How do I stop a webhook retry from creating duplicate receipts?

Pass an idempotencyKey such as the transaction or receipt number. If the webhook fires twice, the repeat request returns the stored PDF instead of generating a new one, so you never issue duplicate receipts.

How is receipt PDF generation priced?

Pricing is per document, not per page. Each receipt you generate counts as one document regardless of how many line items it contains.

Ready to generate receipt PDFs in production?

Get an API key