# Work orders (/docs/guides/work-orders)



Production orders are the unit of work in Factory OS. Each order references a product, a target quantity, and a planned schedule.

## Create a production order [#create-a-production-order]

```bash
curl -X POST https://api.xentr.ai/api/factories/[factory-slug]/production-orders \
  -H "Authorization: Bearer $XENTR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": "a1b2c3d4-...",
    "quantityTarget": 1000,
    "plannedStart": "2026-04-20T08:00:00Z",
    "plannedEnd": "2026-04-20T16:00:00Z"
  }'
```

## Lifecycle [#lifecycle]

```
draft → scheduled → running → completed
                         ↓
                     cancelled
```

* `draft` — created, not yet scheduled
* `scheduled` — assigned a machine + time window
* `running` — production in progress, consuming telemetry
* `completed` — quantity met, order closed
* `cancelled` — explicitly stopped

Transitions happen via dedicated endpoints (`/start`, `/complete`, `/cancel`) — not by `PATCH status`.

## Splits [#splits]

A single order can be split across machines or shifts:

```json
{
  "splits": [
    { "machineCode": "CNC-001", "quantity": 600 },
    { "machineCode": "CNC-002", "quantity": 400 }
  ]
}
```

## Tracking progress [#tracking-progress]

OEE metrics and produced-part counts roll up automatically from machine telemetry linked to the order's machine(s). Query the [Production Orders API](/docs/api-reference/production-orders) for live counts.

## Audit trail [#audit-trail]

Every state change is audit-logged with the user, timestamp, and before/after values. See [Audit API](/docs/api-reference/audit).
