# POST /api/v1/purchase-orders

> Create inventory order

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

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

## Example request

```json
{
  "description": "Monthly restock order",
  "fees": [
    {
      "amount": 5000,
      "name": "Shipping"
    }
  ],
  "line_items": [
    {
      "quantity": 100,
      "unit_price": 1200,
      "variant_id": "019ab37c-0a71-7000-8000-000000000001"
    }
  ],
  "name": "January Inventory Restock",
  "po_number": "PO-2024-001",
  "status": "draft",
  "vendor_id": "019ab37c-ae0d-7000-8000-000000000001"
}
```

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

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 401 — Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 403 — Forbidden - Insufficient permissions

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 422 — Validation Error

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

## 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 '{
  "description": "Monthly restock order",
  "fees": [
    {
      "amount": 5000,
      "name": "Shipping"
    }
  ],
  "line_items": [
    {
      "quantity": 100,
      "unit_price": 1200,
      "variant_id": "019ab37c-0a71-7000-8000-000000000001"
    }
  ],
  "name": "January Inventory Restock",
  "po_number": "PO-2024-001",
  "status": "draft",
  "vendor_id": "019ab37c-ae0d-7000-8000-000000000001"
}'
```

### 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({
  "description": "Monthly restock order",
  "fees": [
    {
      "amount": 5000,
      "name": "Shipping"
    }
  ],
  "line_items": [
    {
      "quantity": 100,
      "unit_price": 1200,
      "variant_id": "019ab37c-0a71-7000-8000-000000000001"
    }
  ],
  "name": "January Inventory Restock",
  "po_number": "PO-2024-001",
  "status": "draft",
  "vendor_id": "019ab37c-ae0d-7000-8000-000000000001"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {'description': 'Monthly restock order',
 'fees': [{'amount': 5000, 'name': 'Shipping'}],
 'line_items': [{'quantity': 100,
                 'unit_price': 1200,
                 'variant_id': '019ab37c-0a71-7000-8000-000000000001'}],
 'name': 'January Inventory Restock',
 'po_number': 'PO-2024-001',
 'status': 'draft',
 'vendor_id': '019ab37c-ae0d-7000-8000-000000000001'}

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 (markdown bundle: https://www.ondayzero.com/docs/reference/purchase-orders.md, OpenAPI: https://www.ondayzero.com/docs/reference/purchase-orders/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
