Generate invoices with correct numbers and tax lines

An invoice is a legal record that happens to be a PDF. Get the number, the tax and the stored copy right, and the rendering is the easy part.

The Invoice Generator turns a JSON body into a finished PDF in one call. That part takes ten minutes to wire up. The rest of this lesson is about the three things that make invoicing hard regardless of how the PDF is drawn: every invoice needs a unique number from an unbroken sequence, the tax on it has to be right and reproducible, and the copy you sent has to exist, unchanged, when someone asks for it years later.

The design principle that holds it together: your database is the invoice; the PDF is a rendering of it. You decide the number, compute the totals and store them before you ever call the API. The API draws what you decided.

What the generator does, and what it assumes

It is a POST endpoint costing 20 credits per call. Required fields are the invoice number, both parties' name, street, city, state and ZIP, and an items array of { qty, description, unit_price }. Optional fields include date, dueDate, paymentTerms, job, discount, salesTax, currency and logoURL. The response is small: pdfName, expires (milliseconds) and a signed downloadURL. When we called it, the link expired about 48 hours later.

Notice what is not in the response: the subtotal, tax or total. The API computes them to draw the PDF but does not hand them back. That alone is a good reason to compute them yourself.

We generated a few invoices and read the PDFs back to pin down the behaviour you cannot see in the reference:

InputWhat the PDF showed
discount: 10 on a 59.97 subtotalDiscount: 10.00. It is a flat amount, not a percentage
salesTax: 8.25Sales Tax: 4.12, which is 8.25% of 49.97, the subtotal after the discount, rounded to the cent
paymentTerms omittedDue on Receipt
dueDate omittedThe invoice date
job omittedService Rendered
currency: "EUR" or "USD"Plain numbers with two decimals; the currency does not appear on the page

Two practical consequences. First, if you bill in more than one currency, the reader of the PDF cannot tell which, so say it in a field that is printed, for example paymentTerms: "Net 30 - amounts in EUR". Second, the address fields are US-shaped: from_state and to_state allow at most two characters, and the ZIP fields need at least five. That fits US billing well. For EU customers who need VAT numbers, a VAT breakdown or reverse-charge wording on the page, build the invoice as HTML and render it with HTML to PDF instead; the Generate PDFs course covers that route.

Try it liveInvoice Generator20 credits
POSThttps://api.apiverve.com/v1/invoicegenerator
curl -X POST "https://api.apiverve.com/v1/invoicegenerator" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"invoiceNumber":"INV-2026-000042","date":"2026-10-22","dueDate":"2026-11-21","paymentTerms":"Net 30","from_name":"Northwind Studio","from_street":"12 Harbor Rd","from_city":"Austin","from_state":"TX","from_zip":"78701","to_name":"Contoso Ltd","to_street":"400 Pine St","to_city":"Dallas","to_state":"TX","to_zip":"75201","items":[{"qty":10,"description":"Design hours","unit_price":85},{"qty":1,"description":"Hosting setup","unit_price":150}],"salesTax":6.25}'
Sign in or create a free account to run this with your own key.

Open downloadURL: subtotal 1000.00, tax 62.50, total 1062.50. None of those numbers are in the JSON.

Check yourself

An invoice has items totalling 200.00, discount: 20 and salesTax: 10. What total does the generated PDF show?

Answer the check above to continue.

Run every example on your own key. Free plan, no card.

Scaling up?

Volume pricing, custom SLAs, and dedicated support for high-traffic teams.

Contact sales