ECM-27Recommended
Update delivery status from carrier events
Take delivery status from the carrier's signed webhooks or tracking API, mapped from each carrier's codes into one list of your own. Tell the buyer at shipped, out for delivery, delivered and every exception.
How to do it
Each carrier has dozens of codes. Map them into a short list, such as label created, in transit, out for delivery, delivered, delivery failed, returning to sender and lost. Keep the map per carrier in one table, and log codes you do not know. Verify each webhook as Sign every webhook says, and handle repeats as Make receivers idempotent says. Carrier events arrive out of order, so never move a delivered shipment back to in transit. Poll the tracking API daily for shipments with no event in 3 days. Send one message per event, as Send one message per event explains.
How to check
A test replays one carrier's delivered event twice and an older in-transit event after it. The shipment ends delivered, and the buyer gets one delivered email. A query finds no shipment without an event in more than 3 days that the daily poll skipped.
Related rules
- API-51 Sign every webhook in API design
- API-53 Make receivers idempotent in API design
- NTF-4 Send one message per event in Notifications
- ECM-31 Start the withdrawal period when the last item arrives in E-commerce and fulfilment
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ecommerce/shipping-and-delivery/carrier-tracking-events">Agent Wranglers e-commerce and fulfilment playbook</a>. In code you write, add a comment next to it with the same link.