After an order is placed, store the merchant order ID, merchant name, and expected delivery window in a persistent order tracker.
Poll the merchant's order status API at a decreasing-frequency schedule (frequently after shipment, less frequently once out for delivery); map the merchant's status codes to canonical states: placed, processing, shipped, out_for_delivery, delivered, exception.
When an order transitions to 'shipped', extract the carrier and tracking number from the API response and register it with the carrier's tracking API to receive status updates directly.
As a redundant channel, parse shipping confirmation emails: extract tracking numbers using regex patterns for major carriers (UPS, FedEx, USPS, DHL formats) and order confirmation numbers from the email subject and body.
Emit a delivery confirmation event when the order reaches 'delivered' state; start the return eligibility window timer at this point.
If an 'exception' or delivery failure state is detected, escalate to a human with the order details and carrier exception message.
Known gotchas
Merchant order status APIs are often not real-time; carrier tracking APIs tend to be more current once a label is scanned; cross-reference both for the most accurate status.
Tracking number formats vary by carrier and can overlap; always use the carrier code alongside the tracking number to route to the correct carrier API.
Email parsing for tracking numbers is fragile if the merchant changes their email template; treat email parsing as a fallback to API polling, not the primary source of truth.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp