Skip to main content

8. Webhook

A webhook(also called a web callback) is a way for an application to provide real-time information. GHTK uses webhook to send notifications to partners upon order status changes. Every partner needs to provide GHTK a callback URL endpoint to receive instant updates upon order status changes.

E.g: callback URL

https://partner_example.com/updateShipment?hash=XXX
info

Example: an order with label ID: "S1.A1.17373471" (partner ID: "1234567") has been updated "successfully delivered".

GHTK system will send to partner’s callback link as below:

{
"partner_id" : "1234567",
"label_id": "S1.A1.17373471",
"status_id": 5,
"action_time": "2016-11-02T12:18:39+07:00",
"reason_code": "",
"reason": "",
"weight": 2.4,
"fee": 15000,
"pick_money": 100000,
"return_part_package": 0
}

Suppose partner’s callback link is https://partner_example.com/updateShipment?hash=XXX

Request sent from GHTK’s server to partner’s system:

POST /updateShipment?hash=XXX HTTP/1.1
Host: doitac.example.com
Content-type: application/x-www-form-urlencoded

label_id=S1.A1.17373471&partner_id=1234567&action_time=2016-11-02T12:18:39+07:00&status_id=5&reason_code=&reason=&weight=2.4&fee=1500&return_part_package=0
info

GHTK uses HTTP Status codes in responses to determine whether updates have been successfully sent to partners.

HTTP/1.1 200 OK
warning

If the response is null or different from 200, GHTK will resend the request

HTTP/1.1 500 Internal Server Error

Input parameters

ParameterDatatypeDescription
label_idStringGHTK’s reference ID (order.label)
partner_idStringPartner’s reference ID
status_idIntegerStatus code (refer to table below for list of status code)
action_timeStringrepresents time of updating order status .Format: ISO 8601
reason_codeIntegerReason code for update
reasonStringReason in text
weightFloatPackage weight in kilogram
feeIntegerShipping fee (in VND)
return_part_packageIntegerTo indicate if the order is a partial shipment. "1" if it is partial shipment

Order Status Details:

StatusDescription
-1Canceled order
1Not Confirmed: order submitted to GHTK’s system is awaiting to be validated and confirmed by the distributor. If shop is configured Automatic Confirmation and all the order’s information is valid, this status is "Confirmed" in default.
2Confirmed: The order is successfully submitted and a carrier will be assigned to pick up the order
3Picked/In warehouse: Carrier picked the order and put it in warehouse
4Delivering: carrier is on the way to deliver the order
5Delivered: order is delivered successfully
6Reconciled (In case of successful Delivery. Prior status is "5: Delivered")
7Failed to Pick Up (over 3 picking-up attempts or shop requested to cancel the order before it is picked up)
8Delay Picking Up
9Failed to Deliver (over 3 delivering attempts). The return process will be triggered then
10Delay Delivering
11Reconciled (in case of Failed to deliver. Prior stage is "9: Failed to Deliver")
12Picking Up: carrier is on the way to pick up the order
13Compensation order
20Returning: carrier attemtps maximum 3 times to return
21Returned: Package order is returned to shop
123Carrier reports order is picked up
127Carrier reports order is failed to pick up
128Carrier reports delay picking up
45Carrier reports order is delivered
49Carrier reports order is failed to deliver
410Carrier reports delay delivering
warning

Note:123, 127, 128, 45, 49, 410 are internal processing stages for notification only and not returned as order status in this API.

Reason code for Delay Picking Up (status_id=8):

reason_codeDescription
100Shop requests to delay picking up until the next shift
101Unable to contact shop owners
102Package order is not ready for picking up
103Shop changes pick-up address
104Shop changes the date of picking-up
105Carrier is overloaded
106Objective factors (e.g Weather)
107Others

Reason code for Failed to Pick Up (status_id=7):

reason_codeDescription
110Pick up address is not supported
111Product is not allowed to deliver (e.g prohibited products)
112Shop requests to cancel order
113Over 3 pick-up attempts
114Others
115Partner requests to cancel order via API

Reason code for Delay Delivering (status_id=10):

reason_codeDescription
120Carrier is overloaded
121Customer requests to delay until the next shift
122Unable to contact customer
123Customer requests to receive at another time
124Customer changes delivery address
125Wrong address, shop needs to double check
126Objective factors (e.g weather conditions)
127Others
128Shop changes delivery time
129Package is not found
1200Wrong contact number, shop needs to double check

Reason code for Failed to Deliver (status_id=9):

reason_codeDescription
130Customer refuses to recieve the products.
131Unable to contact over 3 times
132Customer requests to delay over 3 times
133Shop requests to cancel order
134Others
135Partner requests to cancel order via API

Reason code for Delay Returning:

reason_codeDescription
140Shop requests to delay until the next shift
141Unable to contact shop owners
142Shop is not at returning address
143Shop requests to receive returning order at another time
144Others