Invoice Line Items

Individual charges on an invoice with source tracking

Invoice Line Items represent individual charges on an invoice. Each line item tracks where it came from (its source), enabling accurate revenue attribution and audit trails.

What is a Line Item?

A line item is a single entry on an invoice that describes a specific charge. Each line item has:

  • Description - What the charge is for
  • Amount - How much is being charged
  • Quantity - Number of units
  • Source Type - Where the line item originated
  • Source Reference - Link to the originating entity

Source Types

Line items can originate from different sources, tracked by the source_type field:

Source TypeDescriptionWhen Used
priceFrom a product price in your catalogManual invoices referencing products
subscription_itemFrom a subscription itemSubscription invoices
order_line_itemFrom an orderOrder invoices
adjustmentManual adjustment or custom chargeCredits, discounts, corrections, custom fees

Line Item Fields

FieldTypeDescription
descriptionstringHuman-readable description of the charge
amount_minorintegerUnit price in minor units (cents)
quantityintegerNumber of units
total_minorintegeramount_minor × quantity
source_typeenumprice, subscription_item, order_line_item, adjustment
source_idstringID of the source entity
tax_amount_minorintegerTax amount for this line item
period_startdatetimeBilling period start (subscriptions)
period_enddatetimeBilling period end (subscriptions)

Adding Line Items

From a Product Price

// Add a line item from your product catalog
await client.invoices.addLineItem('inv_xxxxxxxx', {
  priceId: 'price_xxxxxxxx',
  quantity: 2,
});
// Creates line item with source_type: 'price'

Custom Line Item (Adjustment)

// Add a custom charge
await client.invoices.addLineItem('inv_xxxxxxxx', {
  description: 'Rush delivery fee',
  amountMinor: 5000, // $50.00
  quantity: 1,
});
// Creates line item with source_type: 'adjustment'

Credit / Discount Line Item

// Add a credit (negative amount)
await client.invoices.addLineItem('inv_xxxxxxxx', {
  description: 'Loyalty discount - 10%',
  amountMinor: -2500, // -$25.00 credit
  quantity: 1,
});

Automatic Line Items

Some line items are created automatically:

Subscription Renewals

When a subscription renews, line items are automatically created from each subscription item. The period_start and period_end fields indicate the billing period covered.

Checkout Completions

When a customer completes checkout, order line items become invoice line items with source_type: order_line_item.

Prorations

When a subscription changes mid-cycle, prorated adjustments are added as line items to credit unused time or charge for upgrades.

Why Source Tracking Matters

1.
Revenue Attribution

Know exactly which products and subscriptions are generating revenue

2.
Audit Trail

Trace any charge back to its origin for compliance and reconciliation

3.
Refund Processing

Refund specific line items rather than entire invoices

4.
Reporting

Generate accurate reports by product, subscription, or customer

Line items cannot be modified after an invoice is finalized. To make changes, void the invoice and create a new one.

Related