Skip to main content

Generate Orders from Plan

POST 

/api/inventory-forecasting/runs/:runId/orders

Create draft documents from selected plan lines: one draft manufacturing order per Make line, one draft purchase order per supplier and warehouse for the Buy lines, and one draft warehouse transfer per Transfer line. Everything is created as a draft; nothing is sent to a supplier. With preview=true nothing is created and the grouped result comes back.

Required scope: purchase-orders:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Authentication: Requires Bearer token.

Recompute: when a Make line is left out of line_ids (or its quantity is overridden), the ingredients it drove are re-sized from the builds that are being created; an ingredient that drops to zero is returned in dropped and not ordered, a resized one in adjusted. Builds already turned into a manufacturing order still count.

Safety: each document is created on its own, so one that fails is reported in skipped with its reason without affecting the rest. A line that already has a document is skipped ("Already created (PO-1204)"), so repeating the request never creates duplicates. documents lists every draft created, with its type, id and document number (reference). A Make entry carries batches: one draft MO per batch when its Make policy sets an order maximum. The preview's also_needed lists covered ingredients the selection now runs short of (a build raised above its suggestion) — line_id, sku, source, quantity — so the client can add them to line_ids; nothing is created for them unless they are sent. An outsourced build's ingredients are planned (and bought) at the contractor's site warehouse. Make lines need Manufacturing access and Transfer lines need warehouse transfer create access; without it those lines are skipped with the reason.

Supplier minimums: when the plan enforces supplier minimum order value or quantity and a PO falls below it, the request returns 422 with violations unless that supplier is in acknowledged_supplier_ids or minimums_acknowledged is true. The preview always lists violations.

Body: line_ids (required, integer[]), quantities (object line_id => quantity override, optional, ≥ 0), approval_status (draft | approved — purchase orders only, default draft), acknowledged_supplier_ids (integer[], optional), minimums_acknowledged (boolean, optional), preview (boolean, optional).

Request​

Responses​

OK

Response Headers
    Content-Type