# POST /api/v1/inventory/products/unit-costs/preview

> Preview unit cost bulk update

- **Tag:** inventory:products
- **Operation ID:** `preview_unit_cost_bulk_update_api_v1_inventory_products_unit_costs_preview_post`

## Description

Validate parsed CSV rows and preview cost changes before applying.

## Authentication

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

## Request body

Schema: `UnitCostBulkPreviewRequest`

- `rows` (array · UnitCostBulkUpdateRowInput · required) → `UnitCostBulkUpdateRowInput` — Rows from the uploaded CSV after client-side parsing.
  - `row_number` (integer · required) — 1-based row number from the spreadsheet.
  - `sku` (string · required) — Variant SKU.
  - `variant_id` (string) — Optional variant UUID; when set, used instead of SKU matching.
  - `new_unit_cost_cents` (integer) — New unit cost in cents. Omit or null to skip the row.

## Responses

### 201 — Successful Response

Schema: `UnitCostBulkPreviewResponse`

- `total_rows` (integer · required)
- `to_update` (integer · required)
- `unchanged` (integer · required)
- `skipped` (integer · required)
- `errors` (integer · required)
- `rows` (array · UnitCostBulkPreviewRow · required) → `UnitCostBulkPreviewRow`
  - `row_number` (integer · required)
  - `variant_id` (string)
  - `sku` (string · required)
  - `product_name` (string)
  - `variant_name` (string)
  - `current_unit_cost_cents` (integer)
  - `new_unit_cost_cents` (integer)
  - `status` (string · required) — update | unchanged | skip | error
  - `error_message` (string)

### 400 — Bad Request - Invalid input

### 422 — Validation Error - Invalid data format

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/inventory/products/unit-costs/preview' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "rows": []
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/inventory/products/unit-costs/preview', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "rows": []
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {
  "rows": []
}

response = httpx.post("https://api.ondayzero.com/api/v1/inventory/products/unit-costs/preview", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/inventory-products/preview-unit-cost-bulk-update
- OpenAPI slice: https://www.ondayzero.com/docs/reference/inventory-products/preview-unit-cost-bulk-update/openapi.json
- Other endpoints in **inventory:products**: https://www.ondayzero.com/docs/reference/inventory-products
