Introduce
# What is a Webhook?
Webhook is a way for users to change the Web application by customizing callback function. Through Webhook, you can customize some behavior notifications to the specified URL. When the requests are done, the Webhook will respond to the corresponding data through the URL you set. When the logistics information is updated and the status update reminder in the settings is triggered, the system will make a POST request and send it to your custom callback url in the webhook page. The POST body contains JSON strings of the following data:
# The POST body contains JSON strings of the following data:
{
"data": {
"createTime": "2021-09-24 14:57:51",
"deliveredDays": 4,
"deliveredTime": "2021-08-12 10:32:41",
"id": 229255084490768384,
"lastTrackingTime": "2021-08-12 10:32:41",
"localLogisticsInfo": {
"courierCode": "4px",
"courierHomePage": "http://express.4px.com/",
"courierNameCN": "递四方",
"courierNameEN": "4PX",
"trackingDetails": [
{
"address": "Mableton, GA",
"eventDetail": "Delivered",
"eventTime": "2021-08-12 10:32:41",
"transitSubStatus": "DELIVERED_01"
},
{
"address": "AUSTELL, GA",
"eventDetail": "On fedex vehicle for delivery",
"eventTime": "2021-08-12 03:09:00",
"transitSubStatus": "WAITING_DELIVERY_01"
},
{
"address": "AUSTELL, GA",
"eventDetail": "Arrived at fedex location",
"eventTime": "2021-08-12 03:04:00",
"transitSubStatus": "IN_TRANSIT_01"
},
{
"address": "AUSTELL, GA",
"eventDetail": "In transit",
"eventTime": "2021-08-11 17:26:46",
"transitSubStatus": "IN_TRANSIT_01"
},
{
"address": "KENNESAW, GA",
"eventDetail": "Departed fedex location",
"eventTime": "2021-08-11 04:30:39",
"transitSubStatus": "IN_TRANSIT_01"
},
{
"address": "EDISON, NJ",
"eventDetail": "Departed fedex location",
"eventTime": "2021-08-09 10:27:51",
"transitSubStatus": "IN_TRANSIT_01"
},
{
"address": "USNYCA",
"eventDetail": "Packing the operating point",
"eventTime": "2021-08-07 00:40:24",
"transitSubStatus": "INFO_RECEIVED_01"
},
{
"address": "USNYCA",
"eventDetail": "Picking the operating point",
"eventTime": "2021-08-07 00:13:57",
"transitSubStatus": "INFO_RECEIVED_01"
},
{
"address": "",
"eventDetail": "Shipment information sent to fedex",
"eventTime": "2021-08-06 17:34:00",
"transitSubStatus": "INFO_RECEIVED_01"
}
]
},
"orderTime": "2021-08-06 17:34:00",
"receiptDays": 39,
"receiptTime": "2021-08-09 10:27:51",
"shipFrom": "US",
"shipTime": "2021-07-01 12:30:31",
"shipTo": "US",
"trackNo": "282295361468",
"transitStatus": "DELIVERED",
"transitSubStatus": "DELIVERED_01"
},
"verify": {
"signature": "e53cf138931ad85d20955dfc6a0355e777f915a4f511e147c9bd2c6942273151",
"timestamp": "1632466678868"
}
}
# Sign verification
To ensure that the information source is Track123, it is recommended to verify the sign of the received data(You can also directly parse the POST data without verification) .The method of security authentication is as follows:
- Parse out the two parameters timestamp and signature in the POST data.
- Use your Track123 API key and timestamp (plain text) to generate a signature, and verify it with the signature in the POST data ( signature algorithm: PHP: SHA256, JAVA: HmacSHA256 )
# How does it work?
- Log in to the Track123 membership system, and set your webhook url and alert status: https://member.track123.com/#/settings/webhook (opens new window)
- When the server detects that the tracking information is updated and meets your settings, the updated data will be pushed to the webhook URL path set. So you need to pre-write your own program in the webhook URL to process the received webhook data.
- Webhook retry: When your url cannot be connected, or a 200 response is set to be returned but the server does not get the correct HTTP response code for the push, the server will retry the push 6 times. See below for the retry interval:
Times of attempts | Times of retries | Retry interval (sec) |
---|---|---|
1 | 0 | 0 |
2 | 1 | 600 |
3 | 2 | 1800 |
4 | 3 | 3600 |
5 | 4 | 14400 |
6 | 5 | 43200 |
7 | 6 | 129600 |