Skip to content

Shipment Events

Shipment events are triggered when shipments are created, updated, change status, have items assigned, or are deleted.

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;
}
/** Shipment status values */
type ShipmentStatus =
| "onHold"
| "ready"
| "pending"
| "loaded"
| "shipped"
| "inTransit"
| "completed"
| "canceled";

Triggered when a new shipment is created.

{
"id": "evt_abc123",
"kind": "shipment.created",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"shipmentId": "shp_456",
"shipmentShortId": "SHP-001",
"orderId": "ord_789",
"destination": "Toronto Warehouse"
}

Triggered when any tracked field on a shipment changes. The changes object contains only the fields that changed, each with from and to values.

{
"id": "evt_abc123",
"kind": "shipment.updated",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"shipmentId": "shp_456",
"shipmentShortId": "SHP-001",
"changes": {
"status": { "from": "onHold", "to": "shipped" },
"destination": { "from": null, "to": "Toronto Warehouse" }
}
}

Triggered when a shipment’s status is updated.

{
"id": "evt_abc123",
"kind": "shipment.status.changed",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"shipmentId": "shp_456",
"shipmentShortId": "SHP-001",
"previousShipmentStatus": "pending",
"currentShipmentStatus": "in_transit"
}
StatusDescription
onHoldShipment on hold, awaiting action
readyShipment ready to be loaded
pendingShipment pending dispatch
loadedShipment loaded onto transport
shippedShipment dispatched
inTransitShipment in transit to destination
completedShipment delivered and completed
canceledShipment cancelled

Triggered when items are assigned to a shipment for a specific order.

{
"id": "evt_abc123",
"kind": "shipment.items.assigned",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"shipmentId": "shp_456",
"shipmentOrderId": "ord_789"
}

Triggered when a shipment is deleted.

{
"id": "evt_abc123",
"kind": "shipment.deleted",
"time": "2024-01-15T10:30:00Z",
"transactionId": "txn_xyz789",
"shipmentId": "shp_456"
}

Union type for handling any shipment event:

type ShipmentEvent =
| ShipmentCreatedEvent
| ShipmentUpdatedEvent
| ShipmentStatusChangedEvent
| ShipmentItemsAssignedEvent
| ShipmentDeletedEvent;
// Type guard for shipment events
function isShipmentEvent(event: BaseEvent): event is ShipmentEvent {
return event.kind.startsWith("shipment.");
}
// Example webhook handler
async function handleShipmentWebhook(event: ShipmentEvent) {
switch (event.kind) {
case "shipment.created":
console.log(`New shipment created: ${event.shipmentShortId}`);
break;
case "shipment.updated":
console.log(`Shipment ${event.shipmentShortId} was updated`);
break;
case "shipment.status.changed":
console.log(
`Shipment ${event.shipmentShortId} changed from ${event.previousShipmentStatus} to ${event.currentShipmentStatus}`
);
if (event.currentShipmentStatus === "in_transit") {
// Send tracking notification to customer
} else if (event.currentShipmentStatus === "delivered") {
// Update order fulfillment status
}
break;
case "shipment.items.assigned":
console.log(
`Items assigned to shipment ${event.shipmentId} for order ${event.shipmentOrderId}`
);
break;
case "shipment.deleted":
console.log(`Shipment ${event.shipmentId} was deleted`);
break;
}
}