Skip to main content

Generate invoice PDF

Generates a PDF document from an invoice. This endpoint is planned for future implementation.
curl -X POST https://your-domain.com/api/pdf \
  -H "Content-Type: application/json" \
  -d '{
    "invoiceId": "inv_123",
    "fileName": "invoice-march-2026.pdf"
  }'

Body parameters

invoiceId
string
required
The unique identifier of the invoice to convert to PDF
fileName
string
Optional custom filename for the generated PDF. Defaults to invoice-{invoiceId}.pdf

Response

message
string
Information about the endpoint status
invoiceId
string
The invoice ID that was requested
fileName
string
The filename for the generated PDF
nextSteps
array
Implementation steps for developers
501 - Not implemented
{
  "message": "PDF generation not yet implemented",
  "invoiceId": "inv_123",
  "fileName": "invoice-march-2026.pdf",
  "nextSteps": [
    "1. Choose a PDF library (pdfkit, html2pdf, jsPDF, or puppeteer)",
    "2. Install the library: npm install <library>",
    "3. Create a template for the invoice layout",
    "4. Generate PDF from invoice data",
    "5. Return PDF file to client"
  ]
}

Errors

400 - Invoice ID required
{
  "error": "Invoice ID is required"
}
500 - Internal server error
{
  "error": "Failed to generate PDF"
}

Implementation notes

This endpoint is currently not implemented and returns a 501 Not Implemented status. The following PDF libraries are recommended for implementation:
  • pdfkit - Low-level PDF generation with full control
  • html2pdf.js - Convert HTML to PDF (client-side)
  • jsPDF - JavaScript PDF generation library
  • puppeteer - Headless Chrome for complex PDF rendering
The implementation should:
  1. Fetch the invoice data from your database or storage
  2. Generate a PDF using your chosen library with proper formatting
  3. Return the PDF as either a file download or base64-encoded string
  4. Handle errors appropriately
See the source code at app/api/pdf/route.ts:14-55 for the current implementation.

Build docs developers (and LLMs) love