Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Inventory Reorder Planner

commerce.inventory_reorder

ProductionBounded custom (Class B)Deterministicstrictfastv1.0.0
No network

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

Note
Compute reorder decisions and quantities from supplied stock positions under one of three published replenishment policies.

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

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

math

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input1 MB

How we handle your data

Sensitive output possible
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.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
inventoryarrayYesBounded 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.
rulesobjectNoClosed reorder policy object; omit it for the documented deterministic defaults. Its documented commercial properties are bounded to 256 entries — unconstrained RFC 8259 JSON items.
asOfstringNoOptional explicit ISO date used for the plan; omit it when date-independent inputs are used.

Output schema

FieldTypeRequiredDescription
suggestionsarrayYesBounded 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.
summaryobjectYesClosed inventory, suggested, urgent, and quantity count summary. Its documented commercial properties are bounded to 256 entries — unconstrained RFC 8259 JSON items.
rulesobjectYesClosed resolved reorder rules with defaults filled in. Its documented commercial properties are bounded to 256 entries — unconstrained RFC 8259 JSON items.
asOfstringNoApplied explicit ISO planning date when supplied.

API contract

POST /v1/execute
curl
curl -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"}}'
Integrations
TypeScript SDK
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

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.
INVENTORY_INVALID400NoThe request payload failed this skill's input validation.
INVENTORY_LIMIT_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.
INVENTORY_RULES_INVALID400NoThe request payload failed this skill's input validation.
INVENTORY_POLICY_UNSUPPORTED400NoThe skill does not support the requested variant.
INVENTORY_COST_REQUIRED400NoThe request payload failed this skill's input validation.
CURRENCY_UNKNOWN400NoThe request payload failed this skill's input validation.

Other limits

LimitValue
Recommended inline bytes32 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)

Request bodyjson
{
  "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

Inputjson
{
  "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
    }
  ]
}
Expected outputjson
{
  "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

Inputjson
{
  "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
    }
  ]
}
Expected outputjson
{
  "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"
}
  • 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

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.

Tags

inventoryanalysismathcommerce