Instead of fetching updates for tracking, batch labels, and transactions manually, you can use Shippo webhooks to get notified when a status changes.
Setting Up and Testing Webhooks
You can set up webhooks on the API settings page of your Shippo Dashboard. This page also allows you to test webhooks with a sample payload.
Webhook Event Types
transaction_created: sent whenever a transaction is created in your account. The POST request body will contain a JSON of the Transaction object that was created.
transaction_updated: sent whenever a transaction is updated in your account. The POST request body will contain a JSON of the Transaction object that was updated.
track_updated: for tracking status updates. The POST request body will contain a JSON of the Tracking object.
- For API version 2017-03-29 and older, the body will contain the Transaction object if the label was created on Shippo.
- Shipment statuses are polled by us from the carrier API every ~2 hours, if there are any status changes, we immediately POST updates to the webhook.
batch_created: for creating the Batch object that contain Batch Shipments. This process is done asynchronously, so first you’d get an empty Batch object back, then Batch Shipments will be created in the background.
batch_purchased: for purchasing Batch Shipments through the Batch endpoint. This request is done asynchronously as well. Once purchases are complete, you will be able to download a merged PDF containing up to 100 labels per file.
Shippo-API-Version header is included in all webhook responses to indicate what version of the API is being used.
Expected Webhook Behavior
Shippo expects your webhook to return a response with a 2XX HTTP status code, indicating that the webhook has been received successfully. If Shippo doesn’t receive a 2XX response status code, the webhook POST request will be re-tried 1 time with a 3 second delay between each try. Thus each webhook will receive, at most, 2 messages within 3 seconds. It is recommended that the maximum response time for your webhook be of 5 seconds or less.