# 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-time) — Expected delivery date (ISO 8601).
- `payment_term_id` (string) — Payment term ID for net terms (defaults to vendor's).
- `expected_paid_on` (string · date-time) — Expected payment date (ISO 8601). Auto-calculated from delivery + net terms if not provided.

## Responses

### 201 — Successful Response

Schema: `OrderResponse`

- `id` (string · required) — Order UUID.
- `vendor_id` (string · required) — Vendor UUID.
- `vendor_name` (string) — Vendor name (resolved).
- `vendor_email` (string) — Vendor email (resolved).
- `status` (string · required) — Order status.
- `name` (string · required) — Order name.
- `business_id` (string) — Business UUID.
- `po_number` (string · required) — Purchase order number.
- `line_items` (array · object · required) — Order line items.
- `fees` (array · Fee · required) → `Fee` — Additional fees.
  - `name` (string) — Fee name (e.g., 'Shipping', 'Handling').
  - `description` (string) — Fee description (alternative to name).
  - `amount` (integer · required) — Fee amount in cents.
- `payments` (array · Payment-Output · required) → `Payment-Output` — Payment records.
  - `id` (string) — Payment UUID.
  - `paid_on` (string · date-time) — Payment date.
  - `date` (string · date-time) — Payment date (alias for paid_on).
  - `amount` (integer · required) — Payment amount in cents.
  - `inventory_order_id` (string) — Parent order UUID.
  - `method` (string) — Payment method (e.g., 'check', 'wire', 'credit_card').
- `description` (string) — Order notes.
- `total` (integer) — Total amount in cents.
- `balance` (integer) — Remaining balance in cents.
- `shipments` (array · object) — Associated shipments.
- `created_at` (string · date-time · required) — Creation timestamp.
- `updated_at` (string · date-time · required) — Last update timestamp.
- `version` (integer) — Version for optimistic locking.
- `shipping_cost` (integer) — Freight/shipping cost in cents.
- `ship_from_location_id` (string) — Source location UUID.
- `ship_to_location_id` (string) — Destination location UUID.
- `ship_from_location_name` (string) — Resolved source location name.
- `ship_to_location_name` (string) — Resolved destination location name.
- `production_run_id` (string) — Linked production run UUID.
- `transfer_id` (string) — Linked inventory transfer UUID.
- `expected_delivery_date` (string · date-time) — Expected delivery date.
- `payment_term_id` (string) — Payment term UUID for net terms.
- `payment_term_name` (string) — Resolved payment term name (e.g., 'Net 30').
- `payment_term_days` (integer) — Days until due from the payment term.
- `expected_paid_on` (string · date-time) — Expected payment date.
- `bill_id` (string) — UUID of the Bill linked to this PO, if any.
- `bill_status` (string) — Status of the linked bill: forecasted, received, partially_paid, paid, draft, or canceled.
- `bill_amount` (integer) — Linked bill amount in cents.
- `bill_received_on` (string · date-time) — Timestamp the linked bill was marked received from the vendor.
- `bill_paid_on` (string · date-time) — Timestamp the linked bill was marked fully paid.

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