---
type: Web Page
title: "Serial identity"
description: "One serial per unit, unique in active stock, read from scans that may hold other codes."
resource: "https://racksort.com/decisions/serial"
---

# Serial identity

One serial per unit, unique in active stock, read from scans that may hold other codes.

Request with `"decision": "serial"` and one of these operations: `receive`, `pick`, `pack`, `count`.

## Clauses applied

- `receive.factor`: UOM factor is frozen once; serial captures use factor 1 and base quantity 1.
- `serial.unique`: Serial-controlled stock requires one unit per captured serial and no second positive active position for the same item/serial.
- `variance.manager`: Discovery, identity change, reserved/owned stock, above-threshold value or exceptional cost requires independent Warehouse Manager.

## Evidence questions

### `scan_is_serial@1`
This value was scanned from one unit of the item described. Is it that unit's own serial number?

| Answer | Meaning |
| --- | --- |
| `true` | It is the unit's own serial number, unique to this one unit. |
| `false` | It is another code printed on the unit or its packaging: a product barcode (GTIN, UPC, EAN), model or part number, lot or batch, date, or a carton or pallet code. |

## Examples

### A product barcode scanned as a serial
```
{
  "decision": "serial",
  "proposal": {
    "operation": "receive",
    "qty": "2",
    "scans": [
      "SN 2304K118842",
      "0885911425308"
    ]
  },
  "item": {
    "sku": "DCD771C2",
    "description": "20V cordless drill kit",
    "serial_controlled": true,
    "gtin": "00885911425308",
    "identifiers": [
      "DCD771C2"
    ],
    "serial_format": "S/N then 4 digits, a letter, 6 digits"
  },
  "active_serials": []
}
```
Response from the rules with no model loaded, so every question abstains.
```
{
  "verdict": "reject",
  "next": {
    "action": "rescan",
    "text": "1 scan(s) are not serial numbers ('0885911425308' first). Rescan the units' serial labels."
  },
  "questions": [
    {
      "ask": "scans/0",
      "question": "scan_is_serial@1",
      "status": "model_unavailable",
      "evidence": [
        "/proposal/scans/0"
      ]
    }
  ]
}
```
[Run this example in the console](https://racksort.com/console?example=serial-gtin-scanned.json)[Download the request](https://racksort.com/examples/serial-gtin-scanned.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": "serial",
  "proposal": {
    "operation": "receive",
    "qty": "2",
    "scans": [
      "SN 2304K118842",
      "0885911425308"
    ]
  },
  "item": {
    "sku": "DCD771C2",
    "description": "20V cordless drill kit",
    "serial_controlled": true,
    "gtin": "00885911425308",
    "identifiers": [
      "DCD771C2"
    ],
    "serial_format": "S/N then 4 digits, a letter, 6 digits"
  },
  "active_serials": []
}
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": "serial",
    "proposal": {
        "operation": "receive",
        "qty": "2",
        "scans": [
            "SN 2304K118842",
            "0885911425308",
        ],
    },
    "item": {
        "sku": "DCD771C2",
        "description": "20V cordless drill kit",
        "serial_controlled": True,
        "gtin": "00885911425308",
        "identifiers": [
            "DCD771C2",
        ],
        "serial_format": "S/N then 4 digits, a letter, 6 digits",
    },
    "active_serials": [],
}

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": "serial",
  "proposal": {
    "operation": "receive",
    "qty": "2",
    "scans": [
      "SN 2304K118842",
      "0885911425308"
    ]
  },
  "item": {
    "sku": "DCD771C2",
    "description": "20V cordless drill kit",
    "serial_controlled": true,
    "gtin": "00885911425308",
    "identifiers": [
      "DCD771C2"
    ],
    "serial_format": "S/N then 4 digits, a letter, 6 digits"
  },
  "active_serials": []
};

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",
    "item"
  ],
  "additionalProperties": false,
  "properties": {
    "decision": {
      "const": "serial"
    },
    "proposal": {
      "type": "object",
      "required": [
        "operation",
        "qty",
        "scans"
      ],
      "additionalProperties": false,
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "receive",
            "pick",
            "pack",
            "count"
          ]
        },
        "qty": {
          "type": "string",
          "format": "decimal"
        },
        "scans": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "maxItems": 1000
        }
      }
    },
    "item": {
      "type": "object",
      "required": [
        "sku",
        "serial_controlled"
      ],
      "additionalProperties": false,
      "properties": {
        "sku": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4000
        },
        "serial_controlled": {
          "type": "boolean"
        },
        "gtin": {
          "type": "string",
          "pattern": "^\\d{8}$|^\\d{12,14}$"
        },
        "identifiers": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "maxItems": 20
        },
        "serial_mask": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "serial_format": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4000
        }
      }
    },
    "active_serials": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200
      },
      "maxItems": 100000
    },
    "source_serials": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200
      },
      "maxItems": 100000
    }
  }
}
```
