The webhook 2.0 will be discontinued on 28th Feb, 2015. Please update your code to use the newest 4.0 webhook.

You can choose the webhook version in your account Settings --> Triggers --> Webhook.

What's new in 4.0?

* It support required fields for the tracking, such as `tracking_account_number`, `tracking_postal_code`, `tracking_ship_date`, `tracking_key`, `tracking_destination_country`

* the tracking object now include the `id` value

* Please take note that `checkpoint_time` and `expected_delivery` is a string that returns possible value: Empty String, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+TIMEZONE

How to setup the Webhooks

Webhooks is only supported in premium account. You can enable Settings --> Triggers --> Webhook

Securing Webhooks

We currently support either HTTP or HTTPS urls, so you can have security by using an SSL-enabled url. But keep in mind that your endpoint is going to be wide-open on the internet, and you might not want others to be able to submit random data to your systems. At this time, aside from trying to keep the URL private, our best suggestion is to simply include a secret key in the URL that your provide and check the secret GET parameter in your scripts.

Retry Webhooks

AfterShip sent the events for each webhook URL with POSTs request. If the webhook URL doesn't return a 200 HTTPresponse code, that POST request will be re-attempted up to 14 times in increasing intervals: 2^number_of_fail x 30s

If the attempt fail, AfterShip will retry the 2nd attempt 30s later.
If the 5th attempts fail, AfterShip retry the 6th attempt 960s later
If the 14th attempts fail, AfterShip retry not send out that webhook any more.

Webhook 4.0

What is the format of inbound webhooks?

When the tracking is updated and it triggers an update of one of your trigger setting, we make a POST request to the callback URL that you defined in the webhook page.The post body contains a JSON string of the below data.
  • ts - UTC unix timestamp that the event occurred
  • event - the name of the event (for tracking update, the value will be 'tracking_update')
  • msg - details about the message for which the event occurred, in the following format.