# Update Vendor Credit

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

Group: Accounting › Vendor Credits · Operation ID: `updateVendorCredit`

Updates the vendor credit with the given identifier. Only the fields in the request body change.

Only the fields in the request body change. The vendor and the legal entity cannot be changed, because moving a credit to a different vendor or entity changes which bills it can offset, so that is a new credit. Lines change through three arrays, applied in the order delete, then update, then create in one transaction, so one call can retire a line and add its replacement. updateLines and deleteLines address lines by the id the credit publishes, and a line id belonging to another credit is refused with LINE_NOT_FOUND. Omit all three to leave the lines untouched. The response is empty. Read the record with GET accounting/vendor-credits/:id.

[Open in the interactive reference](https://docs.api.lensing.ai/?op=updateVendorCredit)

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Api-Version` | header | `"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 for the vendor credit to update. |

## Request body

Required, `application/json`: updateVendorCreditInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `referenceNumber` | string | no | The vendor's credit memo reference number, as printed on the document. Omit to leave unchanged. |
| `creditDate` | string (date) | no | The date on the vendor's credit memo. Use format YYYY-MM-DD. Omit to leave unchanged. |
| `currency` | string | no | The currency of the credit. Format ISO 4217, for example 'USD'. 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 of object | no | Lines to add to the credit, each with the same shape as on create and no id. Omit for no additions. |
| `createLines[].amount` | string (decimal) | yes | The gross credit amount for the line, as a decimal in the credit currency. |
| `createLines[].description` | string | no | A description of the credit line. |
| `createLines[].accountId` | string | no | The GL account this line credits. See id on GET accounting/accounts/:id. |
| `createLines[].departmentId` | string | no | The department this line is allocated to. See id on GET departments/:id. |
| `createLines[].businessUnitId` | string | no | The business unit this line is allocated to. There is no endpoint for it. |
| `createLines[].vatPercentage` | string (decimal) | no | The VAT rate applied, as a percentage. 19 means 19%, not 0.19. |
| `createLines[].vatAccountId` | string | no | The GL account the VAT posts to. See id on GET accounting/accounts/:id. |
| `createLines[].reverseVatAccountId` | string | no | The GL account reverse-charge VAT posts to. See id on GET accounting/accounts/:id. |
| `createLines[].vatAmount` | string (decimal) | no | The explicit VAT amount, as a decimal in the credit 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[].lineType` | string | no | The kind of line. Accepted values: 'expense' (a one-time credit) or 'prepaid' (a credit spread over several periods). Defaults to 'expense'. |
| `updateLines` | array of object | no | Lines to change, each addressed by the id the credit publishes. Every field but the id is optional and left unchanged when omitted. Omit for no changes. |
| `updateLines[].id` | string | yes | The unique identifier for the line to change. It must belong to this credit. |
| `updateLines[].amount` | string (decimal) | no | The gross credit amount for the line, as a decimal in the credit currency. Omit to leave unchanged. |
| `updateLines[].description` | string | no | A description of the credit line. Omit to leave unchanged. |
| `updateLines[].accountId` | string | no | The GL account this line credits. See id on GET accounting/accounts/:id. Omit to leave unchanged. |
| `updateLines[].departmentId` | string | no | The department this line is allocated to. See id on GET departments/:id. Omit to leave unchanged. |
| `updateLines[].businessUnitId` | string | no | The business unit this line is allocated to. There is no endpoint for it. Omit to leave unchanged. |
| `updateLines[].vatPercentage` | string (decimal) | no | The VAT rate applied, as a percentage. 19 means 19%, not 0.19. Omit to leave unchanged. |
| `updateLines[].vatAccountId` | string | no | The GL account the VAT posts to. See id on GET accounting/accounts/:id. Omit to leave unchanged. |
| `updateLines[].reverseVatAccountId` | string | no | The GL account reverse-charge VAT posts to. See id on GET accounting/accounts/:id. Omit to leave unchanged. |
| `updateLines[].vatAmount` | string (decimal) | no | The explicit VAT amount, as a decimal in the credit currency. Omit to derive it from vatPercentage. |
| `updateLines[].valueAllocationId` | string | no | The value-allocation rule distributing this line across dimensions. There is no endpoint for it. Omit to leave unchanged. |
| `updateLines[].lineType` | string | no | The kind of line. Accepted values: 'expense' (a one-time credit) or 'prepaid' (a credit spread over several periods). Omit to leave unchanged. |
| `deleteLines` | array of string | no | The identifiers of lines to remove, applied before the updates and creates. Each must belong to this credit. |

Example:

```json
{
  "referenceNumber": "CN-4471-A",
  "creditDate": "2026-01-15",
  "currency": "<currency>",
  "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",
      "vatPercentage": "19.99",
      "vatAccountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "reverseVatAccountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "vatAmount": "19.99",
      "valueAllocationId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "lineType": "<lineType>"
    }
  ],
  "updateLines": [
    {
      "id": "6b2a9f18-7c3d-4e5a-8b19-2d4e6f8a0c31",
      "amount": "350.00"
    }
  ],
  "deleteLines": [
    "<deleteLines>"
  ]
}
```

## Response

`200` Success

## 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 |
| `TOO_MANY_LINES` | 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, TOO_MANY_LINES
- `401` — Missing or invalid 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
- `500` — Internal server error
