Reservations
Soft, Hard, Picked and Packed claims that move without growing, and order-change messages that must not become duplicate claims.
Request with "decision": "reserve" and one of these operations: add_soft, release, pick, short_close, cancel.
Clauses applied
reserve.line: For each order line, OrderedQty = CancelledQty + ShippedQty + UnreservedQty + active Soft/Hard/Picked/Packed.reserve.upstream: Upstream changes do not overwrite claimed scope.reserve.release: Wave release records Soft −q / Hard +q, so total claims do not grow.reserve.atp: For each exact unowned eligible position, ATP is QuantityOnHand minus positive Soft and Hard balances.reserve.owned: Owned picked/packed stock is never ATP for another order.reserve.pick: Pick records source stock −q / owned tote stock +q and Hard −q / Picked +q.reserve.short: A short pick posts actual picked quantity, releases the residual source claim and excludes suspect stock before a replacement reservation; it cannot both retain and recreate the same demand.reserve.cancel: Released work is cancelled only after all active tasks, owned stock, reservation balances and uncertain carrier operations reconcile.
Evidence questions
order_change_kind@1
This message about an existing order arrived after the order was received. What does it ask the warehouse to do with the order's quantities?
| Answer | Meaning |
|---|---|
additional_units | Ship more units on top of what the order already holds: a new line, or more of an item in addition to the ordered quantity. |
revised_quantity | Change an existing line to a new total quantity, up or down. |
cancellation | Cancel the order or part of it. |
restatement | Nothing new: it repeats, confirms, resends or asks about the order as it stands. |
Examples
Customer revises a line, agent reserves the new total
{
"decision": "reserve",
"proposal": {
"operation": "add_soft",
"qty": "30"
},
"line": {
"id": "OL-4471-2",
"sku": "YB-CORK-2",
"ordered": "25",
"cancelled": "0",
"shipped": "0",
"unreserved": "0",
"soft": "25",
"hard": "0",
"picked": "0",
"packed": "0"
},
"position": {
"on_hand": "180",
"soft": "40",
"hard": "20",
"eligible": true
},
"message": {
"text": "Hi team, on PO 4471 can you make the cork blocks 30 instead of 25? Thanks, Maya",
"source": "email"
},
"order_lines": [
{
"line": "1",
"sku": "YS-6-TL",
"description": "Yoga strap 6ft teal",
"ordered": "40"
},
{
"line": "2",
"sku": "YB-CORK-2",
"description": "Yoga block cork 2in",
"ordered": "25"
}
]
}Response from the rules with no model loaded, so every question abstains.
{
"verdict": "review",
"next": {
"action": "classify_message",
"text": "The message could not be read with certainty as new demand, a revision, a cancellation or a repeat, so it changes no claim until someone decides.",
"role": "Warehouse Manager"
},
"questions": [
{
"ask": "message",
"question": "order_change_kind@1",
"status": "model_unavailable",
"evidence": [
"/message/text"
]
}
]
}Run this example in the consoleDownload the request
Wave release moves Soft to Hard
{
"decision": "reserve",
"proposal": {
"operation": "release",
"qty": "20"
},
"line": {
"id": "OL-9012-1",
"ordered": "70",
"cancelled": "0",
"shipped": "0",
"unreserved": "0",
"soft": "30",
"hard": "40",
"picked": "0",
"packed": "0"
},
"position": {
"on_hand": "100",
"soft": "30",
"hard": "40",
"eligible": true
}
}Response from the rules with no model loaded, so every question abstains.
{
"verdict": "allow",
"next": {
"action": "proceed",
"text": "Release moves 20 from Soft to Hard; total claims stay the same."
},
"questions": []
}Run this example in the consoleDownload the request
Call it from your code
Each snippet sends the first example above to the hosted API with the key in RACKSORT_API_KEY and prints the verdict and the next step. Create an account, then create a key. The quickstart walks through the first request.
curl
export RACKSORT_API_KEY="paste-your-key-here"
curl https://racksort.com/api/v1/decide \
-H "Authorization: Bearer $RACKSORT_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'EOF'
{
"decision": "reserve",
"proposal": {
"operation": "add_soft",
"qty": "30"
},
"line": {
"id": "OL-4471-2",
"sku": "YB-CORK-2",
"ordered": "25",
"cancelled": "0",
"shipped": "0",
"unreserved": "0",
"soft": "25",
"hard": "0",
"picked": "0",
"packed": "0"
},
"position": {
"on_hand": "180",
"soft": "40",
"hard": "20",
"eligible": true
},
"message": {
"text": "Hi team, on PO 4471 can you make the cork blocks 30 instead of 25? Thanks, Maya",
"source": "email"
},
"order_lines": [
{
"line": "1",
"sku": "YS-6-TL",
"description": "Yoga strap 6ft teal",
"ordered": "40"
},
{
"line": "2",
"sku": "YB-CORK-2",
"description": "Yoga block cork 2in",
"ordered": "25"
}
]
}
EOFPython
Python 3.8 or newer, standard library only. Keep the User-Agent header: requests with Python's default one are refused. With requests or httpx it is not needed.
import json
import os
import urllib.error
import urllib.request
request = {
"decision": "reserve",
"proposal": {
"operation": "add_soft",
"qty": "30",
},
"line": {
"id": "OL-4471-2",
"sku": "YB-CORK-2",
"ordered": "25",
"cancelled": "0",
"shipped": "0",
"unreserved": "0",
"soft": "25",
"hard": "0",
"picked": "0",
"packed": "0",
},
"position": {
"on_hand": "180",
"soft": "40",
"hard": "20",
"eligible": True,
},
"message": {
"text": "Hi team, on PO 4471 can you make the cork blocks 30 instead of 25? Thanks, Maya",
"source": "email",
},
"order_lines": [
{
"line": "1",
"sku": "YS-6-TL",
"description": "Yoga strap 6ft teal",
"ordered": "40",
},
{
"line": "2",
"sku": "YB-CORK-2",
"description": "Yoga block cork 2in",
"ordered": "25",
},
],
}
call = urllib.request.Request(
"https://racksort.com/api/v1/decide",
data=json.dumps(request).encode(),
headers={
"Authorization": f"Bearer {os.environ['RACKSORT_API_KEY']}",
"Content-Type": "application/json",
# Cloudflare refuses Python's default User-Agent, so name the client.
"User-Agent": "racksort-example/1.0",
},
)
try:
with urllib.request.urlopen(call, timeout=30) as response:
result = json.load(response)
except urllib.error.HTTPError as error:
raise SystemExit(json.load(error)["error"]["message"])
print(result["verdict"], "-", result["next"]["text"])TypeScript
Node.js 18 or newer. Save it as decide.mts and run npx tsx decide.mts.
type Verdict = "allow" | "replay" | "reject" | "review" | "reconcile";
interface Decision {
verdict: Verdict;
state?: string;
next: { action: string; text: string; role?: string };
}
const request = {
"decision": "reserve",
"proposal": {
"operation": "add_soft",
"qty": "30"
},
"line": {
"id": "OL-4471-2",
"sku": "YB-CORK-2",
"ordered": "25",
"cancelled": "0",
"shipped": "0",
"unreserved": "0",
"soft": "25",
"hard": "0",
"picked": "0",
"packed": "0"
},
"position": {
"on_hand": "180",
"soft": "40",
"hard": "20",
"eligible": true
},
"message": {
"text": "Hi team, on PO 4471 can you make the cork blocks 30 instead of 25? Thanks, Maya",
"source": "email"
},
"order_lines": [
{
"line": "1",
"sku": "YS-6-TL",
"description": "Yoga strap 6ft teal",
"ordered": "40"
},
{
"line": "2",
"sku": "YB-CORK-2",
"description": "Yoga block cork 2in",
"ordered": "25"
}
]
};
const response = await fetch("https://racksort.com/api/v1/decide", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RACKSORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(request),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.message);
const result = body as Decision;
console.log(result.verdict, "-", result.next.text);
Request schema
{
"type": "object",
"required": [
"decision",
"proposal",
"line"
],
"additionalProperties": false,
"properties": {
"decision": {
"const": "reserve"
},
"proposal": {
"type": "object",
"required": [
"operation",
"qty"
],
"additionalProperties": false,
"properties": {
"operation": {
"type": "string",
"enum": [
"add_soft",
"release",
"pick",
"short_close",
"cancel"
]
},
"qty": {
"type": "string",
"format": "decimal"
}
}
},
"line": {
"type": "object",
"required": [
"id",
"ordered",
"cancelled",
"shipped",
"unreserved",
"soft",
"hard",
"picked",
"packed"
],
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"sku": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"ordered": {
"type": "string",
"format": "decimal"
},
"cancelled": {
"type": "string",
"format": "decimal"
},
"shipped": {
"type": "string",
"format": "decimal"
},
"unreserved": {
"type": "string",
"format": "decimal"
},
"soft": {
"type": "string",
"format": "decimal"
},
"hard": {
"type": "string",
"format": "decimal"
},
"picked": {
"type": "string",
"format": "decimal"
},
"packed": {
"type": "string",
"format": "decimal"
}
}
},
"position": {
"type": "object",
"required": [
"on_hand",
"soft",
"hard",
"eligible"
],
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"on_hand": {
"type": "string",
"format": "decimal"
},
"soft": {
"type": "string",
"format": "decimal"
},
"hard": {
"type": "string",
"format": "decimal"
},
"eligible": {
"type": "boolean"
}
}
},
"message": {
"type": "object",
"required": [
"text"
],
"additionalProperties": false,
"properties": {
"text": {
"type": "string",
"minLength": 1,
"maxLength": 4000
},
"received_at": {
"type": "string",
"format": "date-time"
},
"source": {
"type": "string",
"enum": [
"email",
"edi",
"portal",
"phone",
"other"
]
}
}
},
"order_lines": {
"type": "array",
"items": {
"type": "object",
"required": [
"sku",
"ordered"
],
"additionalProperties": false,
"properties": {
"line": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"sku": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"description": {
"type": "string",
"minLength": 1,
"maxLength": 4000
},
"ordered": {
"type": "string",
"format": "decimal"
}
}
},
"maxItems": 200
}
}
}