> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vinmake.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Production Execution

> Production orders, cut plans, and mobile floor execution

# Production Execution

Production execution turns an approved PLM style into work on the floor. A **production order** anchors the run; a **cut plan** breaks the order into cut jobs; **mobile execution** pushes the work to phones at cutting tables and sewing lines; and **production lines**, **work centers**, and **workers** model the resources that do it.

## The pieces

| Concept              | What it is                                                                                  |
| -------------------- | ------------------------------------------------------------------------------------------- |
| Production Order     | The work order for a style + quantity, with versions and a completion posting.              |
| Cut Plan / Cut Job   | The marker-driven plan to cut fabric into bundles, and the individual jobs that execute it. |
| Sewing Segment       | A unit of sewing work tracked with day reports and output posting.                          |
| Production Line      | A configurable sewing or assembly line that work is assigned to.                            |
| Work Center / Worker | Factory resources — a station and the person operating it.                                  |

## Flow

```mermaid theme={null}
flowchart LR
  PO[Production Order] --> CP[Cut Plan]
  CP --> CJ[Cut Jobs]
  CJ --> Cut[Cutting -> bundles]
  Cut --> Seg[Sewing Segments]
  Seg --> PL[Production Lines]
  PL --> WC[Work Centers / Workers]
  WC --> Done[Post Completion]
  Done -.COGS.-> Fin[Finindex GL]
```

## Creating and running a production order

```mermaid theme={null}
sequenceDiagram
  participant U as Planner
  participant PO as ProductionOrder
  participant CP as CutPlan
  participant Mobile as Mobile (Floor)
  participant Worker as Worker
  U->>PO: POST /production-orders
  U->>PO: POST /production-orders/{id}/submit
  U->>CP: POST /production-floor/cut-plans
  U->>PO: POST /production-floor/production-orders/{id}/prepare-mobile-execution
  Mobile-->>Worker: cut jobs + sewing segments appear on device
  Worker->>Mobile: record cut quantities / day reports
  Mobile->>PO: progress rolls up to the order
  U->>PO: POST /production-orders/{id}/post-completion
  PO-->>Fin: finished-goods value + COGS posted
```

## Production Orders

```bash theme={null}
GET /api/v1/production-orders
Authorization: Bearer <access_token>
```

### Create a production order

<ParamField body="style_id" type="string" required>
  The PLM style this order produces.
</ParamField>

<ParamField body="quantity" type="integer" required>
  Total garments to produce, typically broken down by size in the order detail.
</ParamField>

<ParamField body="due_date" type="string">
  Target completion date in YYYY-MM-DD format.
</ParamField>

```bash theme={null}
POST /api/v1/production-orders
Authorization: Bearer <access_token>

{
  "style_id": "uuid",
  "quantity": 1200,
  "due_date": "2026-07-30"
}
```

**Response (201):**

```json theme={null}
{
  "id": "uuid",
  "code": "PO-2026-0042",
  "style_id": "uuid",
  "quantity": 1200,
  "status": "draft",
  "version": 1
}
```

<Tip>
  A new order starts as `draft`. Call `submit` to lock it for the floor, then `post-completion` once production finishes to recognize finished-goods inventory and COGS in Finindex.
</Tip>

```bash theme={null}
POST /api/v1/production-orders/{order_id}/submit
POST /api/v1/production-orders/{order_id}/post-completion
GET  /api/v1/production-orders/{order_id}/versions
```

<Note>
  Edits create a new **version**. Use `GET /production-orders/{order_id}/versions` to audit how an order changed over its life — useful when a buyer revises quantities mid-run.
</Note>

## Production Floor

The floor APIs turn a submitted order into executable work. Build a cut plan, then call **prepare-mobile-execution** to materialize cut jobs and sewing segments for devices.

```bash theme={null}
POST /api/v1/production-floor/cut-plans
GET  /api/v1/production-floor/cut-jobs
POST /api/v1/production-floor/cut-jobs/{cut_job_id}/quantity-events
POST /api/v1/production-floor/cut-jobs/{cut_job_id}/post-output
POST /api/v1/production-floor/sewing-segments/{segment_id}/day-report
POST /api/v1/production-floor/sewing-segments/{segment_id}/post-output
```

### Prepare mobile execution

Generates the device-ready work set (cut jobs, sewing segments, stage statuses) for a submitted order.

```bash theme={null}
POST /api/v1/production-floor/production-orders/{production_order_id}/prepare-mobile-execution
Authorization: Bearer <access_token>
```

**Response (200):**

```json theme={null}
{
  "production_order_id": "uuid",
  "cut_jobs_created": 6,
  "sewing_segments_created": 4,
  "status": "ready_for_floor"
}
```

<Info>
  Cutting consumes fabric: `post-output` on a cut job writes a stock issue against the fabric lot (see [Warehouse & Inventory](/cutmake/mes/warehouse-inventory)). Sewing `post-output` advances garments toward finished goods.
</Info>

## Production Lines

```bash theme={null}
GET   /api/v1/production-lines
POST  /api/v1/production-lines
PATCH /api/v1/production-lines/{production_line_id}/toggle
```

Use `toggle` to activate or pause a line without deleting its configuration — handy for taking a line offline for maintenance or reassignment.

## Factory: work centers and workers

The Factory tag models physical resources and the assignments that bind them to work.

```bash theme={null}
GET  /api/v1/factory/work-centers
POST /api/v1/factory/workers
GET  /api/v1/factory/assignments
POST /api/v1/factory/stage-statuses
```

<Accordion title="Stage statuses and mobile mutations">
  `stage-statuses` is an **upsert** endpoint that records where each unit of work sits in the cut/sew/finish pipeline. `factory/mobile-mutations` captures offline edits made on devices and replays them server-side, so a phone with a flaky connection never loses a scan.
</Accordion>

## Mobile snapshots

Read-only aggregates that power the floor and worker mobile apps.

```bash theme={null}
GET /api/v1/mobile/floor-snapshot
GET /api/v1/mobile/worker-snapshot
Authorization: Bearer <access_token>
```

* **floor-snapshot** — a whole-floor view: active orders, line load, and stage progress.
* **worker-snapshot** — what a single worker should do next and what they have completed today.

See the **API Reference** tab for the full endpoint list across the Production Orders, Production Floor, Production Lines, Factory, and Mobile tags.
