Generate receipts from HTML, in one API call
receipt PDF API
The second a payment succeeds, your customer expects a receipt. Wire a single render call into your Stripe webhook or checkout success handler and hand back a clean, branded PDF receipt in one request — no template engine to host, no PDF library to wrestle.
No credit card · 25 free credits to start
OVERVIEW
What is the receipt PDF API?
The receipt PDF API is an HTTP endpoint that turns a successful payment into a branded PDF receipt in one request. You POST the payment details as JSON to /v1/render — amount, date, customer, card — and get print-ready PDF bytes back in about 400ms, ready to email or return straight from your Stripe webhook.
A receipt is proof a payment cleared, and customers expect it the moment they pay — not in tomorrow’s batch. That makes timing the whole game: the receipt should be generated on the same event that confirmed the charge, so it lands in the confirmation email or the success page while the purchase is still on screen. It also has to look like you, because a generic library-default receipt undercuts the polish of everything that came before it in your checkout.
Generating receipts from HTML is the clean way to hit both. You design the receipt once as HTML and CSS — the amount, the masked card, the plan name, your logo and accent colour — and let the data fill in per payment. Because the receipt is short, it usually wants a smaller page than an invoice: set A5 or a custom size and margin per request. The merge engine fills {{ placeholders }} from your JSON, so a typical receipt needs no repeating rows at all.
The natural place to call it is your Stripe checkout.session.completed webhook (or any payment-success handler). You already have the amount, customer and line in the event — POST them to /v1/render and the receipt PDF comes back in roughly 400 milliseconds, fast enough to attach to the receipt email inside the same handler. Nothing is stored on our side: the bytes are streamed back and discarded, so you decide whether to email, archive or stream them. When the same order also needs a tax document, you can issue the matching invoice PDF from the same data.
THE PROBLEM
Generating receipts in-house is a two-week project you'll maintain forever
Turning HTML into a clean PDF yourself means running headless Chrome and everything around it. Here's the work you skip.
- Bolting a PDF library onto your payment webhook and maintaining it as the layout evolves.
- Matching the receipt to your brand when a templating library only gives you a generic look.
- Re-running a headless browser per receipt and watching memory climb under load.
- Storing generated receipts somewhere when the customer just needs the bytes back.
THE SOLUTION
From your data to a finished receipt, in one request
Store your receipts layout once, then POST the values to /v1/render and get print-ready application/pdfbytes back in roughly 400ms. Merge is plain{{ }} /{{{ }}} and dotted keys — no template loops to learn, so repeating rows are rendered to HTML and dropped in through one raw placeholder.
- Fires inside your webhook. One synchronous call returns the PDF bytes — generate the receipt in the same handler that confirms the payment.
- Any size, including A5. Receipts often want a smaller page — set A5, Letter or a custom size and margins per request.
- Never stored. The receipt is streamed back in the response and discarded on our side — you decide whether to email, store or stream it.
// Inside your Stripe `checkout.session.completed` handler:
const res = await fetch("https://api.pdfinvoiceapi.com/v1/render", {
method: "POST",
headers: {
Authorization: "Bearer sk_live_...",
"Content-Type": "application/json",
},
body: JSON.stringify({
template: "tpl_receipt",
data: {
receiptNo: "RCPT-3391",
paidAt: "2026-06-24",
customer: { name: "Jordan Lee" },
plan: "Pro plan",
amount: "€38.00",
card: "Visa ending 4242",
},
pdf: { format: "A5", margin: "12mm", printBackground: true },
}),
});
const pdf = Buffer.from(await res.arrayBuffer());
// → email it, or return it from your endpoint as application/pdfHOW TO
How to generate receipts from HTML
- 01
Design the receipt in HTML
Build the receipt as plain HTML and CSS — receipt number, paid date, amount, masked card and your logo. Mark the dynamic values with {{ placeholders }}. Receipts are short, so a single page with no repeating rows usually covers it.
- 02
Store it once as a template
Save the layout in the dashboard for a tpl_ id. Every receipt is then just a small JSON payload, and the look stays identical across every customer and every charge.
- 03
Call /v1/render from your payment webhook
Inside your Stripe checkout.session.completed handler (or any success handler), POST the template id plus the payment data with your API key. Pick a compact page like A5 in the pdf options if you want a receipt-sized document.
- 04
Stream the PDF back
The response body is the receipt PDF. Attach it to the confirmation email or return it from your endpoint as application/pdf — all inside the request that confirmed the payment, no background job.
WHAT YOU GET
The features that matter for receipts
Fires inside your webhook
One synchronous call returns the PDF bytes — generate the receipt in the same handler that confirms the payment.
Any size, including A5
Receipts often want a smaller page — set A5, Letter or a custom size and margins per request.
Never stored
The receipt is streamed back in the response and discarded on our side — you decide whether to email, store or stream it.
FAQ
Receipts on PDFInvoiceAPI — common questions
- How do I generate a receipt PDF from HTML?
- Design the receipt as HTML/CSS with {{ placeholders }}, store it once as a template, then POST the template id and a JSON data object to /v1/render. You get application/pdf bytes back in one synchronous call — no SDK to install and no browser to run yourself.
- Can I trigger it from a Stripe webhook?
- Yes — that is the intended pattern. Inside your checkout.session.completed (or payment_intent.succeeded) handler you already have the amount, customer and line, so you POST them to /v1/render and the receipt comes back in roughly 400ms, fast enough to attach to the receipt email in the same handler.
- Can I render receipts on a smaller page like A5?
- Yes. Set "format": "A5", Letter, or a custom width and height in the pdf options, with your own margins, per request. Receipts usually read better on a compact page than a full A4 sheet.
- Can I use my own logo, fonts and brand colours?
- Always — the PDF is your own HTML/CSS, so the receipt matches the rest of your checkout. Drive the logo and accent colour from data, or save a brand kit and {{brand.logo}} / {{brand.color}} fill in automatically.
- Are my receipts stored on your servers?
- No. Each receipt is streamed back in the response and discarded — the content is processed transiently and never persisted on our side, so you decide whether to email, archive or stream it.
- How fast is receipt rendering?
- A typical receipt comes back in roughly 400 milliseconds — fast enough to generate it synchronously inside the webhook that confirmed the payment, instead of queuing a background job.
RELATED
Same API, more documents
The render call that makes receipts makes these too — one endpoint for everything your product hands a customer.
Invoices
Turn order data into a branded, VAT-ready invoice PDF in one call.
View use case →Order confirmations
Attach a branded, itemised order confirmation PDF to the order-placed email.
View use case →Credit notes
Issue a branded, VAT-correct credit note that references the original invoice.
View use case →Render your first receipt PDF in the next five minutes
One endpoint, real PDFs, 25 free credits to start. No credit card to begin.
Cancel anytime · no long-term contract