Inventory Reorder Planner
commerce.inventory_reorder
Overview
You send stock positions and the policy you buy under, and we return, per item, what is available, the reorder point, whether it is below it, how much to order raw and after your order multiple and minimum, how many days of cover you have left, and a reason code explaining the answer. Every formula is published: available is onHand plus onOrder minus allocated, or onHand minus allocated when rules.includeOnOrder is off; the reorder point is average daily demand times lead time plus safety stock, rounded up to a whole unit; safety stock under DAYS_OF_DEMAND is demand times safetyStockDays, also rounded up; the raw suggestion is the reorder point minus available, or maxStock minus available under MIN_MAX, or the item's reorderQuantity under FIXED_QUANTITY, never below zero; coverDays is available divided by demand truncated to one decimal, floored at 0.0 for an oversold position; and EOQ is the classic square root, taken by integer square root on exact decimals rather than a floating-point library call. There is no forecasting anywhere: demand is an input, not an inference, so this answers "given this demand estimate, what should I order" and not "what will I sell". An item missing what its policy needs comes back INSUFFICIENT_DATA rather than a guess. It suggests; it never orders, reserves or changes anything.
Reorder arithmetic is simple and still gets done differently in three places: one spreadsheet counts stock in transit and another does not, one rounds the order up to a case and another does not, and neither can tell you why a SKU was left off the list. You get one fixed set of formulae, published openly, plus a reason code per item — including an explicit INSUFFICIENT_DATA instead of a quiet zero when an item lacks what its policy needs.
Reliability
Fully deterministic and clock-free: the same positions under the same rules always give the same plan, and nothing here reads the date. All arithmetic is exact decimal, including EOQ, whose square root is taken to three decimals by integer square root and then rounded up to a whole unit — there is no floating point anywhere on the path. Two consequences worth knowing. The reorder point is rounded up to a whole unit, because you cannot hold a fraction of one and rounding down would under-protect. And the order multiple and the minimum order quantity are applied after the maxStock cap, so an order can end up above maxStock: a supplier's case size is a physical constraint while maxStock is a target, and we will not silently break the physical one. A property this skill does not implement is refused, not ignored: an unknown top-level property is a broken request and comes back as the platform's TOOL_INPUT_INVALID, one on an item is INVENTORY_INVALID, and one in rules is INVENTORY_RULES_INVALID. Failures, and what to do about each. INVENTORY_INVALID — trigger: an item has no sku or onHand, repeats a sku, carries an unknown property, has a fractional count, a negative demand or cost, a demand finer than 6 decimals, or a value outside its range; or asOf is not a real calendar date in YYYY-MM-DD form; retryable: no, the same request always fails; next: fix the item we name by index. INVENTORY_LIMIT_EXCEEDED — trigger: more than 5000 items in one call; retryable: no; next: split the list, since every item is independent and the answers do not change. INVENTORY_RULES_INVALID — trigger: safetyStockMode is DAYS_OF_DEMAND without safetyStockDays, a rule is out of range or the wrong type, rules carries a property we do not implement, or orderingCost or holdingCostPerUnitPerYear was sent while economicOrderQuantity is off; retryable: no; next: fix the rule we name, or turn EOQ on if you meant to use the costs. INVENTORY_POLICY_UNSUPPORTED — trigger: rules.policy is not REORDER_POINT, MIN_MAX or FIXED_QUANTITY; retryable: no; next: pick one of the three. An unknown policy is refused rather than treated as the default, because a different policy is a different order. INVENTORY_COST_REQUIRED — trigger: economicOrderQuantity is on without orderingCost, without holdingCostPerUnitPerYear, or with a holding cost of zero; retryable: no; next: supply both, with a holding cost above zero, since EOQ is the trade-off between them and dividing by zero would imply an infinite order. CURRENCY_UNKNOWN — trigger: rules.currency is outside the twenty supported codes; retryable: no; next: pick a supported code, or omit it and no cost total is reported.
Context footprint
One compact entry per item, so 5000 items answer in a few hundred kilobytes. Two ceilings bound a request and both are reachable: 5000 items, and 1 MiB. A position with every field set is around 150 bytes, so 5001 of them reach the item ceiling inside the byte one — but a list carrying 128-character SKUs is roughly twice that, so a large enough call meets the byte ceiling first and is refused for size rather than answered. A successful call costs 1 execution credit.
When to use it
When you have a stock snapshot and a demand estimate and want a defensible buy list, with the reasoning attached.
When you need the demand estimate itself, a statistical service level, or anything that actually places an order.
Scope
Non-goals
- Does not forecast demand — no moving average, no seasonality, no trend, and no safety stock derived from demand variance and a service level, because that would be a statistical model you cannot inspect
- Does not read stock from anywhere; every position is an input
- Does not order, reserve, allocate or change anything
- Does not read the clock — asOf is yours to supply
- Does not choose a supplier, negotiate a price, or check a lead time
- Does not convert between currencies
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
How we handle your data
What this means
This skill may receive sensitive content and may return submitted, transformed, extracted, or reformatted content.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response may contain submitted or transformed content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| inventory | array | Yes | Bounded array of inventory position declarations with SKU, stock, demand, and lead-time fields. The item shape is defined by the nested schema and the array contains from 1 through 100000 items. |
| rules | object | No | Closed reorder policy object; omit it for the documented deterministic defaults. Its documented commercial properties are bounded to 256 entries — unconstrained RFC 8259 JSON items. |
| asOf | string | No | Optional explicit ISO date used for the plan; omit it when date-independent inputs are used. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| suggestions | array | Yes | Bounded array of SKU reorder suggestions in deterministic order. The item shape is defined by the nested schema and the array contains from 0 through 100000 items. |
| summary | object | Yes | Closed inventory, suggested, urgent, and quantity count summary. Its documented commercial properties are bounded to 256 entries — unconstrained RFC 8259 JSON items. |
| rules | object | Yes | Closed resolved reorder rules with defaults filled in. Its documented commercial properties are bounded to 256 entries — unconstrained RFC 8259 JSON items. |
| asOf | string | No | Applied explicit ISO planning date when supplied. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"commerce.inventory_reorder","input":{"inventory":[{"sku":"TSHIRT-S-BLACK","onHand":12,"avgDailyDemand":"4","leadTimeDays":7,"safetyStock":10}],"asOf":"2026-07-28"}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("commerce.inventory_reorder", {"rules":{"minOrderQuantity":24,"roundTo":12},"asOf":"2026-07-28","inventory":[{"avgDailyDemand":"4","leadTimeDays":7,"sku":"TSHIRT-S-BLACK","safetyStock":10,"onHand":12},{"onOrder":60,"avgDailyDemand":"5","leadTimeDays":14,"sku":"MUG-BLUE-S","onHand":40},{"sku":"LAMP-LED","allocated":1,"onHand":3}]});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
| INVENTORY_INVALID | 400 | No | The request payload failed this skill's input validation. |
| INVENTORY_LIMIT_EXCEEDED | 429 | No | A size, quota, rate, or time limit was exceeded. |
| INVENTORY_RULES_INVALID | 400 | No | The request payload failed this skill's input validation. |
| INVENTORY_POLICY_UNSUPPORTED | 400 | No | The skill does not support the requested variant. |
| INVENTORY_COST_REQUIRED | 400 | No | The request payload failed this skill's input validation. |
| CURRENCY_UNKNOWN | 400 | No | The request payload failed this skill's input validation. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not forecast demand — no moving average, no seasonality, no trend, and no safety stock derived from demand variance and a service level, because that would be a statistical model you cannot inspect
- Does not read stock from anywhere; every position is an input
- Does not order, reserve, allocate or change anything
- Does not read the clock — asOf is yours to supply
- Does not choose a supplier, negotiate a price, or check a lead time
- Does not convert between currencies
- Forecasting what you will sell next month
- Deciding safety stock from demand variability and a target service level
- Placing the purchase order
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "commerce.inventory_reorder",
"input": {
"rules": {
"minOrderQuantity": 24,
"roundTo": 12
},
"asOf": "2026-07-28",
"inventory": [
{
"avgDailyDemand": "4",
"leadTimeDays": 7,
"sku": "TSHIRT-S-BLACK",
"safetyStock": 10,
"onHand": 12
},
{
"onOrder": 60,
"avgDailyDemand": "5",
"leadTimeDays": 14,
"sku": "MUG-BLUE-S",
"onHand": 40
},
{
"sku": "LAMP-LED",
"allocated": 1,
"onHand": 3
}
]
}
}Examples
Three items under the default reorder-point policy, ordered in cases of twelve
{
"rules": {
"minOrderQuantity": 24,
"roundTo": 12
},
"asOf": "2026-07-28",
"inventory": [
{
"avgDailyDemand": "4",
"leadTimeDays": 7,
"sku": "TSHIRT-S-BLACK",
"safetyStock": 10,
"onHand": 12
},
{
"onOrder": 60,
"avgDailyDemand": "5",
"leadTimeDays": 14,
"sku": "MUG-BLUE-S",
"onHand": 40
},
{
"sku": "LAMP-LED",
"allocated": 1,
"onHand": 3
}
]
}{
"summary": {
"itemCount": 3,
"reorderCount": 1,
"totalSuggestedUnits": 36
},
"suggestions": [
{
"sku": "TSHIRT-S-BLACK",
"available": 12,
"reorderPoint": 38,
"shouldReorder": true,
"suggestedQuantity": 26,
"roundedQuantity": 36,
"coverDays": "3.0",
"reasonCode": "BELOW_REORDER_POINT"
},
{
"sku": "MUG-BLUE-S",
"available": 100,
"reorderPoint": 70,
"shouldReorder": false,
"suggestedQuantity": 0,
"roundedQuantity": 0,
"coverDays": "20.0",
"reasonCode": "ALREADY_ON_ORDER"
},
{
"sku": "LAMP-LED",
"available": 2,
"shouldReorder": false,
"suggestedQuantity": 0,
"roundedQuantity": 0,
"reasonCode": "INSUFFICIENT_DATA"
}
],
"rules": {
"policy": "REORDER_POINT",
"safetyStockMode": "EXPLICIT",
"roundTo": 12,
"minOrderQuantity": 24,
"includeOnOrder": true,
"economicOrderQuantity": false
},
"asOf": "2026-07-28"
}A min-max item with EOQ and a costed total, where EOQ is not a perfect square
{
"rules": {
"policy": "MIN_MAX",
"economicOrderQuantity": true,
"orderingCost": "45.00",
"holdingCostPerUnitPerYear": "3.50",
"currency": "EUR",
"roundTo": 10
},
"asOf": "2026-07-28",
"inventory": [
{
"avgDailyDemand": "2",
"maxStock": 120,
"sku": "TENT-2P",
"unitCost": "84.00",
"leadTimeDays": 21,
"onHand": 5
}
]
}{
"summary": {
"itemCount": 1,
"reorderCount": 1,
"totalSuggestedUnits": 120,
"totalSuggestedCost": "10080.00",
"costedItemCount": 1
},
"suggestions": [
{
"sku": "TENT-2P",
"available": 5,
"reorderPoint": 42,
"shouldReorder": true,
"suggestedQuantity": 115,
"roundedQuantity": 120,
"coverDays": "2.5",
"economicOrderQuantity": 138,
"reasonCode": "BELOW_REORDER_POINT"
}
],
"rules": {
"policy": "MIN_MAX",
"safetyStockMode": "EXPLICIT",
"roundTo": 10,
"minOrderQuantity": 0,
"includeOnOrder": true,
"economicOrderQuantity": true,
"orderingCost": "45.00",
"holdingCostPerUnitPerYear": "3.50",
"currency": "EUR"
},
"asOf": "2026-07-28"
}Recommended use cases
- Produce a nightly buy list from the stock snapshot your ERP already exports
- See which SKUs are only technically covered, because the stock is still in transit
- Compare a min-max policy against a reorder-point one on the same positions
Avoid for
- Forecasting what you will sell next month
- Deciding safety stock from demand variability and a target service level
- Placing the purchase order
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.