# PUT /api/v1/purchase-orders/{id}

> Update inventory order

- **Tag:** purchase-orders
- **Operation ID:** `update_order_api_v1_purchase_orders__id__put`

## Description

Update purchase order details with optimistic locking support.

## Authentication

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

## Parameters

- `id` (path, string · uuid, required)

## Request body

Schema: `InventoryOrderUpdate`

- `vendor_id` (string) — Updated vendor UUID.
- `status` (string) — Updated status.
- `name` (string) — Updated name.
- `po_number` (string) — Updated PO number.
- `line_items` (array · LineItem) — Replace line items.
- `fees` (array · Fee) — Replace fees.
- `payments` (array · Payment-Input) — Replace payments.
- `description` (string) — Updated notes.
- `total` (integer) — Updated total in cents.
- `balance` (integer) — Updated balance in cents.
- `version` (integer) — Version for optimistic locking (prevents concurrent updates).
- `shipping_cost` (integer) — Freight/shipping cost in cents.
- `ship_from_location_id` (string) — Source location.
- `ship_to_location_id` (string) — Destination location.
- `production_run_id` (string) — Linked production run.
- `expected_delivery_date` (string · date) — Updated expected delivery date (YYYY-MM-DD).
- `payment_term_id` (string) — Updated payment term ID.
- `expected_paid_on` (string · date) — Updated expected payment date (YYYY-MM-DD).

## Responses

### 200 — Successful Response

Schema: `app__core__success__SuccessEnvelope_OrderResponse___2`

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

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

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

### 409 — Conflict - Resource already exists

### 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/purchase-orders/{id}' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "vendor_id": "string",
  "status": "string",
  "name": "string",
  "po_number": "string",
  "line_items": [],
  "fees": []
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/purchase-orders/{id}', {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "vendor_id": "string",
  "status": "string",
  "name": "string",
  "po_number": "string",
  "line_items": [],
  "fees": []
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {
  "vendor_id": "string",
  "status": "string",
  "name": "string",
  "po_number": "string",
  "line_items": [],
  "fees": []
}

response = httpx.put("https://api.ondayzero.com/api/v1/purchase-orders/{id}", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/purchase-orders/update-order
- OpenAPI slice: https://www.ondayzero.com/docs/reference/purchase-orders/update-order/openapi.json
- Other endpoints in **purchase-orders**: https://www.ondayzero.com/docs/reference/purchase-orders
