Skip to content

Invoicing

BoxBilling automatically generates invoices based on subscription billing periods. The invoice generation pipeline handles charge calculation, tax application, coupon discounts, wallet credit consumption, and progressive billing credits.

DRAFT → FINALIZED → PAID
↘ VOIDED
StatusDescription
draftEditable, not yet issued
finalizedIssued to customer, due for payment
paidFully settled
voidedCanceled after finalization
TypeDescription
subscriptionRegular periodic billing
add_onOne-time add-on charge
creditCredit adjustment
one_offManual one-time charge
progressive_billingMid-period usage threshold billing

Each invoice contains the following financial fields:

FieldDescription
subtotal_centsPre-tax amount
tax_amount_centsTotal tax
total_centsFinal amount including tax
prepaid_credit_amount_centsWallet credits applied
coupons_amount_centsCoupon discounts applied
progressive_billing_credit_amount_centsProgressive billing credits applied
currencyInvoice currency (default: USD)
billing_period_startStart of the billing period
billing_period_endEnd of the billing period
due_datePayment due date
issued_atWhen the invoice was issued
paid_atWhen the invoice was paid

When an invoice is generated for a subscription billing period, the system executes these steps:

For each charge on the subscription’s plan:

  • Aggregate usage via the appropriate billable metric
  • Apply the charge model calculator (standard, graduated, volume, etc.)
  • Apply min/max price capping if configured
  • Handle charge filters for segmented pricing

If the plan has minimum commitments and actual charges are below the minimum, a true-up fee is added for the difference.

Taxes are resolved hierarchically:

  1. Charge-level taxes (most specific)
  2. Plan-level taxes
  3. Customer-level taxes
  4. Organization-level defaults

Each fee gets individual AppliedTax records. Fee-level taxes are aggregated into the invoice tax_amount_cents.

Active coupons on the customer are applied:

  • Fixed amount — deducted directly, capped at remaining subtotal
  • Percentage — calculated as subtotal × rate / 100

Coupons are consumed based on their frequency:

  • once — terminated after single use
  • recurring — decremented per billing period
  • forever — never consumed

If the customer has active wallets, credits are consumed in priority order (lower priority number = consumed first). Wallet transactions and invoice settlements are recorded.

If progressive billing invoices were issued during the period, their total is credited on the final period invoice to prevent double-billing.

The generate_periodic_invoices task runs hourly and creates invoices for:

  • Active subscriptions whose billing period has ended (pay-in-arrear)
  • Active subscriptions whose billing period is starting (pay-in-advance)

Create invoices with custom line items that are not tied to a subscription:

Terminal window
POST /v1/invoices/one_off
{
"customer_id": "customer-uuid",
"currency": "USD",
"line_items": [
{
"description": "Consulting hours",
"quantity": 10,
"unit_price": 15000,
"charge_id": null,
"metric_code": null
}
],
"due_date": "2026-04-01T00:00:00Z",
"billing_entity_id": "entity-uuid"
}

Each line item includes:

FieldDescription
descriptionLine item description
quantityNumber of units
unit_pricePrice per unit
amountTotal amount (alternative to quantity × unit_price)
charge_idOptional reference to a charge
metric_codeOptional billable metric code

Preview an invoice for a subscription without persisting anything:

Terminal window
POST /v1/invoices/preview
{
"subscription_id": "subscription-uuid",
"billing_period_start": "2026-03-01T00:00:00Z",
"billing_period_end": "2026-04-01T00:00:00Z"
}

Only subscription_id is required — billing period boundaries are optional and default to the subscription’s current period.

Terminal window
POST /v1/invoices/{id}/finalize

Moves the invoice from draft to finalized. Applies wallet credits and sends an invoice.finalized webhook.

Terminal window
POST /v1/invoices/{id}/pay

Marks the invoice as paid. Sends an invoice.paid webhook.

Terminal window
POST /v1/invoices/{id}/void

Voids a finalized invoice. Sends an invoice.voided webhook.

Terminal window
DELETE /v1/invoices/{id}

Only draft invoices can be deleted.

Terminal window
PUT /v1/invoices/{id}

Updatable fields: status, due_date, issued_at, paid_at.

Terminal window
POST /v1/invoices/{id}/send_email

Sends the invoice to the customer via email.

Terminal window
POST /v1/invoices/{id}/send_reminder

Sends a payment reminder for an overdue invoice.

Terminal window
POST /v1/invoices/{id}/download_pdf # Download PDF
GET /v1/invoices/{id}/pdf_preview # Inline PDF preview
Terminal window
POST /v1/invoices/bulk_finalize

Finalize multiple draft invoices in one request.

Terminal window
POST /v1/invoices/bulk_void

Void multiple invoices in one request.

Fees are the individual line items on an invoice. Each fee represents a calculated charge:

Fee typeDescription
chargeUsage-based charge from a billable metric
subscriptionBase plan subscription fee
add_onOne-time add-on charge
creditCredit adjustment
commitmentMinimum commitment true-up

Each fee records:

FieldDescription
amount_centsPre-tax amount
taxes_amount_centsTax amount
total_amount_centsAmount + taxes
unitsUsage units consumed
events_countNumber of events
unit_amount_centsPrice per unit
payment_statuspending, succeeded, failed, refunded
descriptionFee description
metric_codeAssociated billable metric code
propertiesAdditional fee properties (JSON)

Each fee tracks its own payment status independently:

StatusDescription
pendingPayment not yet processed
succeededSuccessfully paid
failedPayment failed
refundedPayment was refunded
Terminal window
PUT /v1/fees/{id}

Updatable fields: payment_status, description, taxes_amount_cents.

Terminal window
POST /v1/events/estimate_fees

Estimate fees for a hypothetical event without persisting anything.

Invoices can be settled through multiple sources:

Settlement typeDescription
paymentDirect payment (Stripe, Adyen, etc.)
credit_noteApplied credit from a credit note
wallet_creditPrepaid wallet credits

Each settlement records: invoice_id, settlement_type, source_id (polymorphic reference), and amount_cents.

An invoice is automatically marked as paid when settlements equal or exceed the total.

Credit notes are issued against finalized invoices for adjustments, refunds, or corrections.

TypeDescription
creditCredit applied to future invoices
refundRefund to original payment method
offsetOffset against the invoice balance
FieldValuesDescription
statusdraft, finalizedOverall credit note status
credit_statusavailable, consumed, voidedCredit availability
refund_statuspending, succeeded, failedRefund processing state
ReasonDescription
duplicated_chargeDuplicate billing
product_unsatisfactoryProduct quality issue
order_changeOrder modification
order_cancellationOrder canceled
fraudulent_chargeFraudulent activity
otherOther reason
Terminal window
POST /v1/credit_notes
{
"invoice_id": "invoice-uuid",
"customer_id": "customer-uuid",
"credit_note_type": "credit",
"reason": "order_change",
"description": "Adjustment for plan change",
"credit_amount_cents": 500,
"refund_amount_cents": 0,
"items": [
{
"fee_id": "fee-uuid",
"amount_cents": 500
}
]
}
FieldDescription
credit_amount_centsAvailable credit amount
refund_amount_centsRefund amount
balance_amount_centsRemaining unused credit
total_amount_centsTotal credit note amount
taxes_amount_centsTax amount
currencyCredit note currency
OperationEndpointDescription
UpdatePUT /v1/credit_notes/{id}Update description, credit/refund amounts
FinalizePOST /v1/credit_notes/{id}/finalizeFinalize a draft credit note
VoidPOST /v1/credit_notes/{id}/voidVoid a credit note
Send emailPOST /v1/credit_notes/{id}/send_emailEmail credit note to customer
Download PDFPOST /v1/credit_notes/{id}/download_pdfDownload credit note as PDF
  1. Create (draft) → FinalizeApply to invoice or Void
  2. Credit notes have a balance_amount_cents that decreases as credits are applied
  3. Applying credit to an invoice creates an InvoiceSettlement record
EventTrigger
invoice.createdInvoice generated
invoice.finalizedInvoice finalized
invoice.paidInvoice fully paid
invoice.voidedInvoice voided
MethodPathDescription
GET/v1/invoicesList invoices
GET/v1/invoices/{id}Get invoice details
PUT/v1/invoices/{id}Update a draft invoice
DELETE/v1/invoices/{id}Delete a draft invoice
POST/v1/invoices/{id}/finalizeFinalize an invoice
POST/v1/invoices/{id}/payMark as paid
POST/v1/invoices/{id}/voidVoid an invoice
POST/v1/invoices/{id}/send_emailSend invoice email
POST/v1/invoices/{id}/send_reminderSend payment reminder
POST/v1/invoices/{id}/download_pdfDownload invoice PDF
GET/v1/invoices/{id}/pdf_previewPreview invoice PDF inline
GET/v1/invoices/{id}/settlementsList settlements
POST/v1/invoices/one_offCreate a one-off invoice
POST/v1/invoices/previewPreview invoice
POST/v1/invoices/bulk_finalizeBulk finalize drafts
POST/v1/invoices/bulk_voidBulk void invoices
MethodPathDescription
GET/v1/feesList fees
GET/v1/fees/{id}Get fee details
PUT/v1/fees/{id}Update a fee
MethodPathDescription
GET/v1/credit_notesList credit notes
GET/v1/credit_notes/{id}Get credit note
POST/v1/credit_notesCreate a credit note
PUT/v1/credit_notes/{id}Update a credit note
POST/v1/credit_notes/{id}/finalizeFinalize a credit note
POST/v1/credit_notes/{id}/voidVoid a credit note
POST/v1/credit_notes/{id}/send_emailSend credit note email
POST/v1/credit_notes/{id}/download_pdfDownload credit note PDF