# PUT /api/v1/inventory/landed-cost-allocations/{bill_id}

> Replace a bill's landed cost allocations

- **Tag:** inventory:landed_cost_allocations
- **Operation ID:** `replace_allocations_api_v1_inventory_landed_cost_allocations__bill_id__put`

## Description

Set the full list of landed-cost allocations for a bill. Existing allocations are reversed first, then the requested targets are applied to the cost snapshots — idempotent. The allocated total may not exceed the bill amount.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Parameters

- `bill_id` (path, string, required)

## Request body

Schema: `LandedCostAllocationCreateRequest`

- `targets` (array · LandedCostAllocationTarget) → `LandedCostAllocationTarget`
  - `inventory_order_id` (string · required) — Received PO whose goods absorb this cost.
  - `cost_layer` (LandedCostLayer · required) → `LandedCostLayer` — Landed-cost layer the amount feeds (freight/duties/handling).
  - `amount_cents` (integer · required) — Slice of the bill assigned to this PO, in cents.
  - `allocation_basis` (AllocationBasis) → `AllocationBasis` — How the amount is spread across the PO's variants.
  - `note` (string)

## Responses

### 200 — Successful Response

Schema: `SuccessEnvelope_LandedCostAllocationListResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (LandedCostAllocationListResponse)

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 404 — Not Found - Resource does not exist

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X PUT 'https://api.ondayzero.com/api/v1/inventory/landed-cost-allocations/{bill_id}' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "targets": []
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/inventory/landed-cost-allocations/{bill_id}', {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "targets": []
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {
  "targets": []
}

response = httpx.put("https://api.ondayzero.com/api/v1/inventory/landed-cost-allocations/{bill_id}", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/inventory-landed-cost-allocations/replace-allocations
- OpenAPI slice: https://www.ondayzero.com/docs/reference/inventory-landed-cost-allocations/replace-allocations/openapi.json
- Other endpoints in **inventory:landed_cost_allocations**: https://www.ondayzero.com/docs/reference/inventory-landed-cost-allocations
