Skip to main content
POST
/
v1
/
invoices
/
{id}
/
finalize
curl -X POST "https://api.flexprice.io/v1/invoices/inv_1234567890/finalize" \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "message": "invoice finalized successfully"
}

Path Parameters

id
string
required
The unique identifier of the invoice to finalize

What Happens When You Finalize an Invoice

Finalizing an invoice performs the following actions:
  1. Locks the invoice: The invoice status changes from DRAFT to FINALIZED
  2. Freezes line items: No further modifications can be made to line items or amounts
  3. Generates invoice number: A human-readable invoice number is assigned (if not already present)
  4. Sets finalization timestamp: The finalized_at timestamp is recorded
  5. Enables payment: The invoice becomes eligible for payment processing

Invoice Finalization Workflow

Once an invoice is finalized, it cannot be edited. Only payment status can change. If you need to modify a finalized invoice, you must void it and create a new one.
Finalization is irreversible. Ensure all line items, amounts, and customer information are correct before finalizing.

Response

message
string
Confirmation message indicating successful finalization
curl -X POST "https://api.flexprice.io/v1/invoices/inv_1234567890/finalize" \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "message": "invoice finalized successfully"
}

After Finalization

Once an invoice is finalized, you can:
  • Collect payment: Use the Attempt Payment endpoint to charge wallet credits
  • Update payment status: Mark the invoice as paid via payment gateway integration
  • Void the invoice: If needed, use the Void Invoice endpoint
  • Send to customer: Trigger invoice communication via webhook or email
  • Download PDF: Generate and retrieve the invoice PDF

Common Use Cases

For one-time invoices or complex billing scenarios, you may want to review draft invoices before finalizing them:
  1. Create invoice in draft status
  2. Review line items and amounts
  3. Make any necessary adjustments
  4. Finalize when ready
For automated subscription billing, invoices are typically finalized automatically:
  1. Billing cycle triggers invoice generation
  2. Invoice created and finalized in one step
  3. Payment collected automatically (if configured)
For metered billing, finalization marks the end of the usage collection period:
  1. Usage accumulated during billing period
  2. At period end, create draft invoice
  3. Verify usage calculations
  4. Finalize to lock usage amounts