Sample - Stripe API
POST/v1/invoices/{invoice}/lines/{line_item_id}

Update an invoice's line item

Updates an invoice’s line item. Some fields, such as tax_amounts, only live on the invoice line item, so they can only be updated through this endpoint. Other fields, such as amount, live on both the invoice item and the invoice line item, so updates on this endpoint will propagate to the invoice item as well. Updating an invoice’s line item is only possible before the invoice is finalized.

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

2 parameters · 13 body fields
invoicestringrequired
Invoice ID of line item
line_item_idstringrequired
Invoice line item ID
amountintegeroptional
The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. If you want to apply a credit to the customer's account, pass a negative amount.
descriptionstringoptional
An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking.
discountablebooleanoptional
Controls whether discounts apply to this line item. Defaults to false for prorations or negative line items, and true for all other line items. Cannot be set to true for prorations.
discountsarray<DiscountsDataParam>optional
The coupons, promotion codes & existing discounts which apply to the line item. Item discounts are applied before invoice discounts. Pass an empty string to remove previously-defined discounts.
expandarray<string>optional
Specifies which fields in the response should be expanded.
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](/api/invoices/line_item) 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) line items, where any existing metadata on the invoice line is merged with the incoming data.
periodobjectoptional
The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have [Stripe Revenue Recognition](https://docs.stripe.com/revenue-recognition) enabled, the period will be used to recognize and defer revenue. See the [Revenue Recognition documentation](https://docs.stripe.com/revenue-recognition/methodology/subscriptions-and-invoicing) for details.
price_dataobjectoptional
Data used to generate a new [Price](https://docs.stripe.com/api/prices) object inline.
pricingobjectoptional
The pricing information for the invoice item.
quantityintegeroptional
Non-negative integer. The quantity of units for the line item. Use `quantity_decimal` instead to provide decimal precision. This field will be deprecated in favor of `quantity_decimal` in a future version.
quantity_decimalstringoptional
Non-negative decimal with at most 12 decimal places. The quantity of units for the line item.
tax_amountsarray<TaxAmountParam>optional
A list of up to 20 tax amounts for this line item. This can be useful if you calculate taxes on your own or use a third-party to calculate them. You cannot set tax amounts if any line item has [tax_rates](https://docs.stripe.com/api/invoices/line_item#invoice_line_item_object-tax_rates) or if the invoice has [default_tax_rates](https://docs.stripe.com/api/invoices/object#invoice_object-default_tax_rates) or uses [automatic tax](https://docs.stripe.com/tax/invoicing). Pass an empty string to remove previously defined tax amounts.
tax_ratesarray<string>optional
The tax rates which apply to the line item. When set, the `default_tax_rates` on the invoice do not apply to this line item. Pass an empty string to remove previously-defined tax rates.

2 status codes
200Successful response.
amountintegerrequired
The amount, in cents (or local equivalent).
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).
descriptionstringoptional
An arbitrary string attached to the object. Often useful for displaying to users.
discount_amountsarray<DiscountsResourceDiscountAmount>optional
The amount of discount calculated per discount for this line item.
discountablebooleanrequired
If true, discounts will apply to this line item. Always false for prorations.
discountsarray<string>required
The discounts applied to the invoice line item. Line item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.
idstringrequired
Unique identifier for the object.
invoicestringoptional
The ID of the invoice that contains this line item.
livemodebooleanrequired
If the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
metadataobjectrequired
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. Note that for line items with `type=subscription`, `metadata` reflects the current metadata from the subscription associated with the line item, unless the invoice line was directly updated with different metadata after creation.
objectstringrequired
String representing the object's type. Objects of the same type share the same value.
Allowed:line_item
parentobjectoptional
The parent that generated this line item.
periodobjectrequired
pretax_credit_amountsarray<InvoicesResourcePretaxCreditAmount>optional
Contains pretax credit amounts (ex: discount, credit grants, etc) that apply to this line item.
pricingobjectoptional
The pricing information of the line item.
quantityintegeroptional
Quantity of units for the invoice line item in integer format, with any decimal precision truncated. For the line item's full-precision decimal quantity, use `quantity_decimal`. This field will be deprecated in favor of `quantity_decimal` in a future version. If the line item is a proration or subscription, the quantity of the subscription that the proration was computed for.
quantity_decimalstringoptional
Non-negative decimal with at most 12 decimal places. The quantity of units for the line item.
subscriptionstringoptional
subtotalintegerrequired
The subtotal of the line item, in cents (or local equivalent), before any discounts or taxes.
taxesarray<BillingBillResourceInvoicingTaxesTax>optional
The tax information of the line item.
defaultError response.
errorobjectrequired

Error handling

Any other status is an error: Error response.