# 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.

## Prerequisites

Before you can run the following code snippet, you need to call these APIs with the provided parameters to set up the prerequisite API object(s).

1. createCustomer
POST /v1/customers {"name":"Jenny Rosen","email":"jennyrosen@example.com"}
2. createInvoice
POST /v1/invoices {"customer":"${node.prerequisites.createCustomer.createCustomer:id}"}

## Request

```curl
curl -X POST https://api.stripe.com/v1/invoices/{{INVOICE_ID}}/lines/il_tmp_1Nzo1ZGgdF1VjufLzD1UUn9R \
  -u "<<YOUR_SECRET_KEY>>"
```

### Response

```json
{
  "id": "il_tmp_1Nzo1ZGgdF1VjufLzD1UUn9R",
  "object": "line_item",
  "amount": 1000,
  "currency": "usd",
  "description": "My First Invoice Item (created for API docs)",
  "discount_amounts": [],
  "discountable": true,
  "discounts": [],
  "livemode": false,
  "metadata": {},
  "parent": {
    "type": "invoice_item_details",
    "invoice_item_details": {
      "invoice_item": "ii_1Nzo1ZGgdF1VjufLzD1UUn9R",
      "proration": false,
      "proration_details": {
        "credited_items": null
      },
      "subscription": null
    }
  },
  "period": {
    "end": 1696975413,
    "start": 1696975413
  },
  "pricing": {
    "price_details": {
      "price": "price_1NzlYfGgdF1VjufL0cVjLJVI",
      "product": "prod_OnMHDH6VBmYlTr"
    },
    "type": "price_details",
    "unit_amount_decimal": "1000"
  },
  "quantity": 1,
  "quantity_decimal": "1",
  "taxes": []
}
```

## Returns

The updated invoice’s line item object is returned upon success. Otherwise, this call raises [an error](https://docs.stripe.com/api/errors.md).

## Parameters

- `invoice` (string, required)
  Invoice ID of line item

- `line_item_id` (string, required)
  Invoice line item ID

- `amount` (integer, optional)
  The integer amount in the smallest currency unit 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.

- `description` (string, optional)
  An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking.

- `discountable` (boolean, optional)
  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.

- [`discounts`](https://docs.stripe.com/api/invoice-line-item/update.md?query=discounts) (array of objects, 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.

- `metadata` (map, optional)
  Set of [key-value pairs](https://docs.stripe.com/api/metadata.md) 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.md) line items, the incoming metadata specified on the request is directly used to set this value, in contrast to [type=invoiceitem](https://docs.stripe.com/api/invoices/line_item.md) line items, where any existing metadata on the invoice line is merged with the incoming data.

- [`period`](https://docs.stripe.com/api/invoice-line-item/update.md?query=period) (object, optional)
  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.md) 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.md) for details.

- [`price_data`](https://docs.stripe.com/api/invoice-line-item/update.md?query=price_data) (object, optional)
  Data used to generate a new [Price](https://docs.stripe.com/api/prices.md) object inline.

- [`pricing`](https://docs.stripe.com/api/invoice-line-item/update.md?query=pricing) (object, optional)
  The pricing information for the invoice item.

- `quantity` (integer, optional)
  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_decimal` (string, optional)
  Non-negative decimal with at most 12 decimal places. The quantity of units for the line item.

- [`tax_amounts`](https://docs.stripe.com/api/invoice-line-item/update.md?query=tax_amounts) (array of objects, 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.md#invoice_line_item_object-tax_rates) or if the invoice has [default_tax_rates](https://docs.stripe.com/api/invoices/object.md#invoice_object-default_tax_rates) or uses [automatic tax](https://docs.stripe.com/tax/invoicing.md). Pass an empty string to remove previously defined tax amounts.

- `tax_rates` (array of strings, 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.
