Download invoice as PDF
https://app.speybooks.com/api/v1/invoice-pdf/{id}/pdfGenerate and download an invoice as a PDF file. This is a multi-step operation:
- Validate the prefixed invoice ID (
inv_*) - Fetch invoice with contact details (name, email, phone, VAT number, full address) filtered by
organisation_id - Fetch invoice line items ordered by
sort_order - Fetch organisation details (name, email, phone, website, VAT number, company number, full address)
- Assemble data structures for the PDF service — all monetary values are passed as strings for precise rendering
- Generate PDF via
generateInvoicePDF()service - Write
INVOICE_PDF_DOWNLOADEDaudit log entry - Return binary PDF with appropriate headers
Authentication
Requires a valid JWT. The authenticated user must belong to the organisation that owns the invoice. Multi-tenancy is enforced via organisation_id filtering on the query.
Response Format
Unlike other SpeyBooks endpoints, this returns a binary PDF rather than a JSON envelope:
Content-Type: application/pdfContent-Disposition: attachment; filename="ST-2026-0001.pdf"Content-Lengthheader set to buffer size
The filename is derived from the invoice number with non-alphanumeric characters (except hyphens) replaced by underscores.
PDF Content
The rendered PDF includes:
- Organisation header (name, address, VAT/company number)
- Contact details (name, address, VAT number)
- Invoice metadata (number, issue date, due date, status)
- Line item table (description, quantity, unit price, VAT rate, VAT amount, line total)
- Financial summary (subtotal, VAT amount, total, amount paid)
- Notes and terms sections (if populated)
Side Effects
- Audit log —
INVOICE_PDF_DOWNLOADEDentry withinvoiceNumberin details, includes IP address and user agent - No state mutation — downloading a PDF does not change invoice status
Caching
PDFs are generated on every request — there is no server-side caching. Each download triggers a fresh render from current database state, ensuring the PDF always reflects the latest invoice data.
Error responses:
400 { code: "invalid_id" }— malformed or wrong-prefix ID404 { code: "not_found" }— invoice does not exist or belongs to another organisation
curl tip: Use -OJ to save with the server-provided filename, or -o invoice.pdf to specify your own.
Path parameters
id string required