Learn how AfterShip verifies and secures all the webhook requests.

Method

POST
application/json

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')
  • event_id - UUID v4 format, to uniquely identify the webhook event
  • is_tracking_first_tag - indicate if it is the first tracking update sent under a specific delivery tag. This allows application to send only the key updates to end users (e.g. the first in transit, the first failed attempt)
  • msg - details about the message for which the event occurred, in the following format.

Header

aftership-hmac-sha256: xxxxxxxxxxxxxxxx
Content-type: application/json
host: webhook.example.com
accept: application/json
content-length: 17676
Connection: close
Host: webhook.example.com
Content-Length: 12345
Accept: application/json
Aftership-Hmac-Sha256: xxxxxxxxxxxxxxxx
Content-Type: application/json
Accept-Encoding: gzip

Body

{
    "event_id": "3f645f5e-530b-4062-8695-db6a64420af8",
    "event": "tracking_update",
    "is_tracking_first_tag": true,
    "msg": {
        "id": "grhrexm6t3hiwkjwq37jd003",
        "tracking_number": "9361289676091361892011",
        "title": "9361289676091361892011",
        "note": null,
        "origin_country_iso3": "USA",
        "destination_country_iso3": "USA",
        "courier_destination_country_iso3": "USA",
        "shipment_package_count": null,
        "active": true,
        "order_id": null,
        "order_id_path": null,
        "order_date": "2021-01-02T08:52:54Z",
        "customer_name": null,
        "source": "web",
        "emails": [],
        "smses": [],
        "subscribed_smses": [],
        "subscribed_emails": [],
        "android": [],
        "ios": [],
        "return_to_sender": false,
        "custom_fields": {},
        "tag": "InTransit",
        "subtag": "InTransit_001",
        "subtag_message": "In Transit",
        "tracked_count": 1,
        "expected_delivery": null,
        "signed_by": null,
        "shipment_type": "Parcel Select",
        "created_at": "2021-01-14T10:41:23+00:00",
        "updated_at": "2021-01-14T10:41:24+00:00",
        "slug": "usps",
        "unique_token": "deprecated",
        "path": "deprecated",
        "shipment_weight": null,
        "shipment_weight_unit": null,
        "delivery_time": 1,
        "last_mile_tracking_supported": true,
        "language": null,
        "shipment_pickup_date": "2021-01-14T00:52:00",
        "shipment_delivery_date": null,
        "last_updated_at": "2021-01-14T10:41:24+00:00",
        "checkpoints": [
            {
                "location": "NORTH HAVEN, CT, 06473",
                "country_name": null,
                "country_iso3": null,
                "state": "CT",
                "city": "NORTH HAVEN",
                "zip": "06473",
                "message": "Picked Up by Shipping Partner, USPS Awaiting Item",
                "coordinates": [],
                "tag": "InfoReceived",
                "subtag": "InfoReceived_001",
                "subtag_message": "Info Received",
                "created_at": "2021-01-14T10:41:24+00:00",
                "checkpoint_time": "2021-01-13T13:39:00",
                "slug": "usps",
                "raw_tag": "80"
            },
            {
                "location": "NORTH HAVEN, CT, 06473",
                "country_name": null,
                "country_iso3": null,
                "state": "CT",
                "city": "NORTH HAVEN",
                "zip": "06473",
                "message": "Departed Shipping Partner Facility, USPS Awaiting Item",
                "coordinates": [],
                "tag": "InTransit",
                "subtag": "InTransit_001",
                "subtag_message": "In Transit",
                "created_at": "2021-01-14T10:41:24+00:00",
                "checkpoint_time": "2021-01-14T00:52:00",
                "slug": "usps",
                "raw_tag": "82"
            }
        ],
        "order_promised_delivery_date": null,
        "delivery_type": null,
        "pickup_location": null,
        "pickup_note": null,
        "tracking_account_number": null,
        "tracking_origin_country": null,
        "tracking_destination_country": null,
        "tracking_key": null,
        "tracking_postal_code": null,
        "tracking_ship_date": null,
        "tracking_state": null,
        "courier_tracking_link": "https://tools.usps.com/go/TrackConfirmAction?tLabels=9361289676091361892011",
        "first_attempted_at": null,
        "courier_redirect_link": "https://tools.usps.com/go/TrackConfirmAction?tRef=fullpage&tLc=2&text28777=&tLabels=9361289676091361892011,"
    },
    "ts": 1610620885
}