Auto-register new Shopify shipments in AfterShip
When a Shopify order ships, we grab the tracking number and open a matching AfterShip tracking so every shipment is monitored without manual entry.
Whenever a new or updated order lands in Shopify, mirror its shipment into AfterShip so every parcel gets tracked automatically. This is a deterministic pipeline with a fixed input schema and no reasoning required.
Trigger: poll Shopify Orders events. For each order the trigger delivers, run the pipeline below.
Step 1. Call Shopify List Fulfillments for Order using the incoming order id. Look at every fulfillment on the order and collect its tracking_number and tracking_company (the courier name Shopify recorded).
Step 2. Skip any fulfillment that has no tracking_number, and skip any tracking number the workflow has already registered on a previous run (keep a small state store of tracking numbers we have created, or check AfterShip List Trackings by tracking_number before creating). This keeps the workflow idempotent even though the Shopify Orders trigger will fire again when the order is edited.
Step 3. For each remaining fulfillment, call AfterShip Create Tracking with the tracking_number, the customer's email from the Shopify order (order.email or order.customer.email), an order_id set to the Shopify order name (e.g. #1001), and a title such as "Shopify order #1001". If Shopify recorded a tracking_company, pass it as the slug; if the courier is unknown or blank, omit slug entirely so AfterShip auto-detects the courier.
Step 4 (optional). Once AfterShip returns the new tracking id, call Shopify Update Order to append a short note to the order note field, for example "AfterShip tracking: <id>". This gives ops a way to trace back from a Shopify order to its AfterShip record. Preserve any existing note text and only append.
Error handling: if AfterShip Create Tracking returns a duplicate error (meta.code 4022 or similar), treat the tracking number as already registered and continue. If it returns a courier detection error (4011/4012), log it and skip that tracking without failing the whole run. Every other AfterShip or Shopify error should fail the step so it can be retried.
Inputs: Shopify order id (from the trigger). Outputs: zero or more new AfterShip tracking ids per order, plus an updated Shopify order note when the optional step is enabled.
Additional information
What does this prompt do?
- Watches your Shopify store for new orders that have shipping tracking on them.
- Pulls the tracking number and courier from each fulfillment and opens a matching AfterShip tracking, tied to the customer's email and the Shopify order number.
- Skips orders that don't have tracking yet and any tracking number it has already registered, so the same shipment never gets created twice.
- Optionally writes the new AfterShip tracking id back onto the Shopify order note so ops can jump from an order straight to its shipment record.
What do I need to use this?
- A Shopify store you can connect (Admin API access with order and fulfillment read access, plus order write access if you want the tracking id written back to the order note).
- An AfterShip account with an API key.
- A rough sense of which couriers you use; the workflow lets AfterShip auto-detect the courier when Shopify hasn't recorded one.
How can I customize it?
- Turn the optional step that writes the AfterShip tracking id back to the Shopify order note on or off.
- Adjust how the workflow labels each tracking in AfterShip (for example use the Shopify order name, the customer name, or both).
- Filter which orders count — for example only orders above a certain value, only orders from a specific sales channel, or only orders shipping to certain countries.
Frequently asked questions
Does this work if my store uses multiple couriers?
What happens when an order gets updated later, for example when a second package ships?
Do I have to write the AfterShip id back to the Shopify order?
What if an order has no tracking number yet?
Will this send my customers shipment notifications?
Related templates
Stop hand-entering tracking numbers into AfterShip.
Let every new Shopify shipment register itself in AfterShip the moment it ships, with the customer email and order number already attached.