Back

Dec 5, 2025

Fulfillment Automation

H
Hyperfold Team
FulfillmentWorkflows

Fulfillment Flow

The Fulfillment Agent automates post-purchase operations:

  1. Order payment captured triggers fulfillment
  2. Agent selects optimal carrier based on rules
  3. Shipping label generated via carrier API
  4. Tracking number added to order
  5. Customer receives shipping notification

Carrier Setup

Connect your shipping carriers:

bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Add shipping carriers
$ hyperfold fulfillment providers add shipstation
> [OAuth] Opening ShipStation authorization...
> [Config] Configuring carrier accounts...
✓ ShipStation connected!
Carriers:
- USPS (Ground, Priority, Express)
- FedEx (Ground, 2Day, Overnight)
- UPS (Ground, 2nd Day Air, Next Day)
# Configure carrier selection rules
$ hyperfold fulfillment rules set
Rules configured:
- Orders < $50: USPS Ground
- Orders $50-150: FedEx Ground
- Orders > $150: FedEx Ground (Free shipping)
- Express selected: FedEx 2Day
- Overnight selected: UPS Next Day

Label Generation

Implement automatic label generation:

typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Fulfillment agent implementation
@HyperfoldAgent({
name: 'fulfillment-agent',
version: '1.0.0',
})
export class FulfillmentAgent {
@OnEvent('order.paid')
async handlePaidOrder(event: OrderPaidEvent) {
const { order_id } = event;
const order = await getOrder(order_id);
// Select optimal carrier based on rules
const carrier = await selectCarrier({
total: order.total,
shipping_option: order.shipping_option,
destination: order.shipping_address,
});
// Generate shipping label
const label = await createLabel({
carrier,
from: this.warehouseAddress,
to: order.shipping_address,
weight: calculateWeight(order.items),
dimensions: calculateDimensions(order.items),
});
// Update order with tracking
await updateOrder(order_id, {
status: 'shipped',
tracking_number: label.tracking_number,
carrier: carrier.name,
label_url: label.label_url,
});
// Notify customer
await sendShippingNotification(order, label);
}
}

Tracking Updates

Subscribe to carrier tracking webhooks:

typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Handle tracking updates
@OnWebhook('shipstation', 'tracking_update')
async handleTrackingUpdate(event: TrackingEvent) {
const { tracking_number, status, location, timestamp } = event;
// Find order by tracking number
const order = await findOrderByTracking(tracking_number);
// Update order status
await updateOrder(order.id, {
shipping_status: mapStatus(status),
last_location: location,
last_update: timestamp,
});
// Notify on key events
if (status === 'DELIVERED') {
await sendDeliveryConfirmation(order);
}
}

Returns Handling

Automate return label generation:

bash
1
2
3
4
5
6
7
8
# Configure return policy
$ hyperfold fulfillment returns configure \
--window=30d \
--free-returns=true \
--carrier=usps
# The agent automatically generates return labels when
# customers request returns within the policy window