Taxonomy ID System
Switchyard uses an 18-digit taxonomy ID system as a scannable, human-readable alternative to UUIDs. Every entity in the system has both a UUID (for internal database operations) and a taxonomy ID (for scanning, display, and external references).Overview
Taxonomy IDs are designed to be:- Scannable - Can be printed as Code 128 barcodes
- Checksum-protected - MOD-97 validation prevents typos
- Type-aware - First digits identify the entity type
- Globally unique - No collisions across entity types
All V1 API endpoints accept both UUIDs and taxonomy IDs as the
:id parameter. The system automatically detects and resolves the correct format.ID Format (Memory Map)
An 18-digit taxonomy ID follows this structure:| Offset | Width | Field | Allowed | Description |
|---|---|---|---|---|
| 0 | 2 | VER | 01 | Schema version. Reserve 90-99 for future versions |
| 2 | 2 | TYPE | See table below | Entity type. Partitions the ID space |
| 4 | 3 | FAC | 000–999 | Facility/site code. Single site uses 000 |
| 7 | 7 | SEQ | 0000000–9999999 | Per-TYPE per-FAC counter |
| 14 | 2 | RSV | 00–99 | Reserved for future use (flags, subtypes). Keep 00 |
| 16 | 2 | CS | 00–96 | MOD-97 checksum over digits 0–15 |
Type Allocations
Each entity type has a unique 2-digit TYPE code:| TYPE | Entity | Database Table | Description |
|---|---|---|---|
10 | Tote | totes | Container for order items |
11 | Robot | robots | Delivery robot |
13 | Product | sellable_products | Sellable product in the catalog |
14 | Sweep | sweeps | Warehouse sweep operations |
20 | Cart | carts | Picking cart (holds up to 3 totes) |
21 | Bag | bags | Order bag (ambient/cold/frozen) |
22 | Inventory Group | inventory_groups | Warehouse location/slot |
23 | Staff | staff | Employee |
24 | Retailer Location | retailer_locations | Store/retailer location |
25 | Portal | pickup_portals | Pickup portal |
27 | Manifest | partner_manifests | Partner brand shipment manifest |
50–89 | Reserved | — | Lot tracking, vendor/batch use |
90–99 | Future Schema | — | Reserved for schema evolution |
Type codes
12, 15–19, 26, and 28–49 are currently unassigned and available for future entity types.Entity Type Details
TYPE 10 - Totes
TYPE 10 - Totes
Physical containers used to hold items during fulfillment. Uses
tote_code column in the totes table.Use cases:- Order picking containers
- Receiving containers
- Inter-zone transfer bins
01 10 000 0100001 00 CS → Tote #100001TYPE 11 - Robots
TYPE 11 - Robots
Autonomous delivery robots for warehouse operations. Primary key is the taxonomy ID in the
robots table.Use cases:- Delivery robots
- Picking assistants
01 11 000 0100001 00 CS → Robot #100001TYPE 13 - Products
TYPE 13 - Products
Sellable products in the catalog. Has a
taxonomy_id column on the sellable_products table.Use cases:- Product lookup
- Inventory tracking
- Order line items
01 13 000 0100001 00 CS → Product #100001TYPE 14 - Sweeps
TYPE 14 - Sweeps
Warehouse sweep operations for inventory management. Has a
taxonomy_id column on the sweeps table.Use cases:- Inventory sweep tracking
- Cycle counts
01 14 000 0100001 00 CS → Sweep #100001TYPE 20 - Carts
TYPE 20 - Carts
Picking carts that hold up to 3 totes. Primary key is the taxonomy ID in the
carts table. Each cart has a color+animal identification name.Use cases:- Order picking workflows
- Tote assignment
01 20 000 0100001 00 CS → Cart #100001TYPE 21 - Bags
TYPE 21 - Bags
Order bags with temperature zone support (ambient, cold, frozen). Uses
bag_code column in the bags table.Use cases:- Order packaging
- Temperature zone segregation
01 21 000 0100001 00 CS → Bag #100001TYPE 22 - Inventory Groups
TYPE 22 - Inventory Groups
Warehouse locations and inventory slots. Has a
taxonomy_id column on the inventory_groups table.Use cases:- Warehouse location tracking
- Slot/bin identification
- Zone management
01 22 000 0100001 00 CS → Inventory Group #100001TYPE 23 - Staff
TYPE 23 - Staff
Employees and warehouse staff. Has a
taxonomy_id column on the staff table.Use cases:- Staff identification
- Task assignment
- Access control
01 23 000 0100001 00 CS → Staff #100001TYPE 24 - Retailer Locations
TYPE 24 - Retailer Locations
Store and retailer locations. Has a
taxonomy_id column on the retailer_locations table.Use cases:- Location identification
- Multi-store operations
01 24 000 0100001 00 CS → Retailer Location #100001TYPE 25 - Portals
TYPE 25 - Portals
Pickup portals for order collection. Has a
taxonomy_id column on the pickup_portals table.Use cases:- Customer pickup points
- Portal scanning
01 25 000 0100001 00 CS → Portal #100001TYPE 27 - Manifests
TYPE 27 - Manifests
Partner brand shipment manifests. Has a
taxonomy_id column on the partner_manifests table. Used for QR code scanning of incoming partner shipments.Use cases:- Partner shipment receiving
- QR code scanning
- Manifest tracking
01 27 000 0100001 00 CS → Manifest #100001SEQ Reservation Bands
Within each TYPE×FAC combination, the 7-digit SEQ space is divided:| SEQ Range | Purpose |
|---|---|
0000000–0099999 | Test/Temporary - Development and testing |
0100000–8999999 | Production - Live working pool (~8.9M IDs) |
9000000–9999999 | Future/Expansion - Reserved for growth |
Checksum Calculation
The 2-digit checksum (CS) at positions 16-17 is calculated using MOD-97:Examples (FAC=000, RSV=00)
| Entity | Base (first 16 digits) | CS | Complete Taxonomy ID |
|---|---|---|---|
| Tote #100001 | 0110000010000100 | 0110000010000100 mod 97 | 18-digit result |
| Robot #100001 | 0111000010000100 | 0111000010000100 mod 97 | 18-digit result |
| Product #100001 | 0113000010000100 | 0113000010000100 mod 97 | 18-digit result |
| Cart #100001 | 0120000010000100 | 0120000010000100 mod 97 | 18-digit result |
| Bag #100001 | 0121000010000100 | 0121000010000100 mod 97 | 18-digit result |
| Staff #100001 | 0123000010000100 | 0123000010000100 mod 97 | 18-digit result |
| Manifest #100001 | 0127000010000100 | 0127000010000100 mod 97 | 18-digit result |
The checksum provides typo detection. If a user manually enters an ID incorrectly, the checksum validation will fail.
Database Implementation
Taxonomy IDs are automatically generated by database triggers when new entities are created.Table Structure
Each table with taxonomy IDs has:Generation Trigger
Theset_taxonomy_id() trigger function runs on INSERT for supported tables and auto-generates a taxonomy ID if one is not already provided:
Totes, robots, carts, and bags use their taxonomy ID as a primary key or dedicated code column (
tote_code, bag_code) rather than the trigger-based approach. Their IDs are generated during table seeding.API Usage
Dual ID Support
All V1 API endpoints accept both UUIDs and taxonomy IDs:ID Resolution
The API automatically detects the ID format and resolves taxonomy IDs to UUIDs for database queries:resolveId() utility:
sellable_productsstaffinventory_groupssweepsretailer_locations
Detection Logic
Barcode Implementation
Code 128 Set C
Taxonomy IDs are optimized for Code 128 Set C encoding:- 18 digits = 9 symbol pairs
- Highly compact barcode
- Fast scanning
Label Format
Validation
Client-Side Validation
Server-Side Validation
The API validates taxonomy IDs using Zod schemas:TypeScript Types
The taxonomy ID system exposes the following types and utilities fromapps/api/src/lib/taxonomy-id.ts:
EntityType
TYPE_CODES
Utility Functions
| Function | Description |
|---|---|
generateTaxonomyId(type, seq, fac?, ver?, rsv?) | Generate a taxonomy ID for a given entity type and sequence |
validateTaxonomyId(id) | Validate format and MOD-97 checksum |
parseEntityType(id) | Extract the EntityType from a taxonomy ID |
parseTaxonomyId(id) | Parse into all component parts (version, type, facility, sequence, reserved, checksum) |
formatDisplayId(id) | Extract the 5-digit display sequence |
formatEntityLabel(id) | Format as human-readable label (e.g., “Cart 00001”) |
calculateChecksum(digits) | Calculate MOD-97 checksum for a 16-digit base string |
Best Practices
Use Taxonomy IDs for Display
Show taxonomy IDs in user interfaces and printed materials. They’re easier to read and verify than UUIDs.
Store UUIDs Internally
Use UUIDs for database foreign keys and internal references. Taxonomy IDs are for external interfaces.
Validate on Input
Always validate the checksum when accepting taxonomy ID input to catch typos early.
Include Both in Exports
When exporting data, include both the UUID and taxonomy ID for maximum compatibility.
Related Documentation
- Data Model - Database schema and relationships
- V1 API Overview - API endpoint documentation
- Scanner API Guide - Mobile scanning integration