3. Shipping APIs
3.1. Submit Order API
This API is to submit an order to GHTK system.
Endpoint
Headers
POST /services/shipment/order/?ver=1.5 HTTP/1.1
Token: APITokenSample-ca441e70288cB0515F310742
X-Client-Source: S308157
Content-Type: application/json
{
"products": [
{
"name": "bút",
"weight": 0.1,
"quantity": 1,
"product_code": 1241,
"barcode": "AB123",
"cod_money": 10000
},
{
"name": "tẩy",
"weight": 0.2,
"quantity": 1,
"product_code": 1254,
"barcode": "AB123",
"cod_money": 10000
}
],
"order": {
"id": "a4",
"pick_name": "HCM-nội thành",
"pick_address": "590 CMT8 P.11",
"pick_province": "TP. Hồ Chí Minh",
"pick_district": "Quận 3",
"pick_ward": "Phường 1",
"pick_tel": "0911222333",
"tel": "0911222333",
"name": "GHTK - HCM - Noi Thanh",
"address": "123 nguyễn chí thanh",
"province": "TP. Hồ Chí Minh",
"district": "Quận 1",
"ward": "Phường Bến Nghé",
"hamlet": "Khác",
"is_freeship": "1",
"pick_date": "2016-09-30",
"pick_money": 47000,
"note": "Khối lượng tính cước tối đa: 1.00 kg",
"value": 3000000,
"transport": "fly",
"pick_option": "cod", // Đơn hàng xfast yêu cầu bắt buộc pick_option là COD
"deliver_option": "xteam", // nếu lựa chọn kiểu vận chuyển xfast
"pick_session": 2, // Phiên lấy xfast
"return_type": 1, // [1: store, 2: kho tổng] chỉ định là đơn trả về store hay đơn trả về kho tổng
"customer_ship_money": 20000,
"gam_solutions": [
{ "solution_id" : 12365478},
{ "solution_id" : 12365479},
{ "solution_id" : 12365470},
]
}
}
curl -X POST -H "Token: APITokenSample-ca441e70288cB0515F310742" \
-H "X-Client-Source: S308157" \
-H "Content-Type: application/json" \
-d '{"products":[{"name":"bút","weight":0.1,"quantity":1,"product_code": 1241},{"name":"tẩy","weight":0.2,"quantity":1,"product_code": 1254}],"order":{"id":"a4","pick_name":"HCM-nội thành","pick_address":"590 CMT8 P.11","pick_province":"TP. Hồ Chí Minh","pick_district":"Quận 3","pick_ward":"Phường 1","pick_tel":"0911222333","tel":"0911222333","name":"GHTK - HCM - Noi Thanh","address":"123 nguyễn chí thanh","province":"TP. Hồ Chí Minh","district":"Quận 1","ward":"Phường Bến Nghé","hamlet":"Khác","is_freeship":"1","pick_date":"2016-09-30","pick_money":47000,"note":"Khối lượng tính cước tối đa: 1.00 kg","value":3000000,"transport":"fly","pick_option":"cod","deliver_option" : "xteam","pick_session" : 2, "package_return_type": 1}}' "https://services.giaohangtietkiem.vn/services/shipment/order"
<?php
$order = '{"products":[{"name":"bút","weight":0.1,"quantity":1,"product_code":"23304A3MHLMVMXX625"},{"name":"tẩy","weight":0.2,"quantity":1,"product_code":""}],"order":{"id":"a4","pick_name":"HCM-nội thành","pick_address":"590 CMT8 P.11","pick_province":"TP. Hồ Chí Minh","pick_district":"Quận 3","pick_ward":"Phường 1","pick_tel":"0911222333","tel":"0911222333","name":"GHTK - HCM - Noi Thanh","address":"123 nguyễn chí thanh","province":"TP. Hồ Chí Minh","district":"Quận 1","ward":"Phường Bến Nghé","hamlet":"Khác","is_freeship":"1","pick_date":"2016-09-30","pick_money":47000,"note":"Khối lượng tính cước tối đa: 1.00 kg","value":3000000,"transport":"fly","pick_option":"cod","deliver_option":"xteam","pick_session":2,"tags":[1]}}';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://services.giaohangtietkiem.vn/services/shipment/order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $order,
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Token: APITokenSample-ca441e70288cB0515F310742",
"Content-Length: " . strlen($order),
),
));
$response = curl_exec($curl);
curl_close($curl);
echo 'Response: ' . $response;
?>
Input parameters:
Parameter | Datatype | Mandatory (Y)/(N) | Description |
---|---|---|---|
order | Object | Y | Detailed information of order sent to GHTK. |
products | Array | Y | List of products in the order. |
order.id | String | Y | Partner’s reference ID. |
Order picking information | |||
order.pick_name | String | Y | Name of the contact person to pick up the order. |
order.pick_money | Integer | Y | Cash amount which needs to be collected at delivery (in VND). |
order.pick_address_id | String | N | Address ID to pick up the order. This input takes precedence in identifying the pick up address if not null/empty. These ID can be find in tab “Edit shop information”. If pick_address_id is valid, province name, district name,… of pick up address will be following this ID. |
order.pick_address | String | Y | Address string to pick up the order. E.g: nhà số 5, tổ 3, ngách 11, ngõ 45 |
order.pick_province | String | Y | Province to pick up the order. E.g: Hà Nội |
order.pick_district | String | Y | District to pick up the order. E.g: Cầu Giấy |
order.pick_ward | String | N | Ward to pick up the order. E.g: Mai Dịch |
order.pick_street | String | N | Street to pick up the order. E.g: Nguyễn Chí Thanh |
order.pick_tel | String | Y | Phone number of the contact person to pick up the order. |
order.pick_email | String | N | Email contact to pick up the order. |
Order delivery information | |||
order.name | String | Y | Name of the contact person to deliver the order. |
order.address | String | Y | Detailed address to deliver the order. Eg: Chung cư CT1, ngõ 58, đường Trần Bình |
order.province | String | Y | Province to deliver the order. |
order.district | String | Y | District to deliver the order. |
order.ward | String | N | Ward to deliver the order. |
order.street | String | N | Street to deliver the order. |
order.hamlet | String | Y | Hamlet to deliver the order. If it is non-information, please fill “Khác”. |
order.tel | String | Y | Phone number of the contact person to deliver the order. |
order.note | String | N | Note of the order. The maximum length of note is 120 characters. E.g: Khối lượng tính cước tối đa: 1.00 kg. |
order.email | String | Y | Email contact to deliver the order. |
Order return information | |||
order.use_return_address | Integer (0/1) | N | This is to indicate if the return address should be different from pick up address. -“0” means return address is the same as pick up address hence the subsequence params (order.return_*) can be ignored. -“1” means return address is different from pick up address and GHTK should consider the subsequence params for order return. Default value is “0”. |
order.return_name | String | Y if order.use_return_address=1 | Name of the contact person to return the order. |
order.return_address | String | Detailed address to return the order. | |
order.return_province | String | Province to return the order. | |
order.return_district | String | District to return the order. | |
order.return_ward | String | N | Ward to return the order. |
order.return_street | String | N | Street to return the order. |
order.return_tel | String | Y if order.use_return_address=1 | Phone number of the contact person to return the order. |
order.return_email | String | Y | Email contact to return the order. |
Other information | order.is_freeship | Integer | N |
order.weight_option | String | N | Weighing unit (gram/kilogram). Default value is kilogram. |
order.total_weight | Double | N | Total weight of the order.Default value is sum amount of products.weight. |
order.pick_work_shift | Integer | N | To indicate the order will be picked up at which time. “3” is in the evening. “2” is in the afternoon and “1” is in the morning. Default value is set automatically by GHTK. |
order.deliver_work_shift | Integer | N | To indicate the order will be delivered at which time. “3” is in the evening. “2” is in the afternoon and “1” is in the morning. Default value is set automatically by GHTK. |
order.pick_date | String YYYY/MM/DD | N | Booking the picking-up date of the order. This field is enabled for certain service levels. |
order.deliver_date | String YYYY/MM/DD | N | Booking the delivering date of the order. This field is enabled for certain service levels. |
order.value | Integer | Y | Declared monetary value of the order package. The insurance fee is calculated based on this value. (in VND) |
order.pick_option | String | N | Possible value is “cod” (Carrier picks up parcels at shop’s pick up address) or “post” (shop drops the parcels at GHTK’s service points). Default value is cod |
order.transport | String | N | This is the transportation method to deliver the parcel. Possible value is “fly” or “road”. If the transportation method is invalid, GHTK will switch automatically to default transportation method. |
order.deliver_option | String | N | is ‘xteam’ when the delivery method is XFAST service |
order.booking_id | String | Option | Booking id from the response of API get pick time (in case has XFAST service) |
order.tags | Array | N | Possible value is [1] : Display a glass shape on the label if the order has fragile product. Possible value is [7]: if the order has farm product, dry food. |
order.pending_order | Number | N | Order for reserve flow |
order.total_box | Number | N | Total box of order |
order.height | Number | N | Order’s height (cm) |
order.length | Number | N | Order’s length (cm) |
order.width | Number | N | Order’s width (cm) |
order.sub_tags | Array | N |
Detail options when you pick some services such as plant goods |
order.package_return_type | Integer | N | Mark return orders to store or main warehouse [1: store, 2: warehouse] |
order.customer_ship_money | Integer | N | The delivery fee agreed upon between the shop and the customer that the customer has to pay. |
order.gam_solutions | Array | N | List ID solutions of package. |
Product parameters
name | String | Y | Name of the product |
---|---|---|---|
price | Integer | N | Product’s price |
weight | Double | Y | Product’s weight |
quantity | Integer | N | Product’s quantity |
height | Integer | N | Product’s Height (cm ) |
length | Integer | N | Product’s Length (cm) |
width | Integer | N | Product’s Width (cm) |
product_code | Integer | N | Product’s code. This value is taken from product information list API |
barcode | String | N | The product’s barcode. |
cod_money | Integer | N | The cash-on-delivery (COD) amount for the product. |
Tags description
Tag ID | Tag | Nhãn đơn hàng | Description |
---|---|---|---|
1 | Fragile | Dễ vỡ | The items made of fragile materials are prone to damage and breakage during transportation. If any damage occurs, GHTK will take full responsibility for orders marked as Fragile. Cost 1,000 VND per order. |
2 | High-value items | Giá trị cao | Items valued at > 3,000,000 VND (for Pro Shop) and > 1,000,000 VND (for Standard Shop) will have an additional insurance fee, which is the insurance amount for risks during transportation or storage. The insurance fee is equal to 0.5% of the value of the goods. GHTK will reimburse 100% of the value when lost (maximum of 20,000,000 VND) if there is documentation proving the origin and value of the goods (import invoices, valid purchase invoices matching the product information on the GHTK system, etc.). If the shop cannot prove the origin and value of the goods, compensation will be a maximum of 04 times the shipping fee |
7 | Agricultural Products | Hàng nông sản | For agricultural products with a short shelf life (< 30 days ), the scheduled delivery time will not exceed 7 days from the successful pickup. Beyond this deadline, the order will not be automatically stored, and GHTK will return the items to shop. |
10 | Allowed to inspect the product | Cho xem hàng | Customers are allowed to inspect the product before accepting delivery. |
11 | Crosscheck | Cho thử hàng/ đồng kiểm | Customers are allowed to count the quantity or check the condition of each item (excluding breaking seals on the products). Cost 2,000 VND per order. |
13 | Call the shop when the customer does not receive the goods, cannot be contacted, or the information is incorrect. | Gọi cho shop khi không giao được, //Gọi cho shop khi khách không nhận được hàng, không liên lạc được, sai thông tin | GHTK staff will contact the shop in case of issues such as incorrect information, inability to contact the customer, or the customer refuses to receive the goods. |
17 | Partial Delivery - Customer Selects Products | Giao hàng 1 phần chọn sản phẩm | Customers are allowed to only accept and pay for a partial of the order. The remaining will be returned to shop with an intra-province fee of 5,000 VND per order and an interprovincial fee equal to 50% of the shipping fee. |
18 | Partial Delivery - Product Return | Giao hàng 1 phần đổi trả hàng | Assistance in delivering one item to the customer and returning the remaining portion to the shop. The returned portion is treated as a return order with an intra-province fee of 5,000 VND per order and an inter-province fee equal to 50% of the shipping fee. |
19 | Fee for unsuccessful delivery attempt. | Không giao được thu phí | Supporting customers who do not accept the product but collecting a partial fee for the shop. The fee to be collected defaults to the shipping fee, but the shop can adjust the amount they wish to collect. The returned portion for the shop is treated as a return order with an intra-province fee of 5,000 VND per order and an inter-province fee equal to 50% of the shipping fee. Note: Partners need to include an additional field “not_delivered_fee” with a value 0 < not_delivered_fee <= 20,000,000 VND . |
20 | Whole box | Hàng nguyên hộp | Items packed in the manufacturer’s box, requiring intact preservation during transportation. Cost 1,000 VND per order. |
22 | Mail and documents | Thư tín | Documents and files are carefully packaged to prevent damage to the products. |
39 | Fresh food | Thực phẩm tươi | For fresh and frozen food items with a same-day expiration date, if delivery to the customer is unsuccessful, GHTK will refund the order on the same day. |
40 | Small goods | Hàng nhỏ | Items with a weight of ≤ 300 grams.Small orders need to be packaged minimally in envelopes with dimensions of at least 110x120mm. |
42 | Items requiring proper orientation. | Hàng yêu cầu xếp đúng chiều | Goods must be arranged according to the correct orientation/direction of the product during transportation; otherwise, it will affect the safety and quality of the goods. |
52 | Liquid goods | Hàng chất lỏng | Liquid goods are items with physical characteristics in liquid, adhesive, or viscous form. Liquid goods need to be contained in specialized bottles or sealed bags. |
75 | Plant goods | Hàng cây cối | Orders tagged with ‘plants’ will be transported by GHTK through a separate shipping channel to ensure extended storage time and minimize external impact |
81 | BBS Eco Service | Dịch vụ bbs eco | BBS Eco Service |
Sub tags
Sub Tag ID | Miêu tả | Description |
---|---|---|
1 | Hạt giống | Seed |
2 | Cây non | Young plants |
3 | Cây có bầu | Plant with root ball |
4 | Cây có chậu dễ vỡ | Plant in a fragile pot |
5 | Các loại cây khác | Others |
Response
Response for confirmed order:
{
"success": true,
"message": "",
"order": {
"partner_id": "123123a",
"label": "S1.A1.1737345",
"area": "1",
"fee": "30400",
"insurance_fee": "15000",
"estimated_pick_time": "Sáng 2017-07-01",
"estimated_deliver_time": "Chiều 2017-07-01",
"products": [],
"status_id": 2
}
}
Response for failed order:
{
"success": false,
"message": "{ERROR_MESSAGE}",
"error_code": "{ERROR_CODE}",
"log_id": "{LOG_ID}"
}
:::warning Once an order is successfully submitted to GHTK system, it could not be reversed. In case the “order.id” already exists, shop will receive error response including
- code: “ORDER_ID_EXIST”
- partner_id: Partner ID
- ghtk_label: GHTK tracking number with alias
- created: created time of order
- status: the current status of order
:::
{
"success": false,
"message": "Mã đơn hàng của bạn đã tồn tại trên hệ thống GHTK",
"error": {
"code" : "ORDER_ID_EXIST",
"partner_id" : "a4",
"ghtk_label": "S1.A1.1737345",
"created": "2016-11-02T12:18:39+07:00",
"status": 5
}
}
Note
Info
Note: GHTK uses kilograms (KG) as the unit of weight for each product.
Warning
Note: The initial shipping fee will be calculated based on the total weight of the products in the order.
Warning
Note:
* If the order is set to is_freeship = 1
, COD (Cash on Delivery) will only collect the amount specified in pick_money from the recipient.
* If the value is set to 0
(default), COD will collect the amount specified in pick_money
plus the shipping fee of the order from the recipient.
Info
Note:
In cases where pick_address_id
has a valid value, the province, district, etc., information of the pickup point will be retrieved based on this address code.
The fields pick_province
and pick_district
are not required to be sent.
3.2. Calculate Shipping Fee API
This API provides the shipping fee based on given pickup & delivery address and the package weight.
{
"pick_province":"Hà Nội",
"pick_district":"Quận Hai Bà Trưng",
"province":"Hà nội",
"district":"Quận Cầu Giấy",
"address":"P.503 tòa nhà Auu Việt, số 1 Lê Đức Thọ",
"weight":1000,
"value":3000000,
"transport":"fly",
"deliver_option":"",
"tags": [1,7],
"subject_solution_group_ids": [20256455655,156652335655]
}
Request
GET /services/shipment/fee?address=P.503%20t%C3%B2a%20nh%C3%A0%20Auu%20Vi%E1%BB%87t,%20s%E1%BB%91%201%20L%C3%AA%20%C4%90%E1%BB%A9c%20Th%E1%BB%8D&province=H%C3%A0%20n%E1%BB%99i&district=Qu%E1%BA%ADn%20C%E1%BA%A7u%20Gi%E1%BA%A5y&pick_province=H%C3%A0%20N%E1%BB%99i&pick_district=Qu%E1%BA%ADn%20Hai%20B%C3%A0%20Tr%C6%B0ng&weight=1000&value=3000000&deliver_option=xteam HTTP/1.1
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
curl -X GET -H "Token: {API_TOKEN}" \
-H "X-Client-Source: {PARTNER_CODE}" \
"{OPEN_API}/services/shipment/fee?address=P.503%20t%C3%B2a%20nh%C3%A0%20Auu%20Vi%E1%BB%87t,%20s%E1%BB%91%201%20L%C3%AA%20%C4%90%E1%BB%A9c%20Th%E1%BB%8D&province=H%C3%A0%20n%E1%BB%99i&district=Qu%E1%BA%ADn%20C%E1%BA%A7u%20Gi%E1%BA%A5y&pick_province=H%C3%A0%20N%E1%BB%99i&pick_district=Qu%E1%BA%ADn%20Hai%20B%C3%A0%20Tr%C6%B0ng&weight=1000&value=3000000&deliver_option=xteam&tags%5B%5D=1"
<?php
$data = array(
"pick_province" => "Hà Nội",
"pick_district" => "Quận Hai Bà Trưng",
"province" => "Hà nội",
"district" => "Quận Cầu Giấy",
"address" => "P.503 tòa nhà Auu Việt, số 1 Lê Đức Thọ",
"weight" => 1000,
"value" => 3000000,
"transport" => "fly",
"deliver_option" => "xteam",
"tags" => [1,7]
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://services.giaohangtietkiem.vn/services/shipment/fee?" . http_build_query($data),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array(
"Token: APITokenSample-ca441e70288cB0515F310742",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo 'Response: ' . $response;
?>
Input parameters:
Parameter | Datatype | Mandatory (Y)/(N) | Description |
---|---|---|---|
pick_address_id | String | N | Address ID to pick up the order. This input takes precedence in identifying the pick up address if not null/empty. These ID can be found in tab “Edit shop information”. If pick_address_id is valid, province name, district name,… of pick up address will be following this ID. |
pick_address | String | N | Address string to pick up the order |
pick_province | String | Y | Province to pick up the order |
pick_district | String | Y | District to pick up the order |
pick_ward | String | N | Ward to pick up the order |
pick_street | String | N | Street to pick up the order |
address | String | N | Detailed address to deliver the order |
province | String | Y | Province to deliver the order |
district | String | Y | District to deliver the order |
ward | String | N | Ward to deliver the order |
street | String | N | Street to deliver the order |
weight | Integer | Y | Declared weight of the product (gram) |
value | Integer | N | Declared monetary value of the order package. The insurance fee is calculated based on this value. (in VND) |
transport | String | N | This is the transportation method to deliver the parcel. Possible value is “fly” or “road”. If the transportation method is invalid, GHTK will switch automatically to default transportation method |
deliver_option | String | Y | Possible value is “xteam” or “none”. Using “xteam” when the delivery method is Xfast. |
tags | Array | N | Possible value is [1] if the order has fragile product or [7] if the order has farm product, dry food. |
subject_solution_group_ids | Array | N | List id solution of package |
Response sample:
{
"success": true,
"message": "",
"fee": {
"name": "area1",
"fee": 30400,
"insurance_fee": 15000,
"delivery_type": "only_hanoi",
"a": 3,
"dt": "local",
"extFees": [
{
"display": "(+ 13,400 đ)",
"title": "Phụ phí gia cố",
"amount": 13400,
"type": "reinforced"
}
],
"delivery": true,
"ship_fee_only": 30400
}
}
Parameter | Datatype | Description |
---|---|---|
fee.name | String | Name of applied shipping rate Possible values: area1, area2, area3 |
fee.fee | Integer | Total fee amount (in VND) (fee = ship fee + insurance fee + ext fee) |
fee.ship_fee_only | Integer | Only Shipping Fee (in VND) |
fee.insurance_fee | Integer | Insurance fee amount (in VND) |
fee.delivery | Boolean | If the delivery address is supported by GHTK, respone is “true”. If it is not supported, the respone is “false”. |
fee.extFees | Object | Extra fee |
Ext Fee
Parameter | Datatype | Description |
---|---|---|
extFees.*.type | String | Key represents ext fee name |
extFees.*.display | String | Display amount of Ext Fee |
extFees.*.title | String | Name Ext Fee |
extFees.*.amount | Number | Extra fee |
ERROR RESPONSE
System error or unexpected error
Not found any suitable cost config
{
"success": true,
"message": "",
"fee": {
"name": "area2",
"fee": 0,
"insurance_fee": 0,
"delivery_type": "",
"a": 2,
"dt": "area",
"extFees": [],
"delivery": true,
"ship_fee_only": 0
}
}
Empty pick province or pick_district
{
"success": false,
"message": "Vui lòng kiểm tra tên tỉnh/thành phố nơi lấy hàng hóa",
"error_code": "60101",
"log_id": "ts680865040bdef"
}
{
"success": false,
"message": "Vui lòng kiểm tra tên quận/huyện nơi lấy hàng hóa",
"error_code": "60102",
"log_id": "d46808650ec14ff"
}
Empty customer province or customer district
{
"success": false,
"message": "Vui lòng kiểm tra tên tỉnh/thành phố của người nhận hàng hóa",
"error_code": "60103",
"log_id": "9n6808651f3fbca"
}
{
"success": false,
"message": "Vui lòng kiểm tra tên quận/huyện của người nhận hàng hóa",
"error_code": "60104",
"log_id": "h26808652cf1c1f"
}
3.3. Get Order Status API
This API provides the current status of the order. Request sample: Version 2: response including other information of the order
Input parameters:
Parameter | Mandatory (Y)/(N) | Description |
---|---|---|
Label ID | N | GHTK’s reference ID (order.label) |
Partner ID | N | Partner’s reference ID |
Response sample:
{
"success": true,
"message": "",
"order": {
"label_id": "S1.A1.17373471",
"partner_id": "1234567",
"status": "1",
"status_text": "Chưa tiếp nhận",
"created": "2016-10-31 22:32:08",
"modified": "2016-10-31 22:32:08",
"message": "Không giao hàng 1 phần",
"pick_date": "2017-09-13",
"deliver_date": "2017-09-14",
"customer_fullname": "Vân Nguyễn",
"customer_tel": "0911222333",
"address": "123 nguyễn chí thanh Quận 1, TP Hồ Chí Minh",
"storage_day": "3",
"ship_money": "16500",
"insurance": "16500",
"value": "3000000",
"weight": "300",
"pick_money": 47000,
"is_freeship": "1",
"verify_key": "{{verify_key}}"
}
}
Parameter | Datatype | Mandatory (Y)/(N) | Description |
---|---|---|---|
label_id | String | Y | GHTK’s reference ID |
partner_id | String | Y | Partner’s reference ID |
status | Integer | Y | Status code (refer to table “Order Status Details” below for list of status code) |
status_text | String | N | Status description (in Vietnamese) |
created | String | Y | Created date of the package order Format: YY-MM-DD hh:mm:ss |
modified | String | Y | Last modified date of the package order Format: YY-MM-DD hh:mm:ss |
message | String | N | Notes of the package order (in Vietnamese) |
pick_date | String | N | Picking-up date of order |
deliver_date | String | N | Delivery date of order |
customer_fullname | String | Y | Customer’s fullname |
customer_tel | String | Y | Customer’s phone number |
address | String | Y | Detailed address to deliver the order |
storage_day | Integer | N | Number of days to store the order at GHTK’s warehouse before returning |
ship_money | Integer | Y | Shipping fee |
insurance | Integer | N | Insurance fee |
value | Integer | N | Declared monetary value of the order package. The insurance fee will be calculated based on this value. (in VND) |
weight | Integer | Y | Weight of the package (in gram) |
pick_money | Integer | Y | Cash amount needs to be collected at delivery (in VND) |
is_freeship | Integer | N | To indicate if this is a free shipping order or not. |
verify_key | String | N | Key get cod info. |
3.4. Order Cancellation API
In case you want to cancel using GHTK’s tracking order.
Input parameters:
Parameter | Datatype | Mandatory (Y)/(N) | Description |
---|---|---|---|
Label ID | String | Y | GHTK’s reference ID (order.label) |
partner_id | String | Y | Partner’s reference ID |
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://services.giaohangtietkiem.vn/services/shipment/cancel/{TRACKING_ORDER}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array(
"Token: {API_TOKEN}",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo 'Response: ' . $response;
?>
Response
Cancel successfully
Cancelled order
Cases Where Order Cancellation Is Not Possible
Warning
Orders cannot be canceled after they have been successfully picked up. The API can only cancel orders in the following states:
- Created (1 & 2)
- Picking (12)
3.5. Print Label API
This API provides printing label for the package order in PDF format. This label can be pasted on the physical package and it contains the order details. E.g: barcode, shipping addresses, label id, …
Request sample:
Input parameters:
Parameter | Datatype | Mandatory (Y)/(N) | Description |
---|---|---|---|
Label ID | String | Y | GHTK’s reference ID (order.label) |
Response sample:
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename=""
Content-Transfer-Encoding: binary
Failed response: label id is not recognized or cannot be found
3.6 Create Pending Order
Request sample:
curl --location --request POST '{{url}}/services/shipment/pending-order' \
--header 'Token: {API_TOKEN}' \
--header 'X-Client-Source: {PARTNER_CODE}' \
Response sample:
Case 1: Get Success Pending Order
Case 2: Get Fail Pending Order
Case 3: Has Error
3.7 Submit BBS Order
3.7.1 Calculate shipping fee
REQUEST
curl --location --request POST '
{{url}}/services/shipment/3pl/fee' \
--header 'Content-Type: application/json' \
--header 'Token: {API_TOKEN}' \
--header 'X-Client-Source: {PARTNER_CODE}' \
--data-raw '{
"products": [
{
"width": 10,
"height": 10,
"length": 10,
"quantity": 1,
"weight": "100.1"
}
],
"pick_address": "số 12",
"pick_province": "đà nẵng",
"pick_district": "hòa vàng",
"pick_ward": "hòa bắc",
"value": 5000000,
"pick_street": "",
"customer_province": "hải dương",
"customer_district": "cẩm giàng",
"customer_ward": "Cẩm điền",
"customer_address": "số 12",
"customer_hamlet": "khác",
"tags" : [1],
"subject_solution_group_ids": [123456789101114,123456789101115]
}'
Path & method
Params:
Parameter | Mandatory | datatype | Description |
---|---|---|---|
pick_address | optional | String | Address string to pick up the order. E.g: nhà số 5, tổ 3, ngách 11, ngõ 45 |
pick_province | required | String | Province to pick up the order. E.g: Hà Nội |
pick_district | required | String | District to pick up the order. E.g: Cầu Giấy |
pick_ward | optional | String | Ward to pick up the order. E.g: Mai Dịch |
pick_street | optional | String | Street to pick up the order. E.g: Nguyễn Chí Thanh |
pick_hamlet | optional | String | Hamlet to pick up the order. If it is non-information, please fill “Khác”. |
customer_province | required | String | Province to deliver the order. |
customer_district | required | String | District to deliver the order. |
customer_ward | optional | String | Ward to deliver the order. |
customer_street | optional | String | Street to deliver the order. |
customer_hamlet | optional | String | Hamlet to deliver the order. If it is non-information, please fill “Khác”. |
customer_address | optional | String | Detailed address to deliver the order. Eg: Chung cư CT1, ngõ 58, đường Trần Bình |
products | required | array |
Product info of the order |
tags | optional | array | List of tag |
subject_solution_group_ids | optional | array | List id solution of package |
Product parameters
Field name | Mandatory | datatype | Description |
---|---|---|---|
name | required | String | Name of product |
price | optional | Number | Price of product |
quantity | required | Number | Quantity of product |
weight | required | Number | Weight of product |
length | required | Number | Length of product |
height | required | Number | Height of product |
width | required | Number | Width of product |
Tag parameters
Tag ID | Description |
---|---|
1 | Fragile |
7 | Food |
Response:
{
"success": true,
"data": {
"cost_id": 8740,
"real_weight": 100.1,
"distance": 749.286,
"value": 576000,
"transport": "road",
"flag": {
"base_costs": {
"20": 140000
},
"step": 5,
"increase": 20000
},
"region": "near_area",
"insurance": 25000,
"ext_fees": [
{
"type": "reinforced_fee",
"title": "Phụ phí đơn hàng gia cố",
"amount": 101000
}
],
"total_value": 702000
}
}
Param | Desc |
---|---|
insurance | Insurance fee amount (in VND) |
total_value | Shipping fee amount (in VND) |
ext_fees | Surcharge (in VND) |
3.7.2 Submit BBS Order
This API is to submit a BBS order to GHTK system.
REQUEST
POST /services/shipment/order/?ver=1.5 HTTP/1.1
Token:{API_TOKEN}
X-Client-Source: {PARTNER_CODE}
Content-Type:application/json
{
"products": [
{
"name": "iphone 1",
"weight": 20,
"quantity": 1,
"height":100,
"length":100,
"width":100,
"barcode": "AB123",
"cod_money": 10000
}
],
"order": {
"id": "a4",
"pick_name": "HCM-nội thành",
"pick_address": "590 CMT8 P.11",
"pick_province": "TP. Hồ Chí Minh",
"pick_district": "Quận 3",
"pick_ward": "Phường 1",
"pick_tel": "{REPLACE_BY_YOUR_TEL}",
"tel": "{REPLACE_BY_CUSTOMER_TEL}",
"name": "GHTK - HCM - Noi Thanh",
"address": "123 nguyễn chí thanh",
"province": "TP. Hồ Chí Minh",
"district": "Quận 1",
"ward": "Phường Bến Nghé",
"hamlet": "Khác",
"is_freeship": "1",
"pick_date": "2016-09-30",
"pick_money": 47000,
"note": "Khối lượng tính cước tối đa: 1.00 kg",
"value": 3000000,
"transport": "fly",
"pick_option": "cod",
"customer_ship_money: 20000,
"tags": [
1,
7
],
"3pl":1
}
}
Input parameters:
Parameter | Datatype | Mandatory (Y)/(N) | Description |
---|---|---|---|
order | Object | Y | Detailed information of order sent to GHTK. |
products | Array | Y | List of products in the order. |
order.id | String | Y | Partner’s reference ID. |
Order picking information | |||
order.pick_name | String | Y | Name of the contact person to pick up the order. |
order.pick_money | Integer | Y | Cash amount which needs to be collected at delivery (in VND). |
order.pick_address_id | String | N | Address ID to pick up the order. This input takes precedence in identifying the pick up address if not null/empty. These ID can be find in tab “Edit shop information”. If pick_address_id is valid, province name, district name,… of pick up address will be following this ID. |
order.pick_address | String | Y | Address string to pick up the order. E.g: nhà số 5, tổ 3, ngách 11, ngõ 45 |
order.pick_province | String | Y | Province to pick up the order. E.g: Hà Nội |
order.pick_district | String | Y | District to pick up the order. E.g: Cầu Giấy |
order.pick_ward | String | N | Ward to pick up the order. E.g: Mai Dịch |
order.pick_street | String | N | Street to pick up the order. E.g: Nguyễn Chí Thanh |
order.pick_tel | String | Y | Phone number of the contact person to pick up the order. |
order.pick_email | String | N | Email contact to pick up the order. |
Order delivery information | |||
order.name | String | Y | Name of the contact person to deliver the order. |
order.address | String | Y | Detailed address to deliver the order. Eg: Chung cư CT1, ngõ 58, đường Trần Bình |
order.province | String | Y | Province to deliver the order. |
order.district | String | Y | District to deliver the order. |
order.ward | String | N | Ward to deliver the order. |
order.street | String | N | Street to deliver the order. |
order.hamlet | String | Y | Hamlet to deliver the order. If it is non-information, please fill “Khác”. |
order.tel | String | Y | Phone number of the contact person to deliver the order. |
order.note | String | N | Note of the order. The maximum length of note is 120 characters. E.g: Khối lượng tính cước tối đa: 1.00 kg. |
order.email | String | Y | Email contact to deliver the order. |
Order return information | |||
order.use_return_address | Integer (0/1) | N | This is to indicate if the return address should be different from pick up address. -“0” means return address is the same as pick up address hence the subsequence params (order.return_*) can be ignored. -“1” means return address is different from pick up address and GHTK should consider the subsequence params for order return. Default value is “0”. |
order.return_name | String | Y if order.use_return_address=1 | Name of the contact person to return the order. |
order.return_address | String | Detailed address to return the order. | |
order.return_province | String | Province to return the order. | |
order.return_district | String | District to return the order. | |
order.return_ward | String | N | Ward to return the order. |
order.return_street | String | N | Street to return the order. |
order.return_tel | String | Y if order.use_return_address=1 | Phone number of the contact person to return the order. |
order.return_email | String | Y | Email contact to return the order. |
Other information | |||
order.is_freeship | Integer | N | To indicate if this is a free shipping order for customer. “0” means shipper needs to collect cash amount equal to pick_money + shipping fee of the order. “1” means shipper needs to collect the pick_money amount only and this is a freeshiping order for customer. Default value is “0”. |
order.pick_work_shift | Integer | N | To indicate the order will be picked up at which time. “3” is in the evening. “2” is in the afternoon and “1” is in the morning. Default value is set automatically by GHTK. |
order.deliver_work_shift | Integer | N | To indicate the order will be delivered at which time. “3” is in the evening. “2” is in the afternoon and “1” is in the morning. Default value is set automatically by GHTK. |
order.pick_date | String YYYY/MM/DD | N | Booking the picking-up date of the order. This field is enabled for certain service levels. |
order.deliver_date | String YYYY/MM/DD | N | Booking the delivering date of the order. This field is enabled for certain service levels. |
order.value | Integer | Y | Declared monetary value of the order package. The insurance fee is calculated based on this value. (in VND) |
order.opm | Integer | N | To indicate if this order is to collect cash from customer only (without delivering any goods). “1” means cash collection only. Default value is “0”. |
order.pick_option | String | N | Possible value is “cod” (Carrier picks up parcels at shop’s pick up address) or “post” (shop drops the parcels at GHTK’s service points). Default value is cod |
order.transport | String | N | This is the transportation method to deliver the parcel. Possible value is “fly” or “road”. If the transportation method is invalid, GHTK will switch automatically to default transportation method. |
order.tags | Array | N | Possible value is [1] : Display a glass shape on the label if the order has fragile product. Possible value is [7]: if the order has farm product, dry food. |
order.customer_ship_money | Integer | N | The delivery fee agreed upon between the shop and the customer that the customer has to pay. |
Product parameters
name | String | Y | Name of the product |
---|---|---|---|
price | Integer | N | Product’s price |
weight | Double | Y | Product’s weight |
quantity | Integer | Y | Product’s quantity |
length | Integer | Y | Length’s quantity |
width | Integer | Y | Width’s quantity |
height | Integer | Y | Height’s quantity |
product_code | Integer | Y | Product’s code. This value is taken from product information list API |
barcode | String | N | The product’s barcode. |
cod_money | Integer | N | The cash-on-delivery (COD) amount for the product. |
- Specific fields
Parameter | Datatype | Mandatory (Y)/(N) | Description |
---|---|---|---|
order.3pl | Integer | Yes | Set value 1 for BBS order option if chosen |
Response sample:
{
"success": true,
"message": "Các đơn hàng đã được add vào hệ thống GHTK thành công. Thông tin đơn hàng thành công được trả về trong trường success_orders.",
"order": {
"partner_id": "TEST1",
"label": "S3096572.BO.SG01-H103.300101713",
"area": 1,
"fee": 170000,
"insurance_fee": 0,
"estimated_pick_time": "Sáng 2022-04-15",
"estimated_deliver_time": "Sáng 2022-04-17",
"products": [],
"status_id": 1,
"tracking_id": 300101713,
"sorting_code": "BO.SG01-H103",
"id": "TEST1",
"order_id": "S3096572.BO.SG01-H103.300101713",
"package_status_id": 1,
"status": 1,
"cost_id": 8740
}
}
Failed order:
Failed order with error details:
{
"message": "Quý khách đã dùng mã TEST1 cho 1 đơn hàng khác",
"error": {
"code": "ORDER_ID_EXIST",
"partner_id": "TEST1",
"ghtk_label": "S3096572.BO.SG01-H103.300101713",
"created": "2022-04-05 15:04:34",
"status": 1
},
"success": false
}
Warning
Once an order is successfully submitted to GHTK system, it could not be reversed. In case the “order.id” already exists, shop will receive error response including - partner_id ; - ghtk_label ; - created: created time of order - status: the current status of order
3.8 OPM order
3.8.1 Submit OPM order
Path
Params
param | required | type | desc |
---|---|---|---|
order |
yes | Object | Shipping info |
details |
yes | Array | Collection details |
Order object
param | required | type | desc |
---|---|---|---|
order.id | yes | String | Order ID from partner’s system |
order.opm | yes | Number | 1 |
Pickup info | |||
order.pick_name | yes | String | Contact name for pickup |
order.pick_money | yes | Integer | COD amount. If 0, no COD will be collected. In VND |
order.pick_address_id | no | String | Shop’s pickup location ID in the customer’s order management page. If not empty, it will be prioritized. |
order.pick_address | yes | String | Short address for pickup. Example: house number 5, group 3, alley 11, lane 45 |
order.pick_province | yes | String | Province/city name for pickup |
order.pick_district | yes | String | District name for pickup |
order.pick_ward | no | String | Ward/commune name for pickup |
order.pick_street | no | String | Street name for pickup |
order.pick_tel | yes | String | Contact phone number for pickup |
order.pick_email | no | String | Contact email for pickup |
Deliver info | |||
order.name | yes | String | Recipient name |
order.address | yes | String | Detailed recipient address. Example: CT1 apartment building, alley 58, Tran Binh street |
order.province | yes | String | Recipient’s province/city name |
order.district | yes | String | Recipient’s district name |
order.ward | yes | String | Recipient’s ward/commune name (Required if no street/road is available) |
order.street | yes | String | Recipient’s street/road name (Required if no ward/commune is available) |
order.hamlet | yes | String | Recipient’s village/hamlet/group/neighborhood/… name. If not available, please enter “Other” |
order.tel | yes | String | Recipient’s phone number |
order.note | no | String | Order note. Example: Maximum chargeable weight: 1.00 kg. Maximum note length allowed since 24/2/2020 is 120 characters |
order.email | yes | String | Recipient’s email |
Additional info | |||
order.is_freeship | no | Integer | Freeship for recipient. If 1, COD will only collect pick_money from the recipient; if 0, COD will collect pick_money + order’s shipping fee from the recipient. Default value is 0. |
order.pick_work_shift | no | Integer | If set to 3, the order will be picked up in the evening. 2: afternoon. 1: morning. GHTK sets the default shift by itself. |
order.deliver_work_shift | no | Integer | If set to 3, the order will be delivered in the evening. 2: afternoon. 1: morning. GHTK sets the default shift by itself. |
order.pick_date | no | String YYYY/MM/DD | Pickup date |
order.deliver_date | no | String YYYY/MM/DD | Delivery date |
order.value | yes | Interger (VNĐ) | Insured value, which is the basis for calculating insurance fees and compensation in case of an incident. |
order.opm | no | Interger (VNĐ) | 1. Only collect money, 0. default |
order.pick_option | no | String | Accepts either cod or post value, default is cod, indicating COD pickup or Shop will send to post office |
order.transport | no | String | Shipping method road (land) , fly (air). If the shipping method is invalid, GHTK will automatically switch to the default PTVC |
Detail object
param | required | type | desc |
---|---|---|---|
type |
yes | String | Services type, set “opm” |
note |
optional | String | Nội dung khoản thu |
date |
yes | String | Ngày của doanh thu |
value |
yes | Number | Doanh thu |
Response successfully
{
"success": true,
"message": "Các đơn hàng đã được add vào hệ thống GHTK thành công. Thông tin đơn hàng thành công được trả về trong trường success_orders.",
"order": {
"partner_id": "1234585868",
"label": "S15520189.MB7-17-A11.2008669623",
"area": 1,
"fee": 31000,
"insurance_fee": 0,
"estimated_pick_time": "Sáng 2023-11-14",
"estimated_deliver_time": "Chiều 2023-11-14",
"products": [],
"status_id": 3,
"tracking_id": 2008669623,
"sorting_code": "MB7-17-A11",
"date_to_delay_pick": "2023-11-14 00:00:00",
"pick_work_shift": 1,
"date_to_delay_deliver": "2023-11-14 00:00:00",
"deliver_work_shift": 2,
"is_xfast": 0
},
"warning_message": ""
}
Response failed
{
"success": false,
"message": "{ERROR_MESSAGE}",
"error_code": "{ERROR_CODE}",
"log_id": "{LOG_ID}"
}
REQUEST
curl --location '{{URL}}/services/shipment/order' \
--header 'Token: {API_TOKEN}' \
--header 'X-Client-Source: {PARTNER_CODE}' \
--header 'Content-Type: application/json' \
--data '{
"details": [
{
"date": "2023-04-24",
"value": 12117000,
"note": "doanh thu",
"type": "opm"
}
],
"order": {
"id": "1234585868",
"pick_name": "HNPMC876",
"pick_tel": "02871077997/1976",
"pick_address": "22 Trần Quang Khải - phường Hoàng Văn Thụ -quận Hồng Bàng - TP.Hải Phòng",
"pick_province": "Hải Phòng",
"pick_district": "Quận Hồng Bàng",
"pick_ward": "Phường Hoàng Văn Thụ",
"pick_street": null,
"pick_hamlet": "Trần Quang Khải",
"name": "HNPMC876",
"address": "22 Trần Quang Khải - phường Hoàng Văn Thụ -quận Hồng Bàng - TP.Hải Phòng",
"province": "Hải Phòng",
"street": null,
"ward": "Phường Hoàng Văn Thụ",
"district": "Quận Hồng Bàng",
"hamlet": "Trần Quang Khải",
"tel": "02871077997/1976",
"is_freeship": "0",
"note": null,
"pick_date": "2023-11-13",
"pick_work_shift": "1",
"deliver_date": "2023-11-13",
"deliver_work_shift": "2",
"pick_option": "cod",
"value": "2000000",
"transport": "road",
"pick_money": "12117000",
"opm": "1"
}
}'
3.8.2 API calculate shipment fee
Path
Parameters:
Parameter | Datatype | Mandatory (Y)/(N) | Description |
---|---|---|---|
pick_address | String | N | Địa chỉ ngắn gọn để lấy nhận hàng hóa. Ví dụ: nhà số 5, tổ 3, ngách 11, ngõ 45 |
pick_province | String | Y | Tên tỉnh/thành phố nơi lấy hàng hóa |
pick_district | String | Y | Tên quận/huyện nơi lấy hàng hóa |
pick_ward | String | N | Tên phường/xã của người lấy hàng hóa |
pick_street | String | N | Tên đường/phố nơi lấy hàng hóa |
address | String | N | Địa chỉ chi tiết của người nhận hàng, ví dụ: Chung cư CT1, ngõ 58, đường Trần Bình |
province | String | Y | Tên tỉnh/thành phố của người nhận hàng hóa |
district | String | Y | Tên quận/huyện của người nhận hàng hóa |
ward | String | N | Tên phường/xã của người nhận hàng hóa |
street | String | N | Tên đường/phố của người nhận hàng hóa |
weight | Integer | Y | Khối lượng đơn hàng |
value | Integer | N | Giá trị hàng hóa |
Special Field
Parameter | Datatype | Mandatory (Y)/(N) | Description |
---|---|---|---|
opm | Number | Yes | Get FEE đơn thu hộ tiền |
pick_money | Number | Yes | Số tiền thu hộ |
Response:
{
"success": true,
"message": "",
"fee": {
"name": "area1",
"fee": 22000,
"insurance_fee": 0,
"include_vat": 0,
"cost_id": 0,
"delivery_type": "",
"a": "1",
"dt": "local",
"extFees": [],
"ship_fee_only": 22000,
"promotion_key": "",
"delivery": true
}
}
Parameter | Datatype | Description |
---|---|---|
fee.name | String | Tên khu vực |
fee.fee | Integer | Tổng tiền ship |
fee.insurance_fee | Integer | Phí bảo hiểm nếu có |
REQUEST
curl --location '{OPEN_API}/services/shipment/fee?pick_address=s%E1%BB%91%2023%20&pick_province=TP%20H%E1%BB%93%20Ch%C3%AD%20Minh&pick_district=Qu%E1%BA%ADn%207&pick_ward=Ph%C6%B0%E1%BB%9Dng%20T%C3%A2n%20Phong&pick_street=&address=300%2F49%20Nguy%E1%BB%85n%20Th%C3%A1i%20S%C6%A1n-%C4%90%C6%B0%E1%BB%9Dng%20Nguy%E1%BB%85n%20Th%C3%A1i%20S%C6%A1n&province=TP%20H%E1%BB%93%20Ch%C3%AD%20Minh&district=Qu%E1%BA%ADn%20G%C3%B2%20V%E1%BA%A5p&ward=Ph%C6%B0%E1%BB%9Dng%204&street=&value=880000&weight=500&opm=1&pick_money=880000' \
--header 'Token: {API_TOKEN}}'
--header 'X-Client-Source: {PARTNER_CODE}'
3.9 Api get list gam solutions
PATH
Header
- Token:
{API_TOKEN}
- X-Client-Source:
{PARTNER_CODE}
- Content-Type:
application/json
Sample Request
curl --location '{OPEN_API}/open/api/v1/shop/solution/list' \
--header 'Token: {API_TOKEN}' \
--header 'X-Client-Source: {PARTNER_CODE}' \
--header 'Content-Type: application/json'
Response Success 1
{
"success": true,
"data": [
{
"solution_id": 1340164168838205440,
"description": "Giúp shop đảm bảo ngoại quan sản phẩm được giữ nguyên vẹn trong suốt quá trình vận chuyển.",
"group_name": "Gói giải pháp an toàn hàng hoá toàn diện"
},
{
"solution_id": 1341971770371706880,
"description": "Giúp shop đảm bảo ....",
"group_name": "Gói giải pháp an toàn hàng hoá toàn diện"
},
{
"solution_id": 1341971857508372480,
"description": "Giúp shop đảm bảo .... và....",
"group_name": "Gói giải pháp an toàn hàng hoá toàn diện"
}
],
"message": "Thành công!",
"code": 200,
"rid": "dd663be1c8d0"
}
Response Success 2
Parameter | Datatype | Description |
---|---|---|
solution_id | Long | ID giải pháp |
description | String | Mô tả giải pháp |
group_name | String | Tên nhóm giải pháp |