Printmint.

Generate invoice PDFs from JSON

Updated

Your app already has everything an invoice needs: who's paying, what for and how much. Printmint's built-in invoice template turns that data into a PDF, so you don't have to design and maintain invoice HTML.

1. Send the invoice data

curl -X POST https://api-printmint.plxi.us/v1/pdf/template \
  -H "X-API-Key: $PRINTMINT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "invoice",
    "inline": true,
    "data": {
      "number": "INV-2026-0142",
      "issued": "2026-10-31",
      "due": "2026-11-30",
      "currency": "USD",
      "seller": { "name": "Northwind Studio", "address": ["18 Harbour Street", "Portland, OR 97204"], "email": "[email protected]" },
      "customer": { "name": "Acme Robotics Inc.", "address": ["400 Market Street", "San Francisco, CA 94105"] },
      "items": [
        { "description": "Website redesign", "quantity": 1, "unit_price": 2400 },
        { "description": "Design system components", "quantity": 12, "unit_price": 150 }
      ],
      "tax_rate": 0.0875,
      "notes": "Please pay within 30 days."
    }
  }'

The template works out each line's amount, the subtotal, the tax and the total. currency sets the symbol and decimal places: USD prints $4,200.00, EUR €4,200.00 and JPY ¥4,200.

2. What you can put in it

Field What it is
number, issued Invoice number and issue date (YYYY-MM-DD)
due Due date (optional)
currency ISO code such as USD, EUR, GBP
seller, customer name, address (a list of lines), email; the seller can have tax_id
items description, quantity, unit_price
tax_rate A fraction: 0.2 for 20% (optional)
payment Payment details in order: [{"label": "IBAN", "value": "…"}] (optional)
notes Free text at the bottom (optional)
accent The accent colour, such as #2563eb (optional)

POST /v1/templates/list returns the same list for every built-in template, with sample data you can send as it is.

3. If a field is missing

If the data lacks a field the template prints, the call fails with a 400 that names the line, and isn't charged:

{ "error": "missing_field", "message": "a field the template uses is missing from \"data\" (line 54).", "line": 54 }

That's on purpose: an invoice with a blank customer name is worse than no invoice.

4. Your own design

When the built-in layout isn't yours, save your own template once and print it by its id. Templates are HTML with Jinja tags, and every value is escaped:

curl -X POST https://api-printmint.plxi.us/v1/templates/create \
  -H "X-API-Key: $PRINTMINT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Our invoice",
    "html": "<h1>Invoice {{ number }}</h1>{% for item in items %}<p>{{ item.description }}: {{ (item.quantity * item.unit_price)|money(currency) }}</p>{% endfor %}",
    "sample": { "number": "1", "currency": "EUR", "items": [{ "description": "Consulting", "quantity": 2, "unit_price": 90 }] }
  }'

Then send "template": "<the id it returned>" with your data. Saving, listing and deleting templates is free; each PDF costs one credit.

Receipts, certificates and labels

The same call works with receipt (an 80 mm till receipt), certificate, report (with page numbers in the footer) and shipping_label (4 × 6 inches).