> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tesouro.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Invoice line items

> Add, replace, remove, or fully replace invoice line items.

The examples below use draft invoices. In the default `compliant` mode, you cannot edit an invoice's line items after issuing it. In `non_compliant` mode, you can edit issued invoices, including their line items. See [Invoice compliance](/finops/guides/accounts-receivable/regulatory-compliance/invoice-compliance) for details.

## Update invoice line items

To add, replace, or remove line items while updating other invoice fields, call [`PATCH /receivables/{receivable_id}`](/finops/reference/openapi/receivables/update-receivable). The response for every invoice line item includes a stable `id`; use that ID when replacing or removing an existing item.

The `line_items` object can contain `add`, `replace`, and `remove` operations in the same request. Each item in `add` and `replace[].data` uses the complete line item shape accepted by the [replace line items endpoint](/finops/reference/openapi/receivables/replace-receivable-items). A `replace` operation keeps the existing line item's ID.

```sh expandable lines theme={null}
curl -X PATCH 'https://api.sandbox.tesouro.com/finops/v1/receivables/411dc6eb...6289b3' \
     -H 'X-Finops-Version: 2025-06-23' \
     -H 'X-Organization-Id: ORGANIZATION_ID' \
     -H 'Authorization: Bearer ACCESS_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{
       "invoice": {
         "memo": "Updated services for September",
         "line_items": {
           "add": [
             {
               "quantity": 1,
               "product_id": "fb2cc78f-3396-42e1-a69f-04b1931e4a84",
               "vat_rate_id": "8d4c2c10-f7d7-4d7c-a1f5-5f3a9d56371e"
             }
           ],
           "replace": [
             {
               "id": "5c4798b6-4b3f-4b0c-9ed6-5242c144a0c1",
               "data": {
                 "quantity": 3,
                 "product_id": "d1bc6df0-1571-457c-8407-7cf42aceb5dd",
                 "vat_rate_id": "8d4c2c10-f7d7-4d7c-a1f5-5f3a9d56371e"
               }
             }
           ],
           "remove": ["cd9e0e72-8a6c-4f09-8b62-5e63f6320a5d"]
         }
       }
     }'
```

Include at least one operation. Do not use the same line item ID more than once or in both `replace` and `remove`. The final invoice must contain at least one line item. Tesouro recalculates the totals from the resulting list and records the header and line-item changes in one history entry.

## Replace all invoice line items

To replace the entire list in a separate request, send a `PUT` request to the [`/receivables/{receivable_id}/line-items`](/finops/reference/openapi/receivables/replace-receivable-items) endpoint. In the request body, use the `data` field to specify the invoice's new line items. This endpoint is unchanged.

```sh expandable lines theme={null}
curl -X PUT 'https://api.sandbox.tesouro.com/finops/v1/receivables/411dc6eb...6289b3/line-items' \
     -H 'X-Finops-Version: 2025-06-23' \
     -H 'X-Organization-Id: ORGANIZATION_ID' \
     -H 'Authorization: Bearer ACCESS_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{
       "data": [
         {
           "quantity": 2,
           "product_id": "fb2cc78f-3396-42e1-a69f-04b1931e4a84",
           "vat_rate_id": "8d4c2c10-f7d7-4d7c-a1f5-5f3a9d56371e",
           "discount": {
             "type": "amount",
             "amount": 0
           }
         },
         {
           "quantity": 4,
           "product_id": "d1bc6df0-1571-457c-8407-7cf42aceb5dd",
           "vat_rate_id":"8d4c2c10-f7d7-4d7c-a1f5-5f3a9d56371e",
           "discount": {
             "type":"amount",
             "amount":0
           }
         }
       ]
     }'
```

A successful request overwrites the invoice's existing line items and replaces them with the newly defined array of line item objects.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.