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 Type | Description | When Used |
|---|---|---|
price | From a product price in your catalog | Manual invoices referencing products |
subscription_item | From a subscription item | Subscription invoices |
order_line_item | From an order | Order invoices |
adjustment | Manual adjustment or custom charge | Credits, discounts, corrections, custom fees |
Line Item Fields
| Field | Type | Description |
|---|---|---|
description | string | Human-readable description of the charge |
amount_minor | integer | Unit price in minor units (cents) |
quantity | integer | Number of units |
total_minor | integer | amount_minor × quantity |
source_type | enum | price, subscription_item, order_line_item, adjustment |
source_id | string | ID of the source entity |
tax_amount_minor | integer | Tax amount for this line item |
period_start | datetime | Billing period start (subscriptions) |
period_end | datetime | Billing 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
Know exactly which products and subscriptions are generating revenue
Trace any charge back to its origin for compliance and reconciliation
Refund specific line items rather than entire invoices
Generate accurate reports by product, subscription, or customer