# Update a sub-order (quantity produced, state, etc.) (/docs/api-reference/production-orders/ProductionOrdersController_updateSubOrder)

`PATCH /api/factories/{factoryId}/production-orders/{id}/sub-orders/{subId}`

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 |
| `subId` | path | yes | string | Sub-Order ID |

## Request body

Required.

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "serialNumbers": {
      "description": "Serial numbers for this sub-order",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "quantityProduced": {
      "type": "number",
      "description": "Quantity produced"
    },
    "quantityGood": {
      "type": "number",
      "description": "Quantity good"
    },
    "quantityRejected": {
      "type": "number",
      "description": "Quantity rejected"
    },
    "quantityTransferred": {
      "type": "number",
      "description": "Quantity transferred"
    },
    "state": {
      "type": "string",
      "description": "Sub-order state",
      "enum": [
        "pending",
        "in_progress",
        "completed",
        "cancelled"
      ]
    },
    "currentLocation": {
      "type": "string",
      "description": "Current location"
    },
    "machineId": {
      "type": "string",
      "description": "Machine ID"
    },
    "workAreaId": {
      "type": "string",
      "description": "Work area ID"
    },
    "plannedStart": {
      "type": "string",
      "description": "Planned start (ISO) — used by per-op Gantt reschedule"
    },
    "plannedEnd": {
      "type": "string",
      "description": "Planned end (ISO) — used by per-op Gantt reschedule"
    },
    "changedBy": {
      "type": "string",
      "description": "User who made the change"
    }
  }
}
```

## Responses

### 200: Sub-order updated

### 404: Sub-order not found