# Schedule an order via the scheduling canvas — draft for all modes; a scheduled (not started, non-routed) order may be re-split with mode=split (/docs/api-reference/production-orders/ProductionOrdersController_schedule)

`POST /api/factories/{factoryId}/production-orders/{id}/schedule`

Base URL: https://api.xentr.ai

Authentication: bearer token (`Authorization: Bearer <token>`).

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `factoryId` | path | yes | string | Factory ID |
| `id` | path | yes | string | Production Order ID |

## Request body

Required.

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "machineId": {
      "type": "string",
      "description": "Target machine ID (single-machine modes)"
    },
    "methodId": {
      "type": "string",
      "description": "Production method ID (required unless splits provided)"
    },
    "plannedStart": {
      "type": "string",
      "description": "Planned start"
    },
    "plannedEnd": {
      "type": "string",
      "description": "Planned end"
    },
    "mode": {
      "type": "string",
      "description": "Assignment mode",
      "enum": [
        "single",
        "multi",
        "manual",
        "split"
      ]
    },
    "splits": {
      "description": "Split assignment: multiple machines with per-machine quantities",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "machineId": {
            "type": "string",
            "description": "Target machine id for this portion of the split.",
            "example": "a1b2c3d4-1111-2222-3333-444455556666"
          },
          "methodId": {
            "type": "string",
            "description": "Production method id to run on this machine.",
            "example": "a1b2c3d4-1111-2222-3333-444455556666"
          },
          "quantity": {
            "type": "number",
            "description": "Quantity assigned to this machine within the split.",
            "example": 500
          }
        },
        "required": [
          "machineId",
          "methodId",
          "quantity"
        ]
      }
    },
    "actualStart": {
      "type": "string",
      "description": "Backfill: actual start in the past. When provided, the order is marked as in_production (or completed if actualEnd is also set)."
    },
    "actualEnd": {
      "type": "string",
      "description": "Backfill: actual end. When provided alongside actualStart, transitions order to completed."
    },
    "backfillReason": {
      "type": "string",
      "description": "Required when actualStart is provided. Free-text justification."
    },
    "startNow": {
      "type": "boolean",
      "description": "Start the order immediately after scheduling. Transitions the order to in_production and sets actualStart = now on both the order and its first sub-order. Used by the \"Now\" option in the schedule dialog."
    }
  },
  "required": [
    "mode"
  ]
}
```

## Responses

### 200: Order scheduled and auto-assign run

### 400: Order must be in draft state — or scheduled (not started) for mode=split

### 404: Production order not found