Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Inventory Events

Inventory events are triggered when inventory items are received, produced, modified, moved, or destroyed.

Copy these interfaces to type your webhook handlers:

/** Base event properties included in all webhook events */
interface BaseEvent {
/** Unique event identifier (UUID) */
id: string;
/** Event type */
kind: string;
/** ISO 8601 timestamp */
time: string;
/** Transaction identifier for grouping related events */
transactionId: string;
}
/** Entity object included in inventory events */
interface Entity {
/** Entity UUID */
id: string;
/** Entity name/code (e.g., "BATCH-001") */
name: string;
/** Product UUID */
productId: string;
/** Quantity */
quantity?: number;
/** Custom attributes */
attributes?: Record<string, unknown>;
}
/** Node/location reference */
interface Node {
/** Node UUID */
id: string;
/** Node name (e.g., "Receiving Bay 1") */
name: string;
/** Node type */
type: "stage" | "container" | "bundle";
}
/** Change tracking for inventory modifications */
interface EntityChanges {
attributes: {
add: Array<{ key: string; value: unknown }>;
updated: Array<{ key: string; value: unknown }>;
removed: string[];
};
correlations: {
add: string[];
updated: string[];
removed: string[];
};
spawns: {
add: string[];
};
}

Triggered when inventory is received into the system.

{
"id": "evt_abc123",
"kind": "inventory.received",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"entity": {
"id": "ent_456",
"name": "BATCH-001",
"productId": "prod_789",
"quantity": 100,
"attributes": {}
},
"node": {
"id": "node_abc",
"name": "Receiving Bay 1",
"type": "stage"
}
}

Triggered when inventory is created via a transformation (production).

{
"id": "evt_abc123",
"kind": "inventory.produced",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"entity": {
"id": "ent_456",
"name": "FINISHED-001",
"productId": "prod_789",
"quantity": 50
},
"node": {
"id": "node_abc",
"name": "Production Line 1",
"type": "stage"
}
}

Triggered when inventory attributes or correlations are updated.

{
"id": "evt_abc123",
"kind": "inventory.modified",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"entityId": "ent_456",
"changes": {
"attributes": {
"add": [{ "key": "temperature", "value": "4C" }],
"updated": [],
"removed": []
},
"correlations": {
"add": [],
"updated": [],
"removed": []
},
"spawns": {
"add": []
}
}
}

Triggered when inventory is moved to a new location (stage or container).

{
"id": "evt_abc123",
"kind": "inventory.moved",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"entity": {
"id": "ent_456",
"name": "BATCH-001",
"productId": "prod_789"
},
"from": {
"id": "node_abc",
"name": "Receiving Bay 1",
"type": "stage"
},
"to": {
"id": "node_def",
"name": "Cold Storage",
"type": "stage"
}
}

Triggered when inventory is moved into a bundle.

{
"id": "evt_abc123",
"kind": "inventory.bundled",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"entity": {
"id": "ent_456",
"name": "BATCH-001",
"productId": "prod_789"
},
"from": {
"id": "node_abc",
"name": "Staging Area",
"type": "stage"
},
"to": {
"id": "bundle_def",
"name": "PALLET-001",
"type": "bundle"
}
}

Triggered when inventory is destroyed or consumed.

{
"id": "evt_abc123",
"kind": "inventory.destroyed",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"entityId": "ent_456"
}

Triggered when inventory is marked as waste.

{
"id": "evt_abc123",
"kind": "inventory.wasted",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"entityId": "ent_456",
"reason": "Expired"
}

Triggered when multiple inventory items are merged into a single item.

{
"id": "evt_abc123",
"kind": "inventory.merged",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"mergedEntity": {
"id": "ent_789",
"name": "MERGED-001",
"productId": "prod_123",
"quantity": 200
},
"sourceEntityIds": ["ent_456", "ent_457"],
"sourceEntityNames": ["BATCH-001", "BATCH-002"],
"node": {
"id": "node_abc",
"name": "Merge Station",
"type": "stage"
}
}

Triggered when a merge operation is reverted, restoring the original items.

{
"id": "evt_abc123",
"kind": "inventory.merge.reverted",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"revertedEntityId": "ent_789",
"restoredEntityIds": ["ent_456", "ent_457"],
"restoredEntityNames": ["BATCH-001", "BATCH-002"],
"node": {
"id": "node_abc",
"name": "Merge Station",
"type": "stage"
}
}

Triggered when inventory is restored via deconstruction.

{
"id": "evt_abc123",
"kind": "inventory.restored",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"flowId": "flow_123",
"restoredEntityId": "ent_456",
"sourceEntityId": "ent_789",
"sourceEntityName": "FINISHED-001",
"node": {
"id": "node_abc",
"name": "Deconstruction Station",
"type": "stage"
}
}

Union type for handling any inventory event:

type InventoryEvent =
| InventoryReceivedEvent
| InventoryProducedEvent
| InventoryModifiedEvent
| InventoryMovedEvent
| InventoryBundledEvent
| InventoryDestroyedEvent
| InventoryWastedEvent
| InventoryMergedEvent
| InventoryMergeRevertedEvent
| InventoryRestoredEvent;
// Type guard for inventory events
function isInventoryEvent(event: BaseEvent): event is InventoryEvent {
return event.kind.startsWith("inventory.");
}