Create Purchase Orders from Forecast
POST/api/inventory-forecasting/purchase-orders
Create purchase orders from forecast results. Creates a ForecastScheduleRun to track the creation.
This endpoint currently requires session authentication; Personal Access Token scope support is in progress.
Authentication: Requires Bearer token.
approval_status: draft (default) or approved — if approved, auto-approves the PO after creation.
submit_to_supplier: if true, submits the PO to the supplier after creation.
forecast_config is optional but recommended for tracking — stores a snapshot of the config used.
Also syncs backorder coverage for all new PO lines.
Returns 422 if no valid orders provided.
Supplier minimum enforcement: when forecast_config.enforce_minimum_order_value or forecast_config.enforce_minimum_order_quantity is true and the order totals fall below the supplier's minimum_purchase_order or minimum_purchase_order_quantity, the request is rejected with 422 unless minimums_acknowledged is true on that order.
forecast_type accepts: target_stock_level, with_sales_history, fill_backorders.
Nullable forecast_config snapshot keys: the snapshot is sent verbatim from the saved forecast configuration, which persists null for any setting the selected forecast type does not use (e.g. target_stock_days is null on a target_stock_level run that targets a minimum stock level, and on a fill_backorders run). Every snapshot key therefore accepts null as well as its documented type: supplier_ids (array|null), forecast_type (string|null), target_stock_days (integer|null), override_product_target_days (boolean|null), use_leadtime (boolean|null), use_measured_lead_time (boolean|null), use_moq (boolean|null), enforce_minimum_order_value (boolean|null), enforce_minimum_order_quantity (boolean|null), rounding_method (string|null), target_quantity (integer|null), sales_history_days (integer|null), sales_start_date (string|null), sales_end_date (string|null), destination_warehouse_id (integer|null), pricing_tier_id (integer|null), product_filters (array|null), sales_filters (array|null), demand_modifiers (array|null), created_by_user_id (integer|null), created_by_user_name (string|null), manual_forecast_run_id (integer|null), post_forecast_adjustments (array|null), ignore_min_stock_level (boolean|null). A null is stored as-is in the snapshot; type validation still applies to non-null values.
Request
Responses
- 200
- 401
- 403
- 422
- 429
OK
Response Headers
Unauthenticated — the bearer token is missing, revoked, expired, or malformed. Never retry automatically; fix the credential. See the Errors guide.
Forbidden — the token lacks a required scope, the endpoint is not available to API tokens, or the user behind the token lacks the permission. A human must adjust the token scopes or user permissions; do not retry.
Unprocessable Entity
Response Headers
Rate limited — platform limit is 1,000 requests/min; individual tokens may carry lower limits. Honor the Retry-After header before retrying. See the Rate Limits guide.