# GET /api/v1/inventory/cost-history

> Landed COGS history

- **Tag:** inventory:cost_history
- **Operation ID:** `get_cost_history_api_v1_inventory_cost_history_get`

## Description

Return cost snapshots grouped by variant for the last N months. Powers the Landed COGS sparkline + material/freight/processing breakdown.

## Authentication

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

## Parameters

- `months` (query, integer, optional) — Window size in months (default 12).

## Responses

### 200 — Successful Response

Schema: `CostHistoryResponse`

- `window_months` (integer · required)
- `variants` (array · VariantCostHistory · required) → `VariantCostHistory`
  - `variant_id` (string · required)
  - `variant_name` (string)
  - `variant_sku` (string)
  - `product_id` (string)
  - `product_name` (string)
  - `points` (array · CostSnapshotPoint)
  - `latest_total_per_unit` (integer)
  - `trailing_delta_pct` (number) — Percent change vs. the earliest point in the window. Null if <2 points.

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 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 GET 'https://api.ondayzero.com/api/v1/inventory/cost-history' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/inventory/cost-history', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
  },
});
const data = await response.json();
```

### Python

```python
import httpx

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

response = httpx.get("https://api.ondayzero.com/api/v1/inventory/cost-history", headers=headers)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/inventory-cost-history/get-cost-history
- OpenAPI slice: https://www.ondayzero.com/docs/reference/inventory-cost-history/get-cost-history/openapi.json
- Other endpoints in **inventory:cost_history**: https://www.ondayzero.com/docs/reference/inventory-cost-history
