---
type: Web Page
title: "Count posting"
description: "Counts post only under an active lock and an unchanged snapshot; other bins' activity does not invalidate them."
resource: "https://racksort.com/decisions/count"
---

# Count posting

Counts post only under an active lock and an unchanged snapshot; other bins' activity does not invalidate them.

Request with `"decision": "count"` and one of these operations: `post`.

## Clauses applied

- `count.lock`: A count lock covers the whole counted location; acquire it only after in-flight physical work is paused/reconciled.
- `count.bypass`: Moves, picks, receipt/pack transfers and quantity corrections cannot bypass it.
- `count.invalid`: A changed scoped quantity/version/set, lost lease or reopened physical work invalidates the count: reacquire, snapshot and recount.
- `count.global`: Unrelated warehouse-revision increments from other bins do not invalidate an unchanged locked scope; the global revision is audit evidence only.

## Evidence questions

### `movement_during_count@1`
This is a counter's note from counting one location. Does it report stock moving into or out of the location while the count was under way, or work at the location that was not paused?

| Answer | Meaning |
| --- | --- |
| `true` | The note reports stock moving into or out of the location during the count, or work there that was not paused. |
| `false` | The note reports nothing moving during the count. It is about the count itself, labels, damage or other matters. |

## Examples

### A counter reports a pick during the count
```
{
  "decision": "count",
  "proposal": {
    "operation": "post",
    "task": "CC-7781-4",
    "at": "2026-10-02T15:42:00Z"
  },
  "lock": {
    "status": "Active",
    "location": "B-11-04-C",
    "expires_at": "2026-10-02T17:00:00Z"
  },
  "snapshot": {
    "positions": {
      "POS-551201": 17
    },
    "global_revision": 90412
  },
  "current": {
    "positions": {
      "POS-551201": 17
    },
    "global_revision": 90466
  },
  "result": {
    "expected": "10",
    "counted": "8",
    "unit_cost": "8"
  },
  "note": "Picker pulled 2 from this bin at 3:31 while I was counting. Didn't see a scan on the gun."
}
```
Response from the rules with no model loaded, so every question abstains.
```
{
  "verdict": "review",
  "next": {
    "action": "confirm_or_recount",
    "text": "It is not certain whether the counter's note reports movement during the count.",
    "role": "Inventory Controller"
  },
  "questions": [
    {
      "ask": "note",
      "question": "movement_during_count@1",
      "status": "model_unavailable",
      "evidence": [
        "/note"
      ]
    }
  ]
}
```
[Run this example in the console](https://racksort.com/console?example=count-movement.json)[Download the request](https://racksort.com/examples/count-movement.json)
### Posting a count after the position changed
```
{
  "decision": "count",
  "proposal": {
    "operation": "post",
    "task": "CC-7781-5",
    "at": "2026-10-02T15:42:00Z"
  },
  "lock": {
    "status": "Active",
    "location": "B-11-05-A",
    "expires_at": "2026-10-02T17:00:00Z"
  },
  "snapshot": {
    "positions": {
      "POS-551209": 17
    },
    "global_revision": 90412
  },
  "current": {
    "positions": {
      "POS-551209": 18
    },
    "global_revision": 90466
  }
}
```
Response from the rules with no model loaded, so every question abstains.
```
{
  "verdict": "reconcile",
  "next": {
    "action": "recount",
    "text": "Positions in the locked location changed since the snapshot. Reacquire, snapshot and recount.",
    "role": "Inventory Controller"
  },
  "questions": []
}
```
[Run this example in the console](https://racksort.com/console?example=count-stale-version.json)[Download the request](https://racksort.com/examples/count-stale-version.json)

## 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](https://racksort.com/signup), then [create a key](https://racksort.com/account). The [quickstart](https://racksort.com/docs/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": "count",
  "proposal": {
    "operation": "post",
    "task": "CC-7781-4",
    "at": "2026-10-02T15:42:00Z"
  },
  "lock": {
    "status": "Active",
    "location": "B-11-04-C",
    "expires_at": "2026-10-02T17:00:00Z"
  },
  "snapshot": {
    "positions": {
      "POS-551201": 17
    },
    "global_revision": 90412
  },
  "current": {
    "positions": {
      "POS-551201": 17
    },
    "global_revision": 90466
  },
  "result": {
    "expected": "10",
    "counted": "8",
    "unit_cost": "8"
  },
  "note": "Picker pulled 2 from this bin at 3:31 while I was counting. Didn't see a scan on the gun."
}
EOF
```
### Python
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": "count",
    "proposal": {
        "operation": "post",
        "task": "CC-7781-4",
        "at": "2026-10-02T15:42:00Z",
    },
    "lock": {
        "status": "Active",
        "location": "B-11-04-C",
        "expires_at": "2026-10-02T17:00:00Z",
    },
    "snapshot": {
        "positions": {
            "POS-551201": 17,
        },
        "global_revision": 90412,
    },
    "current": {
        "positions": {
            "POS-551201": 17,
        },
        "global_revision": 90466,
    },
    "result": {
        "expected": "10",
        "counted": "8",
        "unit_cost": "8",
    },
    "note": "Picker pulled 2 from this bin at 3:31 while I was counting. Didn't see a scan on the gun.",
}

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": "count",
  "proposal": {
    "operation": "post",
    "task": "CC-7781-4",
    "at": "2026-10-02T15:42:00Z"
  },
  "lock": {
    "status": "Active",
    "location": "B-11-04-C",
    "expires_at": "2026-10-02T17:00:00Z"
  },
  "snapshot": {
    "positions": {
      "POS-551201": 17
    },
    "global_revision": 90412
  },
  "current": {
    "positions": {
      "POS-551201": 17
    },
    "global_revision": 90466
  },
  "result": {
    "expected": "10",
    "counted": "8",
    "unit_cost": "8"
  },
  "note": "Picker pulled 2 from this bin at 3:31 while I was counting. Didn't see a scan on the gun."
};

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",
    "snapshot",
    "current"
  ],
  "additionalProperties": false,
  "properties": {
    "decision": {
      "const": "count"
    },
    "proposal": {
      "type": "object",
      "required": [
        "operation",
        "at"
      ],
      "additionalProperties": false,
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "post"
          ]
        },
        "task": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "lock": {
      "type": "object",
      "required": [
        "status"
      ],
      "additionalProperties": false,
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "Active",
            "Released",
            "Expired"
          ]
        },
        "location": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "acquired_at": {
          "type": "string",
          "format": "date-time"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "snapshot": {
      "type": "object",
      "required": [
        "positions"
      ],
      "additionalProperties": false,
      "properties": {
        "positions": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "global_revision": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "current": {
      "type": "object",
      "required": [
        "positions"
      ],
      "additionalProperties": false,
      "properties": {
        "positions": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "global_revision": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "result": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "expected": {
          "type": "string",
          "format": "decimal"
        },
        "counted": {
          "type": "string",
          "format": "decimal"
        },
        "unit_cost": {
          "type": "string",
          "format": "decimal"
        }
      }
    },
    "note": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4000
    }
  }
}
```
