Build Forecast (Single Supplier)
POST/api/inventory-forecasting/build-single
Build a forecast for a single supplier. If the product count is large the request is queued as a background job and the response returns a job_id for polling; otherwise the result is returned synchronously.
Any valid API token can call this endpoint — no specific scope required. Manage tokens.
Authentication: Requires Bearer token.
Response type field: sync (includes data) or async (includes job_id for status polling).
This endpoint accepts the same forecast controls as Build Forecast, including the baseline decomposition:
- baseline_method: flat (default), recency_weighted, or damped_trend.
- trend_damping_factor (0..1, default 0.85): damping factor phi for damped_trend; lower = more damping.
- trend_max_growth_pct (>= 0, default 100): caps the trend lift above the flat mean (100 = may at most double it).
- trend_half_life_days (>= 1, nullable, default 21): reserved tuning for recency_weighted.
- exclude_detected_anomalies (default false): drop/replace resolved anomaly days before computing the baseline.
- demand_modifiers[]: percentage, seasonal, event, override, or promo_lift (carry promo_window_id and send value 0 - the window's measured lift is applied multiplicatively to the current baseline).
The sparse-history fallback applies here too: a product with fewer than roughly 8 weeks of history or fewer than 8 orders falls back to the flat mean (trend_factor 1.0). See Build Forecast for the full field guide and the per-line inputs decomposition (base_flat, trend_factor, baseline_method, trend_capped, anomaly_days_excluded, anomaly_days_smoothed, promo_factor, promo_window_name, promo_current_baseline).
enforce_minimum_order_value / enforce_minimum_order_quantity: when true, the minimums block flags whether the forecast totals fall below the supplier's minimum_purchase_order / minimum_purchase_order_quantity. Display-only here; enforcement is applied at PO creation time (POST /api/inventory-forecasting/purchase-orders).
Returns 422 if too many products are found.
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.
Validation failed — the body is a field → messages map (Laravel shape) or the platform envelope with a stable machine-readable code. Fix the payload and resubmit.
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.