Doc2api

Use case

Generate invoice PDFs from JSON

Your app knows what the customer owes. Turning that into a document people will accept means laying out a header, a line-item table that grows with the order, totals that add up, and dates in a format the recipient's accounts team recognises — and then keeping it right forever.

Read the API docs
A invoice produced by this template
The invoice template, rendered from the payload beside it. Yours to edit once you open it.

What you send

This is the template's own sample data — the document on the left was drawn from exactly this.

{
  "data": {
    "invoice_ref": "INV-0042",
    "issued_on": "1 August 2026",
    "due_on": "31 August 2026",
    "company": {
      "name": "Northgate Studio",
      "address": "14 Bridge Street\nLeeds LS1 4DA"
    },
    "customer": {
      "name": "Acme Ltd",
      "address": "9 Queen Square\nBristol BS1 4ND"
    },
    "line_items": [
      {
        "description": "Consulting — discovery",
        "qty": 3,
        "unit_price": 450
      },
      {
        "description": "Implementation",
        "qty": 1,
        "unit_price": 4800
      },
      {
        "description": "Support retainer",
        "qty": 2,
        "unit_price": 300
      }
    ],
    "notes": "Payment within 30 days. Late payments accrue 2% monthly."
  }
}

POST it to your document's endpoint with your API key. The reply is JSON carrying a signed pdf_url — a link rather than the bytes, because a base64 document breaks receivers sitting behind a default body limit.

curl -X POST https://www.doc2api.co/api/v1/documents/<ID>/render \
  -H "X-Api-Key: d2a_live_…" \
  -H "Content-Type: application/json" \
  -d @payload.json
# → { "pdf_url": "https://…", "pdf_bytes": 17185, "sha256": "…",
#     "pdf_url_expires_at": "…" }

What the template already does

  • A line-item table that repeats over your array — its rows are "{{line_items}}", however many there are
  • Row amounts computed in the document as qty × unit price, and a column total summed for you
  • Currency formatting from one setting — symbol, code and locale
  • Issue and due dates, company and customer address blocks, and a payment-terms note
  • A running header on every page, and page numbers
  • Elements that disappear when their value is absent, so an empty note leaves no gap

And what you can add in the designer

Not in the starting template — a few clicks once it is open.

  • Your logo, and a brand colour and type scale for the whole document
  • A QR code linking to a payment page
  • A DRAFT or PAID watermark across every page

The totals are not your problem

Send quantities and unit prices; the row amounts and the invoice total are expressions evaluated when the PDF is drawn. Nothing to keep in step between your database and the document, and no rounding that disagrees with your ledger because it was computed twice.

Already have a PDF you have to use?

Designing from a template is one of the three things Doc2api does. If you were handed a form you cannot redraw — a claim form, a government return, a contract in someone else's house style — upload it instead and we read its fields into a JSON schema. Or paste your own HTML into the designer and we render that.

Open it and see for yourself

The template opens in the editor, filled with the sample data above, with a live endpoint and an API key. No account, nothing to cancel — and the first 100 test fills each month are free.