Sample - Stripe API
POST/v1/invoices/{invoice}/update_lines

Bulk update invoice line items

Updates multiple line items on a draft invoice. Supply lines with each line item's identifier and the values to change, including pricing, quantity, description, or tax settings as needed. The operation only applies while the invoice remains in draft status.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.
  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

1 parameter · 3 body fields
invoicestringrequired
The unique identifier of the draft invoice whose line items to update. Maximum 5,000 characters.

Parameters for updating one or more line items on a draft invoice.

expandarray<string>optional
Specifies which fields in the response should be expanded.
invoice_metadataobjectoptional
Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. For [type=subscription](https://docs.stripe.com/api/invoices/line_item#invoice_line_item_object-type) line items, the incoming metadata specified on the request is directly used to set this value, in contrast to [type=invoiceitem](api/invoices/line_item#invoice_line_item_object-type) line items, where any existing metadata on the invoice line is merged with the incoming data.
linesarray<LinesDataParam>required
The line items to update.

2 status codes
200Returns the updated invoice object after applying the line item changes.
account_countrystringoptional
The country of the business associated with this invoice, most often the business creating the invoice.
account_namestringoptional
The public name of the business associated with this invoice, most often the business creating the invoice.
account_tax_idsarray<string>optional
The account tax IDs associated with the invoice. Only editable when the invoice is a draft.
amount_dueintegerrequired
Final amount due at this time for this invoice. If the invoice's total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the `amount_due` may be 0. If there is a positive `starting_balance` for the invoice (the customer owes money), the `amount_due` will also take that into account. The charge that gets generated for the invoice will be for the amount specified in `amount_due`.
amount_overpaidintegerrequired
Amount that was overpaid on the invoice. The amount overpaid is credited to the customer's credit balance.
amount_paidintegerrequired
The amount, in cents (or local equivalent), that was paid.
amount_paid_off_stripeintegerrequired
Amount, in cents (or local equivalent), that was paid on the invoice outside of Stripe.
amount_remainingintegerrequired
The difference between amount_due and amount_paid, in cents (or local equivalent).
amount_shippingintegerrequired
This is the sum of all the shipping amounts.
applicationstringoptional
ID of the Connect Application that created the invoice.
attempt_countintegerrequired
Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule. If a failure is returned with a non-retryable return code, the invoice can no longer be retried unless a new payment method is obtained. Retries will continue to be scheduled, and attempt_count will continue to increment, but retries will only be executed if a new payment method is obtained.
attemptedbooleanrequired
Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the `invoice.created` webhook, for example, so you might not want to display that invoice as unpaid to your users.
auto_advancebooleanrequired
Controls whether Stripe performs [automatic collection](https://docs.stripe.com/invoicing/integration/automatic-advancement-collection) of the invoice. If `false`, the invoice's state doesn't automatically advance without an explicit action.
automatic_taxobjectrequired
automatically_finalizes_atintegeroptional
The time when this invoice is currently scheduled to be automatically finalized. The field will be `null` if the invoice is not scheduled to finalize in the future. If the invoice is not in the draft state, this field will always be `null` - see `finalized_at` for the time when an already-finalized invoice was finalized.
billing_reasonstringoptional
Indicates the reason why the invoice was created. * `manual`: Unrelated to a subscription, for example, created via the invoice editor. * `subscription`: No longer in use. Applies to subscriptions from before May 2018 where no distinction was made between updates, cycles, and thresholds. * `subscription_create`: A new subscription was created. * `subscription_cycle`: A subscription advanced into a new period. * `subscription_threshold`: A subscription reached a billing threshold. * `subscription_update`: A subscription was updated. * `upcoming`: Reserved for upcoming invoices created through the Create Preview Invoice API or when an `invoice.upcoming` event is generated for an upcoming invoice on a subscription.
Allowed:automatic_pending_invoice_item_invoicemanualquote_acceptsubscriptionsubscription_createsubscription_cyclesubscription_thresholdsubscription_updateupcoming
collection_methodstringrequired
Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
Allowed:charge_automaticallysend_invoice
confirmation_secretobjectoptional
The confirmation secret associated with this invoice. Currently, this contains the client_secret of the PaymentIntent that Stripe creates during invoice finalization.
createdintegerrequired
Time at which the object was created. Measured in seconds since the Unix epoch.
currencystringrequired
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
custom_fieldsarray<InvoiceSettingCustomField>optional
Custom fields displayed on the invoice.
customerstringrequired
The ID of the customer to bill.
customer_accountstringoptional
The ID of the account representing the customer to bill.
customer_addressobjectoptional
The customer's address. Until the invoice is finalized, this field will equal `customer.address`. Once the invoice is finalized, this field will no longer be updated.
customer_emailstringoptional
The customer's email. Until the invoice is finalized, this field will equal `customer.email`. Once the invoice is finalized, this field will no longer be updated.
customer_namestringoptional
The customer's name. Until the invoice is finalized, this field will equal `customer.name`. Once the invoice is finalized, this field will no longer be updated.
customer_phonestringoptional
The customer's phone number. Until the invoice is finalized, this field will equal `customer.phone`. Once the invoice is finalized, this field will no longer be updated.
customer_shippingobjectoptional
The customer's shipping information. Until the invoice is finalized, this field will equal `customer.shipping`. Once the invoice is finalized, this field will no longer be updated.
customer_tax_exemptstringoptional
The customer's tax exempt status. Until the invoice is finalized, this field will equal `customer.tax_exempt`. Once the invoice is finalized, this field will no longer be updated.
Allowed:exemptnonereverse
customer_tax_idsarray<InvoicesResourceInvoiceTaxID>optional
The customer's tax IDs. Until the invoice is finalized, this field will contain the same tax IDs as `customer.tax_ids`. Once the invoice is finalized, this field will no longer be updated.
default_payment_methodstringoptional
ID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings.
default_sourcestringoptional
ID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription's default source, if any, or to the customer's default source.
default_tax_ratesarray<TaxRate>required
The tax rates applied to this invoice, if any.
descriptionstringoptional
An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.
discountsarray<string>required
The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.
due_dateintegeroptional
The date on which payment for this invoice is due. This value will be `null` for invoices where `collection_method=charge_automatically`.
effective_atintegeroptional
The date when this invoice is in effect. Same as `finalized_at` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the invoice PDF and receipt.
ending_balanceintegeroptional
Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null.
footerstringoptional
Footer displayed on the invoice.
from_invoiceobjectoptional
Details of the invoice that was cloned. See the [revision documentation](https://docs.stripe.com/invoicing/invoice-revisions) for more details.
hosted_invoice_urlstringoptional
The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been finalized yet, this will be null.
idstringrequired
Unique identifier for the object. For preview invoices created using the [create preview](https://stripe.com/docs/api/invoices/create_preview) endpoint, this id will be prefixed with `upcoming_in`.
invoice_pdfstringoptional
The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.
issuerobjectrequired
last_finalization_errorobjectoptional
The error encountered during the previous attempt to finalize the invoice. This field is cleared when the invoice is successfully finalized.
latest_revisionstringoptional
The ID of the most recent non-draft revision of this invoice
linesobjectrequired
The individual line items that make up the invoice. `lines` is sorted as follows: (1) pending invoice items (including prorations) in reverse chronological order, (2) subscription items in reverse chronological order, and (3) invoice items added after invoice creation in chronological order.
livemodebooleanrequired
If the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
metadataobjectoptional
Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
next_payment_attemptintegeroptional
The time at which payment will next be attempted. This value will be `null` for invoices where `collection_method=send_invoice`.
numberstringoptional
A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer's unique invoice_prefix if it is specified.
objectstringrequired
String representing the object's type. Objects of the same type share the same value.
Allowed:invoice
on_behalf_ofstringoptional
The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the [Invoices with Connect](https://docs.stripe.com/billing/invoices/connect) documentation for details.
parentobjectoptional
The parent that generated this invoice
payment_settingsobjectrequired
paymentsobjectoptional
Payments for this invoice. Use [invoice payment](/api/invoice-payment) to get more details.
period_endintegerrequired
The latest timestamp at which invoice items can be associated with this invoice. Use the [line item period](/api/invoices/line_item#invoice_line_item_object-period) to get the service period for each price.
period_startintegerrequired
The earliest timestamp at which invoice items can be associated with this invoice. Use the [line item period](/api/invoices/line_item#invoice_line_item_object-period) to get the service period for each price.
post_payment_credit_notes_amountintegerrequired
Total amount of all post-payment credit notes issued for this invoice.
pre_payment_credit_notes_amountintegerrequired
Total amount of all pre-payment credit notes issued for this invoice.
receipt_numberstringoptional
This is the transaction number that appears on email receipts sent for this invoice.
renderingobjectoptional
The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.
shipping_costobjectoptional
The details of the cost of shipping, including the ShippingRate applied on the invoice.
shipping_detailsobjectoptional
Shipping details for the invoice. The Invoice PDF will use the `shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer.
starting_balanceintegerrequired
Starting customer balance before the invoice is finalized. If the invoice has not been finalized yet, this will be the current customer balance. For revision invoices, this also includes any customer balance that was applied to the original invoice.
statement_descriptorstringoptional
Extra information about an invoice for the customer's credit card statement.
statusstringoptional
The status of the invoice, one of `draft`, `open`, `paid`, `uncollectible`, or `void`. [Learn more](https://docs.stripe.com/billing/invoices/workflow#workflow-overview)
Allowed:draftopenpaiduncollectiblevoid
status_transitionsobjectrequired
subtotalintegerrequired
Total of all subscriptions, invoice items, and prorations on the invoice before any invoice level discount or exclusive tax is applied. Item discounts are already incorporated
subtotal_excluding_taxintegeroptional
The integer amount in cents (or local equivalent) representing the subtotal of the invoice before any invoice level discount or tax is applied. Item discounts are already incorporated
test_clockstringoptional
ID of the test clock this invoice belongs to.
threshold_reasonobjectoptional
totalintegerrequired
Total after discounts and taxes.
total_discount_amountsarray<DiscountsResourceDiscountAmount>optional
The aggregate amounts calculated per discount across all line items.
total_excluding_taxintegeroptional
The integer amount in cents (or local equivalent) representing the total amount of the invoice including all discounts but excluding all tax.
total_pretax_credit_amountsarray<InvoicesResourcePretaxCreditAmount>optional
Contains pretax credit amounts (ex: discount, credit grants, etc) that apply to this invoice. This is a combined list of total_pretax_credit_amounts across all invoice line items.
total_taxesarray<BillingBillResourceInvoicingTaxesTax>optional
The aggregate tax information of all line items.
webhooks_delivered_atintegeroptional
Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have [been exhausted](https://docs.stripe.com/billing/webhooks#understand). This field tracks the time when webhooks for this invoice were successfully delivered. If the invoice had no webhooks to deliver, this will be set while the invoice is being created.
defaultReturned when the request cannot be processed. The response contains an API error object with a type and error details.
errorobjectrequired

Error handling

lines is required and every entry must include id. If period is supplied, it must include both start and end, and price_data must include currency. invoice must identify the draft invoice whose line items you want to update.