# Update a landed cost

Operation ID: `updateLandedCost`

Group: Inventory › Landed Costs

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

`PATCH /inventory/landed-costs/{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 landed cost with the fields you send. A field you leave out keeps its current value.

When you send receipts or charges, the list you send replaces the whole list, so include every receipt or charge you want to keep.

The response contains the `id` and the `allocationLineCount`. To see the new allocation, use GET inventory/landed-costs/: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 landed cost you want to update. Format: UUID. |

## Request body

Required, `application/json`: updateLandedCostInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `documentDate` | date | no | The date of the landed cost. Format: YYYY-MM-DD. The inventory revaluations that the commit creates have this date, so it sets the date of the change in the stock's value. It must fall in an open accounting period. |
| `notes` | string | no | Free text on the landed cost. |
| `receipts` | array<object> | no | The receipts whose stock the charges are spread over. Send at least one. Every receipt must have the `documentStatus` 'COMMITTED'. |
| `receipts[].receiptId` | string | yes | The unique identifier of the receipt. Format: UUID. See `id` on GET inventory/receipts/:id (getReceipt). |
| `receipts[].selectedLineIds` | array<string> | no | The unique identifiers of the receipt lines to spread the charges over. Format: UUID. Each identifier must be the `id` of a line of the receipt named by `receiptId`. Omit to spread the charges over all of the receipt's lines. See `lines[].id` on GET inventory/receipts/:id (getReceipt). |
| `charges` | array<object> | no | The charges to spread over the stock. Each charge comes from a line of an approved vendor bill. Send at least one. Example: `[{"chargeId":"9c47e1b8-2a63-4d05-b7f9-04e28d5a1c37","allocationMode":"LineTotal","amount":"300"}]`. |
| `charges[].chargeId` | string | yes | The unique identifier of the vendor bill line the charge comes from. Format: UUID. The vendor bill is taken from the line, so you do not send it. See `id` on GET inventory/landed-costs/vendor-bill-lines (getAvailableCharges). |
| `charges[].allocationMode` | string | no | How the charge is spread (allocated) over the receipt lines. Required. 'Weight' needs a gross weight, weight, or net weight on the item of every selected receipt line. 'Volume' needs a volume per unit on the item of every selected receipt line, or else a length, width, and height on every one. Weights and volumes are converted to the same unit before the charge is spread. See `grossWeight`, `weight`, `netWeight`, `weightUnit`, `volumePerUnit`, `volumeUnit`, `length`, `width`, and `height` on GET inventory/items/:id (getItem). Accepted values: 'Equal', 'Quantity', 'LineTotal', 'Weight', 'Volume'. |
| `charges[].amount` | decimal | yes | The amount of the vendor bill line to use, in the functional currency of the landed cost's legal entity. It must be more than 0. To use what is left on the line, send `functionalLineTotal` minus `functionalAllocatedAmount` from GET inventory/landed-costs/vendor-bill-lines. The commit fails if this amount is more than what is left on the line. |
| `charges[].isSelected` | boolean | no | Whether to spread the charge over the receipt lines. Defaults to true. A charge set to false is kept in the landed cost's charges, so you can set it back to true later, but the commit does not spread it. |

```json
{
  "documentDate": "2026-01-15",
  "notes": "<notes>",
  "receipts": [
    {
      "receiptId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "selectedLineIds": [
        "<selectedLineIds>"
      ]
    }
  ],
  "charges": [
    {
      "chargeId": "9c47e1b8-2a63-4d05-b7f9-04e28d5a1c37",
      "allocationMode": "LineTotal",
      "amount": "300"
    }
  ]
}
```

## Response

`200` Success

Under `data` (updateLandedCostOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | The unique identifier for the landed cost. Format: UUID. Example: `"6d18b2f0-49c7-4a35-9e81-2f0c5a7d3b64"`. |
| `allocationLineCount` | number | no | The number of allocation lines on the landed cost. There is one allocation line for each selected receipt line that has an inventory item and takes a share of the charges. When it is 0, no stock takes a share of the charges, and committing the landed cost fails. Example: `1`. |

```json
{
  "data": {
    "id": "6d18b2f0-49c7-4a35-9e81-2f0c5a7d3b64",
    "allocationLineCount": 1
  },
  "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 |
| `WRONG_STATUS` | 400 |
| `REFERENCE_NOT_FOUND` | 400 |
| `NO_RECEIPTS` | 400 |
| `NO_CHARGES` | 400 |
| `RECEIPT_NOT_COMMITTED` | 400 |
| `VENDOR_BILL_NOT_APPROVED` | 400 |
| `INVALID_AMOUNT` | 400 |
| `UNKNOWN_ALLOCATION_MODE` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Statuses

- `400` — Invalid request or business failure. Codes: NOT_FOUND, WRONG_STATUS, REFERENCE_NOT_FOUND, NO_RECEIPTS, NO_CHARGES, RECEIPT_NOT_COMMITTED, VENDOR_BILL_NOT_APPROVED, INVALID_AMOUNT, UNKNOWN_ALLOCATION_MODE
- `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
