# Update a vendor bill

Operation ID: `updateVendorBill`

Group: Accounting › Vendor Bills

[Open in the interactive reference](https://lensing.ai/api-docs/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.

attachments replaces the bill's whole set of files. To add an invoice PDF: upload it to `POST /public/files/{namespace}/updateVendorBill` (multipart/form-data), then send the attachments the bill already has by `id` plus the new one as `file`. `{namespace}` is the segment after `/public/api/` in your base URL.

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. |
| `taxReportingDate` | date | no | The date that decides which tax return the bill is reported in. Use format YYYY-MM-DD. A date sent here is kept only when taxReportingDateOverridden is true and the entity allows overriding it; otherwise it is calculated. Omit to leave it to its current rule: a calculated date is recalculated when billDate, serviceDate, postingPeriodId or entityId changes; a manually entered one is kept while the entity allows overriding it, and recalculated otherwise. |
| `taxReportingDateOverridden` | boolean | no | Send true with taxReportingDate to keep it as entered manually. Send false to hand the date back to the calculation. A taxReportingDate sent without it is calculated. |
| `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 decimal fraction. For example, 0.19 is 19%. It must match exactly one active purchase tax code of the entity's tax configuration, or the request fails with TAX_CODE_NOT_FOUND or TAX_CODE_AMBIGUOUS. Send taxCodeId when several tax codes share the rate. |
| `createLines[].taxCodeId` | string | no | The tax code this line is taxed under. See lines[].id on GET accounting/tax-configurations/:id. Sent without vatPercentage, the line takes the code's rate. |
| `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 \| null | no | The legal entity this line is cross charged to (Charge to). See id on GET base/entities. Omit to leave unchanged, or send null to clear it. 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 decimal fraction. For example, 0.19 is 19%. It must match exactly one active purchase tax code of the entity's tax configuration, or the request fails with TAX_CODE_NOT_FOUND or TAX_CODE_AMBIGUOUS. Send taxCodeId when several tax codes share the rate. |
| `updateLines[].taxCodeId` | string | no | The tax code this line is taxed under. See lines[].id on GET accounting/tax-configurations/:id. Sent without vatPercentage, the line takes the code's rate. |
| `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"]`. |
| `attachments` | array<object> \| null | no | The bill's attachments. Omit to keep them. A list you send **replaces the whole set**: keep an existing attachment by its `id`, add a new file as `file`. Send `null` or `[]` to remove them all. **Attach a file in two steps:** 1. **Upload** it: `POST /public/files/{namespace}/updateVendorBill` with a `multipart/form-data` body and the `Api-Version` header. The response returns an upload reference (`u1.…`). 2. **Send** that reference as `file` in this request. `{namespace}` is the segment after `/public/api/` in your base URL, as in the request example. A reference works only for updateVendorBill, only for you, and for a few minutes, so upload right before this call. Accepted types: pdf, tiff, jpeg, jpg, png, xls, xlsx, csv, xml, doc, docx, heic, heif. Up to 10 MB each, the same limit as the bill page. The upload route itself accepts up to 15 MB. |
| `attachments[].id` | string | no | An attachment the bill already has, to keep. See attachments[].id on GET accounting/vendor-bills/:id. |
| `attachments[].fileName` | string | no | The display name of a new file. Defaults to the uploaded file's name. Not accepted with `id`: a kept attachment keeps its name. |
| `attachments[].file` | file | no | A new file: the upload reference returned by `POST /public/files/{namespace}/updateVendorBill`, for example `u1.fIrOBkgwx7…`. Send exactly one of `id` or `file`. Any other value is refused with 400. |

```json
{}
```

## Response

`200` Success

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

## Files

- `attachments[].file` takes an upload reference: upload the file first as `multipart/form-data` to `POST /public/files/{namespace}/updateVendorBill` (with `Api-Version`), and send the `data.<part name>` value it returns.

## 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 |
| `BILL_LOCKED` | 400 |
| `LINE_NOT_FOUND` | 400 |
| `ACCOUNT_ENTITY_MISMATCH` | 400 |
| `CROSS_CHARGE_INVALID` | 400 |
| `TOO_MANY_LINES` | 400 |
| `INVALID_ATTACHMENT` | 400 |
| `UNSUPPORTED_FILE_TYPE` | 400 |
| `FILE_TOO_LARGE` | 400 |
| `ATTACHMENT_REQUIRED` | 400 |
| `AMORTIZATION_SCHEDULE_NOT_FOUND` | 400 |
| `AMORTIZATION_SCHEDULE_POSTED` | 400 |
| `TAX_CODE_NOT_FOUND` | 400 |
| `TAX_CODE_AMBIGUOUS` | 400 |
| `TAX_CODE_ACCOUNT_NOT_CONFIGURED` | 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, BILL_LOCKED, LINE_NOT_FOUND, ACCOUNT_ENTITY_MISMATCH, CROSS_CHARGE_INVALID, TOO_MANY_LINES, INVALID_ATTACHMENT, UNSUPPORTED_FILE_TYPE, FILE_TOO_LARGE, ATTACHMENT_REQUIRED, AMORTIZATION_SCHEDULE_NOT_FOUND, AMORTIZATION_SCHEDULE_POSTED, TAX_CODE_NOT_FOUND, TAX_CODE_AMBIGUOUS, TAX_CODE_ACCOUNT_NOT_CONFIGURED, 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
