> For the complete documentation index, see [llms.txt](https://tri.gitbook.io/tri-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tri.gitbook.io/tri-doc/liquidity-pool/edit-invoice.md).

# Edit Invoice

### Liquidity Pool

<mark style="color:blue;">`PATCH`</mark> <https://sandbox.triangle.digital/api/v2/liquidity\\_pool/clients/{client\\_id}/invoices/{invoice\\_id}>

Changes one invoice of the client. Send only the fields to change: a field left out keeps its stored value, and a group — `ai_compute`, `air_travel`, `vehicle`, `lodging`, `food` — that is not sent keeps both of its values. An invoice that was entered as expense lines keeps them the same way, and `expense_lines` replaces the whole set of them at once; patching a single expense-type group on such an invoice is refused, because the lines are what those totals are summed from.

The employee of the invoice is resolved from `employee_name` and `employee_number`: the newest employee of the client with that name is taken, narrowed by the Employee ID when it is sent, and when nobody matches, a new employee is created and the invoice is pointed at them. Sending these two fields is therefore how an invoice is moved to another employee.

An invoice that has already been bought from can be edited too. The `co2` values are what is LEFT of it — the part that was already purchased is kept as it is and is not touched by the edit.

The answer carries the invoice in the shape of [Get Invoices](/tri-doc/liquidity-pool/get-invoices.md).

**Path parameters**

<table data-full-width="true" data-search="false"><thead><tr><th width="230">Name</th><th width="110">Type</th><th>Description</th><th width="210">Where to take it from</th></tr></thead><tbody><tr><td><code>client_id</code></td><td>integer</td><td><strong>Required.</strong> The client the invoice belongs to.</td><td><a href="/tri-doc/liquidity-pool/get-clients.md">Get Clients</a> — <code>client_id</code></td></tr><tr><td><code>invoice_id</code></td><td>integer</td><td><strong>Required.</strong> The invoice to change.</td><td><a href="/tri-doc/liquidity-pool/get-invoices.md">Get Invoices</a> — <code>invoice_id</code></td></tr></tbody></table>

**Headers**

<table data-full-width="true"><thead><tr><th>Name</th><th>Value</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td></tr></tbody></table>

**Body**

<table data-full-width="true" data-search="false"><thead><tr><th width="200">Name</th><th width="110">Type</th><th>Description</th><th width="260">Example</th></tr></thead><tbody><tr><td><code>hash</code></td><td>string</td><td><strong>Required.</strong> API key.</td><td>fk5f0iuy-rr06-j4x3-i75b-fy2s67s4ilo1</td></tr><tr><td><code>invoice_number</code></td><td>string</td><td>Invoice number — the client assigns the value, as used in its own systems.</td><td>56WFFS23</td></tr><tr><td><code>employee_number</code></td><td>string</td><td>Client-facing Employee ID — the client assigns the value, as used in its own systems; the <code>employee_number</code> of <a href="/tri-doc/liquidity-pool/get-employees.md">Get Employees</a>. Sent together with <code>employee_name</code> it decides which employee the invoice belongs to.</td><td>D2354324</td></tr><tr><td><code>employee_name</code></td><td>string</td><td>Employee of the invoice. Cannot be cleared — sending it empty is refused.</td><td>John Smith</td></tr><tr><td><code>transaction_date</code></td><td>string</td><td>Invoice date, MM/DD/YYYY. An empty value clears the date.</td><td>07/07/2026</td></tr><tr><td><code>transaction_type</code></td><td>string</td><td>One of: <code>business_travel</code>, <code>employee_commuting</code>, <code>purchased_goods_and_services</code>. An invoice that carries a type no longer offered can be sent back with that same value. An empty value clears the type.</td><td>business_travel</td></tr><tr><td><code>ai_compute</code> / <code>air_travel</code> / <code>vehicle</code> / <code>lodging</code> / <code>food</code></td><td>object</td><td>Per expense type — <code>co2</code> (tons, number) and <code>amount</code> (USD, number). Send the values to change: <code>co2</code> and <code>amount</code> are patched on their own, and a value left out keeps what is stored.</td><td><pre class="language-json"><code class="lang-json">{
  "co2": 3.0,
  "amount": 1.0
}
</code></pre></td></tr><tr><td><code>expense_lines</code></td><td>array</td><td>The expense lines of the invoice, ALL of them: the set sent replaces the stored one, and a line left out is removed. Leave the field out to keep the stored lines as they are. When it is sent, each expense type's <code>co2</code> and <code>amount</code> are the SUM of its lines and the per-type groups are ignored.</td><td></td></tr><tr><td><code>expense_lines[].expense_type</code></td><td>string</td><td><strong>Required.</strong> One of: <code>ai_compute</code>, <code>air_travel</code>, <code>vehicle</code>, <code>lodging</code>, <code>food</code>.</td><td>air_travel</td></tr><tr><td><code>expense_lines[].amount</code></td><td>number</td><td>USD of this line.</td><td>1.0</td></tr><tr><td><code>expense_lines[].co2</code></td><td>number</td><td>Tons of CO<sub>2</sub> of this line. <strong>Not accepted for <code>ai_compute</code></strong>: the CO<sub>2</sub> of that line is computed by the platform from <code>provider</code>, <code>model_name</code> and <code>output_token_count</code>, and is <code>0</code> when those are not all filled in.</td><td>3.0</td></tr><tr><td><code>expense_lines[].date</code></td><td>string</td><td>Air Travel and Lodging. Date of the flight or of the stay, MM/DD/YYYY.</td><td>09/01/2026</td></tr><tr><td><code>expense_lines[].flight_origin</code></td><td>string</td><td>Air Travel only. Airport or city the flight departs from.</td><td>JFK</td></tr><tr><td><code>expense_lines[].destination</code></td><td>string</td><td>Air Travel only. Airport or city the flight arrives at.</td><td>LHR</td></tr><tr><td><code>expense_lines[].provider</code></td><td>string</td><td>Air Travel and Lodging — airline or hotel of the line. AI Compute — the AI provider, a <code>value</code> of <a href="/tri-doc/liquidity-pool/carbon-equivalent-reporting/ai-compute/get-ai-compute-providers.md">Get AI Compute Providers</a>.</td><td>Delta</td></tr><tr><td><code>expense_lines[].distance_miles</code></td><td>number</td><td>Air Travel only. Distance in miles, up to 4 decimal places.</td><td>3450</td></tr><tr><td><code>expense_lines[].round_trip</code></td><td>boolean</td><td>Air Travel only. Whether the flight is a round trip.</td><td>true</td></tr><tr><td><code>expense_lines[].nights</code></td><td>integer</td><td>Lodging only. Number of nights, a whole number.</td><td>3</td></tr><tr><td><code>expense_lines[].region</code></td><td>string</td><td>Lodging only. Region of the stay.</td><td>EMEA</td></tr><tr><td><code>expense_lines[].model_name</code></td><td>string</td><td>AI Compute only. Model of the chosen provider — a value of <a href="/tri-doc/liquidity-pool/carbon-equivalent-reporting/ai-compute/get-ai-compute-models.md">Get AI Compute Models</a>.</td><td>claude-opus-4-20250514</td></tr><tr><td><code>expense_lines[].output_token_count</code></td><td>integer</td><td>AI Compute only. Number of output tokens generated, a whole number of 0 or more.</td><td>1324345</td></tr></tbody></table>

```json
{
    "hash": "fk5f0iuy-rr06-j4x3-i75b-fy2s67s4ilo1",
    "transaction_date": "07/07/2026",
    "air_travel": {
        "co2": 3.0,
        "amount": 1.0
    }
}
```

**Response fields**

<table data-full-width="true" data-search="false"><thead><tr><th width="300">Field</th><th width="110">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>message</code></td><td>string</td><td>Human-readable result of the call.</td></tr><tr><td><code>success</code></td><td>boolean</td><td>Whether the invoice was updated; a refused call answers HTTP 400.</td></tr><tr><td><code>data.invoice_id</code></td><td>integer</td><td>The invoice, as in <a href="/tri-doc/liquidity-pool/get-invoices.md">Get Invoices</a> — <code>invoice_id</code>.</td></tr><tr><td><code>data.invoice_number</code></td><td>string</td><td>Invoice number after the change.</td></tr><tr><td><code>data.employee_id</code></td><td>integer</td><td>The employee the invoice now belongs to, as in <a href="/tri-doc/liquidity-pool/get-employees.md">Get Employees</a> — <code>employee_id</code>.</td></tr><tr><td><code>data.employee_number</code> / <code>employee_name</code></td><td>string</td><td>Client-facing Employee ID and name of that employee.</td></tr><tr><td><code>data.transaction_date</code></td><td>string</td><td>Invoice date, MM/DD/YYYY; empty when none is set.</td></tr><tr><td><code>data.transaction_type</code></td><td>string</td><td>Type of the invoice; empty when none is set.</td></tr><tr><td><code>data.credit_card</code></td><td>boolean</td><td>Whether the employee of the invoice has a card attached.</td></tr><tr><td><code>data.ai_compute</code> / <code>air_travel</code> / <code>vehicle</code> / <code>lodging</code> / <code>food</code></td><td>object</td><td><code>co2</code> (tons) and <code>amount</code> (USD) left on the invoice per expense type.</td></tr><tr><td><code>data.expense_lines</code></td><td>array</td><td>The expense lines the invoice was entered as. The per-expense-type objects above are their totals, and a purchase reduces those totals without touching the lines — so on a partly purchased invoice the lines add up to more than what is left. Empty for an invoice entered without lines. A field the invoice does not carry comes back as null.</td></tr><tr><td><code>data.expense_lines[].expense_type</code></td><td>string</td><td><strong>Required.</strong> One of: <code>ai_compute</code>, <code>air_travel</code>, <code>vehicle</code>, <code>lodging</code>, <code>food</code>.</td></tr><tr><td><code>data.expense_lines[].amount</code></td><td>number</td><td>USD of this line.</td></tr><tr><td><code>data.expense_lines[].co2</code></td><td>number</td><td>Tons of CO<sub>2</sub> of this line.</td></tr><tr><td><code>data.expense_lines[].date</code></td><td>string</td><td>Air Travel and Lodging. Date of the flight or of the stay, MM/DD/YYYY.</td></tr><tr><td><code>data.expense_lines[].flight_origin</code></td><td>string</td><td>Air Travel only. Airport or city the flight departs from.</td></tr><tr><td><code>data.expense_lines[].destination</code></td><td>string</td><td>Air Travel only. Airport or city the flight arrives at.</td></tr><tr><td><code>data.expense_lines[].provider</code></td><td>string</td><td>Air Travel and Lodging. Airline or hotel of the line.</td></tr><tr><td><code>data.expense_lines[].distance_miles</code></td><td>number</td><td>Air Travel only. Distance in miles, up to 4 decimal places.</td></tr><tr><td><code>data.expense_lines[].round_trip</code></td><td>boolean</td><td>Air Travel only. Whether the flight is a round trip.</td></tr><tr><td><code>data.expense_lines[].nights</code></td><td>integer</td><td>Lodging only. Number of nights, a whole number.</td></tr><tr><td><code>data.expense_lines[].region</code></td><td>string</td><td>Lodging only. Region of the stay.</td></tr><tr><td><code>data.total_co2</code></td><td>number</td><td>Sum of the <code>co2</code> values above — what is left to buy.</td></tr><tr><td><code>errors</code></td><td>object</td><td>400 only — validation problems, each naming the field it belongs to.</td></tr><tr><td><code>operations_count</code></td><td>integer</td><td>Always <code>1</code>.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}
{% code fullWidth="false" %}

```json
{
    "message": "Invoice updated successfully.",
    "success": true,
    "data": {
        "invoice_id": 61,
        "invoice_number": "56WFFS23",
        "employee_id": 18,
        "employee_number": "D2354324",
        "employee_name": "John Smith",
        "transaction_date": "07/07/2026",
        "transaction_type": "business_travel",
        "credit_card": false,
        "ai_compute": {
            "co2": 0.0,
            "amount": 0.0
        },
        "air_travel": {
            "co2": 3.0,
            "amount": 1.0
        },
        "vehicle": {
            "co2": 0.0,
            "amount": 0.0
        },
        "lodging": {
            "co2": 0.0,
            "amount": 0.0
        },
        "food": {
            "co2": 0.0,
            "amount": 0.0
        },
        "expense_lines": [
            {
                "expense_type": "air_travel",
                "amount": 1.0,
                "co2": 3.0,
                "date": "09/01/2026",
                "flight_origin": "JFK",
                "destination": "LHR",
                "provider": "Delta",
                "distance_miles": 3450,
                "round_trip": true
            }
        ],
        "total_co2": 3.0
    },
    "operations_count": 1
}
```

{% endcode %}
{% endtab %}

{% tab title="400" %}
Nothing was changed. A field that is not valid comes back in `errors`; the other refusals answer with the problem in `message`: `Invoice not found for this client.`; `Invalid transaction_date '07-07-2026'. Expected format: MM/DD/YYYY.`; `Invalid transaction_type 'travel'. Allowed values: business_travel, employee_commuting, purchased_goods_and_services.`; `Could not save the invoice.`; `This invoice is itemized: send expense_lines to change its amounts.`; `Invalid expense_type 'flight'. Allowed values: ai_compute, air_travel, vehicle, lodging, food.`; `expense_lines must be an array.`

```json
{
    "message": "Please fill in all fields",
    "success": false,
    "data": {},
    "errors": {
        "0": {
            "errors": [
                {
                    "field_name": "employee_name",
                    "message": "\"Employee Name\" required field"
                }
            ],
            "validate": false
        }
    },
    "operations_count": 1
}
```

{% endtab %}
{% endtabs %}
