Invoice summary itemsBeta
Learn how to use the Invoicing APIs to summarize and hide invoice line items.
This guide describes how to use the underlying API (Invoice summary items) that enables the grouping of invoice line items. With the summary item feature, you can group invoice line items with the API.
If you want to categorize and display invoice line items dynamically, see Group invoice line items.
Create summary items
For an existing draft invoice, create an invoice summary item as described below. The summary item represents a group that you can assign line items to, and the description
field of the summary item renders as the group header for these line items.
By default, Stripe renders all the line items assigned to the summary item. You can also hide all line items assigned to the summary item and only display the group header by setting display_
as a parameter on the summary item. If you set display_
, it hides all line items assigned to the summary item. It is not possible to selectively hide some line items but not others, except for line items with a value of 0 USD (see Hide individual $0 line items section).
curl https://api.stripe.com/v1/invoices/
/summary_items \ -u{{INVOICE_ID}}: \ -d description="Summary item 1" \ -d display_items="none"sk_test_4eC39HqLyjWDarjtT1zdp7dc
Instead of creating the summary items one-by-one, you can also bulk create with the create or update invoice endpoints. The example code below creates a draft invoice with two empty summary items
curl https://api.stripe.com/v1/invoices \ -u
: \ -d "rendering[summary_items_data][0][description]"="Summary item 1" \ -d "rendering[summary_items_data][0][display_items]"="none" \ -d "rendering[summary_items_data][1][description]"="Summary item 2" \ -d "expand[]"="rendering.summary_items"sk_test_4eC39HqLyjWDarjtT1zdp7dc
Remember to expand rendering.
so you can see the list of summary items in the response.
Assign summary item
Now that the invoice contains empty summary items (assuming that the invoice already contains line items), we can assign a summary item to the line item.
curl https://api.stripe.com/v1/invoices/
/lines/{{INVOICE_LINE_ITEM_ID}} \ -u{{INVOICE_ID}}: \ -d "rendering[summary_item]"={{SUMMARY_ITEM_ID}}sk_test_4eC39HqLyjWDarjtT1zdp7dc
You can update the summary item that the line item belongs to, or un-group the line item by using the same endpoint.
Update summary items
Using the update invoice endpoint, you can re-order, delete, or update the summary items. For example, in the code below, the order is reversed for the first and second summary item.
curl https://api.stripe.com/v1/invoices \ -u
: \ -d "rendering[summary_items_data][0][id]"="{{SUMMARY_ITEM_2_ID}}" \ -d "rendering[summary_items_data][1][id]"="{{SUMMARY_ITEM_1_ID}}" \ -d "expand[]"="rendering.summary_items"sk_test_4eC39HqLyjWDarjtT1zdp7dc
To delete all existing summary items from an invoice, use the same endpoint to unset the rendering[summary_
field like the following:
curl https://api.stripe.com/v1/invoices \ -u
: \ -d "rendering[summary_items_data]"="" \ -d "expand[]"="rendering.summary_items"sk_test_4eC39HqLyjWDarjtT1zdp7dc
When you delete the summary items, all associated line items are no longer grouped.
Alternatively, you can delete a single summary item like the following:
curl https://api.stripe.com/v1/invoices/
/summary_items/{{SUMARY_ITEM_ID}} \ -u{{INVOICE_ID}}: \ -x DELETEsk_test_4eC39HqLyjWDarjtT1zdp7dc
Hide individual $0 line items
The API also supports hiding individual 0 USD line items. For a specific line item on the invoice, you can set rendering[display]=hidden_
like the following:
curl https://api.stripe.com/v1/invoices/
/lines/{{INVOICE_LINE_ITEM_ID}} \ -u{{INVOICE_ID}}: \ -d "rendering[display]"= "hidden_if_zero"sk_test_4eC39HqLyjWDarjtT1zdp7dc
Then, if the line item is 0 USD, it is automatically hidden anywhere the customer sees the invoice.