Download invoice PDF

Downloads the PDF representation of an invoice. If the PDF has not been generated yet, it will be created on-demand.

GET /api/v1/invoices/{uuid}/pdf

Headers

NameTypeRequiredDescription
AuthorizationstringYesBearer token for authentication
X-CompanystringYesCompany UUID to scope the request

Path parameters

NameTypeRequiredDescription
uuidstringYesInvoice UUID

Request

curl https://api.storno.ro/api/v1/invoices/7c9e6679-7425-40de-944b-e07fc1f90ae7/pdf \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "X-Company: 550e8400-e29b-41d4-a716-446655440000" \
  -o invoice.pdf

Response

Returns the PDF file with Content-Type: application/pdf.

Response headers

HeaderValueDescription
Content-Typeapplication/pdfPDF content type
Content-Dispositioninline; filename="FAC-2024-001.pdf"Display inline or download
Content-Length{size}File size in bytes
X-Generated-At2024-02-15T09:00:00ZWhen the PDF was generated

PDF features

The generated PDF includes:

Header section

  • Company logo (if configured)
  • Supplier details (name, CIF, registration, address)
  • Invoice number and issue date
  • QR code for quick scanning (optional)

Client section

  • Client/customer details
  • Billing address
  • Tax identification numbers

Line items table

  • Description, quantity, unit price
  • Unit of measure
  • VAT rate and amount
  • Line totals
  • Discount information (if applicable)

Totals section

  • Subtotal (before VAT)
  • VAT breakdown by rate
  • Total amount due
  • Amount paid (if any)
  • Balance remaining
  • Payment terms and due date
  • Bank account details
  • Notes and mentions
  • Legal footer text
  • Page numbers

Customization options

PDF appearance can be customized in company settings:

  • Logo and branding colors
  • Template layout (classic, modern, minimal)
  • Font and font size
  • Show/hide optional fields
  • Custom footer text
  • Signature image

When is PDF generated

The PDF is generated automatically or on-demand:

  1. Automatic - When invoice is issued
  2. On-demand - First time this endpoint is called
  3. Regeneration - When invoice is updated and reissued

Performance

  • First generation: 1-3 seconds
  • Cached PDF: < 100ms
  • Complex invoices (50+ lines): 3-5 seconds

For large invoices, consider using asynchronous generation:

// Check if PDF exists
const invoice = await fetch('/api/v1/invoices/{uuid}').then(r => r.json());

if (invoice.pdfGenerated) {
  // Download immediately
  window.open('/api/v1/invoices/{uuid}/pdf', '_blank');
} else {
  // Show loading state and poll
  await generatePdf();
}

Error codes

CodeDescription
401Missing or invalid authentication token
403No access to company
404Invoice not found
422Invoice cannot be rendered as PDF (invalid data)
500PDF generation failed (temporary error)

Use cases

  • Email invoices to clients
  • Print physical copies
  • Archive for compliance
  • Client self-service portal
  • Attach to payment reminders
  • Accounting system integration