# Update a vendor bill

Operation ID: `updateVendorBill`

Group: Accounting › Vendor Bills

[Open in the interactive reference](https://docs.api.lensing.ai/lensing/v1/endpoints/updateVendorBill)

`PATCH /accounting/vendor-bills/{id}`

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Updates a vendor bill with the fields you send. A field you leave out keeps its current value. Line items change through three separate arrays, applied in this order: deleteLines, updateLines, createLines.

Leave out all three to keep the lines as they are. On an updateLines item, a field you leave out keeps its current value, and amortization schedules change through createAmortizationSchedules, updateAmortizationSchedules and deleteAmortizationSchedules.

The bill's main fields and its line items can change in one request.

One request can remove a line and add its replacement.

updateLines and deleteLines name each line by the id that GET accounting/vendor-bills/:id returns for it. Each line must belong to this bill. Amounts on the lines this request writes are in currency, or in the bill's current currency when currency is left out.

The response is empty. To see the updated bill, use GET accounting/vendor-bills/:id.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Api-Version` | header | string · v1 | yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version `v1`. |
| `Idempotency-Key` | header | string | no | An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with `400 IDEMPOTENCY_NOT_SUPPORTED` rather than silently ignored. |
| `id` | path | string | yes | The unique identifier of the vendor bill you want to update. Example: `"c41d0b58-2e97-4f6a-8d13-7b5e9c204af6"`. |

## Request body

Required, `application/json`: updateVendorBillInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `billNumber` | string | no | The vendor-issued invoice number, as printed on the bill. It is not unique across vendors. Omit to leave unchanged. |
| `billDate` | date | no | The date printed on the vendor's invoice. Use format YYYY-MM-DD. Omit to leave unchanged. |
| `dueDate` | date | no | The date payment is due. Use format YYYY-MM-DD. Omit to leave unchanged. Example: `"2026-09-15"`. |
| `serviceDate` | date | no | The date the goods or services were delivered. Use format YYYY-MM-DD. Omit to leave unchanged. |
| `currency` | string | no | The currency of the bill. Format ISO 4217, for example 'USD'. Omit to leave unchanged. |
| `paymentTerms` | string | no | The payment-terms key, for example 'net30', 'net60' or 'dueOnReceipt'. Omit to leave unchanged. |
| `vendorId` | string | no | The vendor the bill is from. See id on GET accounting/vendors/:id. Omit to leave unchanged. |
| `entityId` | string | no | The legal entity the bill is posted under. See id on GET base/entities. Omit to leave unchanged. |
| `markAsPaid` | boolean | no | Whether the bill is marked paid. Omit to leave unchanged. |
| `origin` | string | no | The source system this record came from, as free-form text, for example 'Ramp'. Omit it and it stays unset. The server does not set a value. |
| `createLines` | array<object> | no | Lines to add to the bill, each with the same shape as on create and no id. Omit for no additions. |
| `createLines[].amount` | decimal | yes | The total line amount, gross, including VAT where applicable, as a decimal in the bill currency. |
| `createLines[].description` | string | no | A description of the line item, typically copied from the vendor's invoice. |
| `createLines[].accountId` | string | no | The GL expense account this line posts to. See id on GET accounting/accounts/:id. |
| `createLines[].departmentId` | string | no | The department this line is charged to. See id on GET people/departments/:id. |
| `createLines[].businessUnitId` | string | no | The business unit this line is charged to. There is no endpoint for it. |
| `createLines[].crossChargeEntityId` | string | no | The legal entity this line is cross charged to (Charge to). See id on GET base/entities. It must differ from the bill's entity, and cross charging must be set up for both entities, or the request fails with CROSS_CHARGE_INVALID. |
| `createLines[].customerId` | string | no | The customer this expense is rebilled to. See id on GET accounting/customers/:id. It is only meaningful alongside billableExpense. |
| `createLines[].vatPercentage` | decimal | no | The VAT rate applied, as a percentage. 19 means 19%, not 0.19. |
| `createLines[].vatAccountId` | string | no | The general ledger account the VAT posts to. See id on GET accounting/accounts/:id. |
| `createLines[].reverseVatAccountId` | string | no | The general ledger account reverse-charge VAT posts to. See id on GET accounting/accounts/:id. |
| `createLines[].vatAmount` | decimal | no | The explicit VAT amount, as a decimal in the bill currency. Omit to derive it from vatPercentage. |
| `createLines[].valueAllocationId` | string | no | The value-allocation rule distributing this line across dimensions. There is no endpoint for it. |
| `createLines[].purchaseOrderLineId` | string | no | The purchase-order line this line is matched against. There is no endpoint for it. |
| `createLines[].billableExpense` | string | no | The billable-expense status for this line. Values include 'yes', 'no' and 'skipped'. |
| `createLines[].lineType` | string | no | The kind of line. Values include 'expense' (a one-time cost) and 'prepaidExpense' (an upfront cost spread over several periods). Defaults to 'expense'. |
| `createLines[].amortizationSchedules` | array<object> | no | The amortization schedules to defer this line over, one per accounting book. A new line has nothing to change or remove, so this is a plain array, the same shape POST accounting/vendor-bills takes. |
| `createLines[].amortizationSchedules[].bookId` | string | no | The accounting book this schedule posts into. See id on GET accounting/books/:id. Omit it on a single-book entity to use that entity's default transaction book. |
| `createLines[].amortizationSchedules[].deferredAccountId` | string | no | The general ledger account the deferred balance sits on until it is recognized. See id on GET accounting/accounts/:id. Defaults to the line's own accountId. |
| `createLines[].amortizationSchedules[].recognitionAccountId` | string | yes | The general ledger account each installment recognizes the expense into. See id on GET accounting/accounts/:id. |
| `createLines[].amortizationSchedules[].amortizationMethod` | string | yes | How the schedule spreads its total. Values include 'exactDays', 'pointInTime', 'straightLine', 'straightLineProRateFirstLast' and 'usageBased'. |
| `createLines[].amortizationSchedules[].amortizationStartDate` | date | yes | The first day the schedule amortizes over. Format YYYY-MM-DD. It must not be after amortizationEndDate. |
| `createLines[].amortizationSchedules[].amortizationEndDate` | date | yes | The last day the schedule amortizes over, inclusive. Format YYYY-MM-DD. |
| `createLines[].amortizationSchedules[].term` | decimal | yes | The number of months the schedule spreads over. A count, not an amount, so it carries no currency. |
| `createLines[].amortizationSchedules[].description` | string | no | A note to record against the schedule. |
| `updateLines` | array<object> | no | Lines to change, each addressed by the id the bill publishes. Every field but the id is optional and left unchanged when omitted. Omit for no changes. Example: `[{"id":"7a1b2c3d-4e5f-6071-8293-a4b5c6d7e8f9","amount":"1350.00"}]`. |
| `updateLines[].id` | string | yes | The unique identifier for the line to change. It must belong to this bill. |
| `updateLines[].amount` | decimal | no | The total line amount, gross, as a decimal in the bill currency. Omit to leave unchanged. |
| `updateLines[].description` | string | no | A description of the line item. Omit to leave unchanged. |
| `updateLines[].accountId` | string | no | The GL expense account this line posts to. See id on GET accounting/accounts/:id. Omit to leave unchanged. |
| `updateLines[].departmentId` | string | no | The department this line is charged to. See id on GET people/departments/:id. Omit to leave unchanged. |
| `updateLines[].businessUnitId` | string | no | The business unit this line is charged to. There is no endpoint for it. Omit to leave unchanged. |
| `updateLines[].crossChargeEntityId` | string | no | The legal entity this line is cross charged to (Charge to). See id on GET base/entities. Omit to leave unchanged. It must differ from the bill's entity, and cross charging must be set up for both entities, or the request fails with CROSS_CHARGE_INVALID. |
| `updateLines[].customerId` | string | no | The customer this expense is rebilled to. See id on GET accounting/customers/:id. Omit to leave unchanged. |
| `updateLines[].vatPercentage` | decimal | no | The VAT rate applied, as a percentage. 19 means 19%, not 0.19. Omit to leave unchanged. |
| `updateLines[].vatAccountId` | string | no | The general ledger account the VAT posts to. See id on GET accounting/accounts/:id. Omit to leave unchanged. |
| `updateLines[].reverseVatAccountId` | string | no | The general ledger account reverse-charge VAT posts to. See id on GET accounting/accounts/:id. Omit to leave unchanged. |
| `updateLines[].vatAmount` | decimal | no | The explicit VAT amount, as a decimal in the bill currency. Omit to leave unchanged. |
| `updateLines[].valueAllocationId` | string | no | The value-allocation rule distributing this line across dimensions. There is no endpoint for it. Omit to leave unchanged. |
| `updateLines[].purchaseOrderLineId` | string | no | The purchase-order line this line is matched against. There is no endpoint for it. Omit to leave unchanged. |
| `updateLines[].billableExpense` | string | no | The billable-expense status for this line. Values include 'yes', 'no' and 'skipped'. Omit to leave unchanged. |
| `updateLines[].lineType` | string | no | The kind of line. Values include 'expense' and 'prepaidExpense'. Omit to leave unchanged. |
| `updateLines[].createAmortizationSchedules` | array<object> | no | Amortization schedules to add to this line, each with no id. Omit for no additions. Send none of the three amortization arrays to leave this line's schedules exactly as they are. |
| `updateLines[].createAmortizationSchedules[].bookId` | string | no | The accounting book this schedule posts into. See id on GET accounting/books/:id. Omit it on a single-book entity to use that entity's default transaction book. |
| `updateLines[].createAmortizationSchedules[].deferredAccountId` | string | no | The general ledger account the deferred balance sits on until it is recognized. See id on GET accounting/accounts/:id. Defaults to the accountId sent on this updateLines item. If that item doesn't send accountId, send deferredAccountId. |
| `updateLines[].createAmortizationSchedules[].recognitionAccountId` | string | yes | The general ledger account each installment recognizes the expense into. See id on GET accounting/accounts/:id. |
| `updateLines[].createAmortizationSchedules[].amortizationMethod` | string | yes | How the schedule spreads its total. Values include 'exactDays', 'pointInTime', 'straightLine', 'straightLineProRateFirstLast' and 'usageBased'. |
| `updateLines[].createAmortizationSchedules[].amortizationStartDate` | date | yes | The first day the schedule amortizes over. Format YYYY-MM-DD. It must not be after amortizationEndDate. |
| `updateLines[].createAmortizationSchedules[].amortizationEndDate` | date | yes | The last day the schedule amortizes over, inclusive. Format YYYY-MM-DD. |
| `updateLines[].createAmortizationSchedules[].term` | decimal | yes | The number of months the schedule spreads over. A count, not an amount, so it carries no currency. |
| `updateLines[].createAmortizationSchedules[].description` | string | no | A note to record against the schedule. |
| `updateLines[].updateAmortizationSchedules` | array<object> | no | Amortization schedules to change, each addressed by the id the bill publishes. A schedule that has already started recognizing is refused with AMORTIZATION_SCHEDULE_POSTED. Omit for no changes. |
| `updateLines[].updateAmortizationSchedules[].id` | string | yes | The identifier of the schedule to change. It must be one this line already carries. |
| `updateLines[].updateAmortizationSchedules[].bookId` | string | no | The accounting book this schedule posts into. See id on GET accounting/books/:id. Omit to leave unchanged. |
| `updateLines[].updateAmortizationSchedules[].deferredAccountId` | string | no | The general ledger account the deferred balance sits on until it is recognized. See id on GET accounting/accounts/:id. Omit to leave unchanged, unless this updateLines item also sends accountId, in which case it is set to that account. |
| `updateLines[].updateAmortizationSchedules[].recognitionAccountId` | string | no | The general ledger account each installment recognizes the expense into. See id on GET accounting/accounts/:id. Omit to leave unchanged. |
| `updateLines[].updateAmortizationSchedules[].amortizationMethod` | string | no | How the schedule spreads its total. Values include 'exactDays', 'pointInTime', 'straightLine', 'straightLineProRateFirstLast' and 'usageBased'. Omit to leave unchanged. |
| `updateLines[].updateAmortizationSchedules[].amortizationStartDate` | date | no | The first day the schedule amortizes over. Format YYYY-MM-DD. Omit to leave unchanged. |
| `updateLines[].updateAmortizationSchedules[].amortizationEndDate` | date | no | The last day the schedule amortizes over, inclusive. Format YYYY-MM-DD. Omit to leave unchanged. |
| `updateLines[].updateAmortizationSchedules[].term` | decimal | no | The number of months the schedule spreads over. Omit to leave unchanged. |
| `updateLines[].updateAmortizationSchedules[].description` | string | no | A note to record against the schedule. Omit to leave unchanged. |
| `updateLines[].deleteAmortizationSchedules` | array<string> | no | The identifiers of amortization schedules to remove from this line. Each must be one this line carries, and one that has not started recognizing. Removing a schedule leaves this line's other books untouched. |
| `deleteLines` | array<string> | no | The identifiers of lines to remove, applied before the updates and creates. Each must belong to this bill. Removing a line also removes the amortization schedules it carried. Example: `["1f2e3d4c-5b6a-7089-9a8b-7c6d5e4f3a2b"]`. |

```json
{
  "billNumber": "<billNumber>",
  "billDate": "2026-01-15",
  "dueDate": "2026-09-15",
  "serviceDate": "2026-01-15",
  "currency": "<currency>",
  "paymentTerms": "<paymentTerms>",
  "vendorId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "entityId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "markAsPaid": true,
  "origin": "<origin>",
  "createLines": [
    {
      "amount": "19.99",
      "description": "<description>",
      "accountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "departmentId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "businessUnitId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "crossChargeEntityId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "customerId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "vatPercentage": "19.99",
      "vatAccountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "reverseVatAccountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "vatAmount": "19.99",
      "valueAllocationId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "purchaseOrderLineId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "billableExpense": "<billableExpense>",
      "lineType": "<lineType>",
      "amortizationSchedules": [
        {
          "bookId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "deferredAccountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "recognitionAccountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "amortizationMethod": "<amortizationMethod>",
          "amortizationStartDate": "2026-01-15",
          "amortizationEndDate": "2026-01-15",
          "term": "19.99",
          "description": "<description>"
        }
      ]
    }
  ],
  "updateLines": [
    {
      "id": "7a1b2c3d-4e5f-6071-8293-a4b5c6d7e8f9",
      "amount": "1350.00"
    }
  ],
  "deleteLines": [
    "1f2e3d4c-5b6a-7089-9a8b-7c6d5e4f3a2b"
  ]
}
```

## Response

`200` Success

```json
{
  "data": {},
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}
```

## Response headers

- `Idempotency-Replayed` — Present and `true` only when this response replays a previously stored one for the same Idempotency-Key, rather than reflecting a live execution. Absent on a live response - never sent as `false`.

## Errors

| Code | Status |
| --- | --- |
| `NOT_FOUND` | 400 |
| `REFERENCE_NOT_FOUND` | 400 |
| `LINE_NOT_FOUND` | 400 |
| `ACCOUNT_ENTITY_MISMATCH` | 400 |
| `CROSS_CHARGE_INVALID` | 400 |
| `TOO_MANY_LINES` | 400 |
| `AMORTIZATION_SCHEDULE_NOT_FOUND` | 400 |
| `AMORTIZATION_SCHEDULE_POSTED` | 400 |
| `AMORTIZATION_NOT_ALLOWED_ON_LINE` | 400 |
| `AMORTIZATION_DATE_RANGE_INVALID` | 400 |
| `AMORTIZATION_BOOK_NOT_CONFIGURED` | 400 |
| `DUPLICATE_AMORTIZATION_BOOK` | 400 |
| `AMORTIZATION_TERM_MISMATCH` | 400 |
| `AMORTIZATION_METHOD_INVALID` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Statuses

- `400` — Invalid request or business failure. Codes: NOT_FOUND, REFERENCE_NOT_FOUND, LINE_NOT_FOUND, ACCOUNT_ENTITY_MISMATCH, CROSS_CHARGE_INVALID, TOO_MANY_LINES, AMORTIZATION_SCHEDULE_NOT_FOUND, AMORTIZATION_SCHEDULE_POSTED, AMORTIZATION_NOT_ALLOWED_ON_LINE, AMORTIZATION_DATE_RANGE_INVALID, AMORTIZATION_BOOK_NOT_CONFIGURED, DUPLICATE_AMORTIZATION_BOOK, AMORTIZATION_TERM_MISMATCH, AMORTIZATION_METHOD_INVALID
- `401` — The request carries no valid access token.
- `403` — Not authorized
- `404` — Not found
- `409` — The Idempotency-Key is still being processed by another request.
- `422` — The Idempotency-Key was already used with a different request payload.
- `429` — Too many requests from this client address. The response has no body and no `Retry-After` header.
- `500` — Internal server error
