# POST /api/v1/purchase-orders

> Create inventory order

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

## Description

Create a new purchase order for inventory restocking.

## Authentication

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

## Request body

Schema: `InventoryOrderCreate`

- `vendor_id` (string · required) — Vendor UUID.
- `status` (string · required) — Order status (draft, submitted, confirmed, received, cancelled).
- `name` (string · required) — Order name/title.
- `po_number` (string · required) — Purchase order number.
- `line_items` (array · LineItem) — Products being ordered.
- `fees` (array · Fee) — Additional fees (shipping, handling, etc.).
- `payments` (array · Payment-Input) — Payments made on this order.
- `description` (string) — Order notes.
- `total` (integer) — Total order amount in cents (calculated if not provided).
- `balance` (integer) — Remaining balance in cents (total minus payments).
- `shipping_cost` (integer) — Freight/shipping cost in cents.
- `ship_from_location_id` (string) — Source location; defaults to vendor.default_location_id.
- `ship_to_location_id` (string) — Destination location.
- `production_run_id` (string) — Linked production run (for copacker orders).
- `expected_delivery_date` (string · date) — Expected delivery date (YYYY-MM-DD).
- `payment_term_id` (string) — Payment term ID for net terms (defaults to vendor's).
- `expected_paid_on` (string · date) — Expected payment date (YYYY-MM-DD). Auto-calculated from delivery + net terms if not provided.

## Responses

### 201 — 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

### 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 POST 'https://api.ondayzero.com/api/v1/purchase-orders' \
  -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"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/purchase-orders', {
  method: 'POST',
  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"
}),
});
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"
}

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

## See also

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