3. Order Creation API
Partners send a list of orders to Giaohangtietkiem’s system via APIs. Once the orders are successfully saved into GHTK’s system, the system will return a corresponding list of orders containing the relevant details of each one.
Hyperlink
POST /services/shipment/order
Headers
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
- HTTP
- CURL
- PHP
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
}, {
"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", // Đơn hàng xfast yêu cầu bắt buộc pick_option là COD
"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","pick_session":2,"gam_solutions":[{"solution_id":12365478},{"solution_id":12365479},{"solution_id":12365470}]}}' "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","pick_session":2,"tags":[1],"gam_solutions":[{"solution_id":12365478},{"solution_id":12365479},{"solution_id":12365470}]}}';
$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;
?>
Parameters
| Parameters | Required | Description |
|---|---|---|
| order | yes | Object - Order information to be sent to GHTK |
| products | yes | Array - List of products. See the next table for detailed description of product fields |
| order.id | yes | String - Partner's order code in their system |
| Pickup Information | ||
| order.pick_name | yes | String - Name of the contact person for pickup |
| order.pick_money | yes | Integer - CoD amount (in VND). If 0, no cash collection is required |
| order.pick_address_id | no | String - Pickup location ID from the customer’s order management page. This field will take priority if not empty |
| order.pick_address | yes | String - Short pickup address (e.g., House No. 5, Block 3, Alley 11, Lane 45) |
| order.pick_province | yes | String - Province/City of the pickup location |
| order.pick_district | yes | String - District of the pickup location |
| order.pick_ward | no | String - Ward/Commune of the pickup location |
| order.pick_street | no | String - Street name of the pickup location |
| order.pick_tel | yes | String - Pickup contact phone number |
| order.pick_ext_tel | no | String - Extension number of the main pickup contact phone number |
| order.pick_email | no | String - Pickup contact email address |
| Delivery Information | ||
| order.name | yes | String - Recipient's full name |
| order.address | yes | String - Detailed delivery address (e.g., CT1 Building, Alley 58, Tran Binh Street) |
| order.province | yes | String - Province/City of the recipient |
| order.district | yes | String - District of the recipient |
| order.ward | yes | String - Ward/Commune of the recipient |
| order.street | yes if order.hamlet=None | String - Street name of the recipient (Required if Hamlet/Village/Cluster is not provided) |
| order.hamlet | yes if order.street=None | String - Hamlet/Village/Cluster/... of the recipient. If not applicable, enter "Other" (Required if Street is not provided) |
| order.tel | yes | String - Recipient’s phone number |
| order.ext_tel | no | String - Extension number of the main recipient's phone number |
| order.note | no | String - Order note (e.g., Maximum chargeable weight: 1.00 kg). From Feb 24, 2020, max 120 characters allowed |
| order.email | no | String - Recipient’s email address |
| Return Address | ||
| order.use_return_address | no | Integer - Default is 0. This field accepts either a value of 0 or 1. A value of 0 means the return address is the same as the pickup address, so the return address fields can be omitted. A value of 1 means a different return address is used, and all corresponding return address fields must be provided |
| order.return_name | yes | String - Return recipient name |
| order.return_address | yes | String - Detailed return address (e.g., House A, Alley 100) |
| order.return_province | yes | String - Province/City of the return address |
| order.return_district | yes | String - District of the return address |
| order.return_ward | no | String - Ward/Commune of the return address |
| order.return_street | no | String - Street of the return address |
| order.return_tel | yes | String - Return recipient phone number |
| order.return_email | no | String - Return recipient email address |
| Additional Information | ||
| order.is_freeship | no | Integer - Free shipping for receiver. 1 means receiver pays only CoD amount that equals (pick_money), 0 means receiver pays CoD + shipping fee. Default is 0 |
| order.weight_option | no | String - Weight unit of items in packages, either gram or kilogram. Default is kilogram |
| order.total_weight | no | Double - Total weight of the package. If omitted, calculated from products.weight |
| order.pick_work_shift | no | Integer - To indicate the order will be picked up at which time. “2” is in the afternoon and “1” is in the morning. Default value is set automatically by GHTK. |
| order.deliver_work_shift | no | Integer - To indicate the order will be delivered at which time. “2” is in the afternoon and “1” is in the morning. Default value is set automatically by GHTK. |
| order.label_id | no | String - Pre-assigned order label from partner. Not available by default - service-specific configuration |
| order.pick_date | no | String YYYY/MM/DD - Scheduled pickup date. Not available by default - service-specific configuration |
| order.deliver_date | no | String YYYY/MM/DD - Scheduled delivery date. Not available by default - service-specific configuration |
| order.value | yes | Integer (VNĐ) - Declared value, which is a base for insurance and compensation fee calculation when an incident occurs. |
| order.opm | no | Integer (VNĐ) - 1 for CoD only (no delivery), 0 for default full delivery |
| order.pick_option | no | String - Either cod or post. Default is cod. Indicates whether the item is picked up (cod) or dropped off by shop at post office (post) |
| order.actual_transfer_method | no | String - This field saves the transfer method of an order, default is by air (fly). If on ground (road), GHTK will notify about the change |
| order.transport | no | String - Shipping method: road (ground), fly (air). If invalid, GHTK will fall back to the default method |
| order.tags | no | Array - Order Tagging: An array of tags to label the order. The list of available tags is described in the following table |
| order.sub_tags | no | Array - Array - Sub Tags: An array of detailed tag information. This field is mandatory when tagging the order as a "Live Plants" |
| order.total_box | no | Integer - Total number of packages in the order. |
| order.gam_solutions | no | Array - List of Gam solution IDs applied to the order. |
products parameters
| Parameter | Required | Description |
|---|---|---|
| name | yes | String - Product name |
| price | no | Integer - Product price |
| weight | yes | Double - Product weight in kilograms |
| quantity | no | Integer - Product quantity |
| product_code | no | String - Product code taken from the API to get product information list |
| height | no | Double - Height of the product (unit: cm) |
| width | no | Double - Width of the product (unit: cm) |
| length | no | Double - Length of the product (unit: cm) |
tags description
| Tag | Description | Detailed |
|---|---|---|
| 2 | High-Value / Special | Goods valued over 3,000,000 VND (for B2C shops) or 1,000,000 VND (for C2C shops). High-value goods will incur an additional insurance fee, which covers risks during transportation or storage. An additional insurance fee of 0.5 % of the product price is applied. In cases that the product is missing, GHTK will reimburse 100 % of the declared value (up to 20,000,000 VND) if valid proof of value/origin is provided (e.g., purchase invoices, valid receipts that match the product information on GHTK’s system, etc.). In cases where the seller cannot provide proof of origin and value of the goods, compensation will be limited to a maximum of 4 times the shipping fee. |
| 10 | Item Preview | The recipient is able to view the product before accepting the delivery. |
| 13 | Shop Call-Back | A GHTK agent will contact the shop if problems such as wrong recipient information, unreachable customer, or customer refuses the parcel arise. |
| 17 | Partial Delivery | Customer pays only for the items kept; remaining items are returned to the shop. Return fee: 5,000 VND for in‑province shipping, 50 % of initial shipping fee for inter‑province shipping. |
| 18 | Partial Return | Support for delivering one product to the customer and returning the remaining items to the shop. Shipping fee is negotiated between shop and customer (default equals shipping fee). Returned portion is treated as a return order. Return fee: 5,000 VND for in‑province shipping, 50 % of initial shipping fee for inter‑province shipping. |
| 19 | Failed Delivery – Fee Collected | Support for cases where the customer does not receive the product but a partial fee is collected for the shop. Default fee equals shipping fee, but the shop can adjust the amount. Returned portion is treated as a return order. Return fee: 5,000 VND for in‑province shipping, 50 % of initial shipping fee for inter‑province shipping. Note: Partners must include the not_delivered_fee field with a value greater than 0 and less than or equal to 20,000,000 VND. |
| 62 | Partial Delivery with Document Retrieval | Support for delivering products to the customer and returning accompanying documents (invoices, papers) with the remaining items to the shop. |
sub_tags description
| Sub tag detail | Description |
|---|---|
| 1 | Seeds |
| 2 | Seedlings |
| 3 | Bagged plants |
| 4 | Plants in fragile pots |
| 5 | Other types of plants |
Response
When an order is successfully created:
{
"success": true,
"message": "",
"order": {
"partner_id": "123123a",
"label": "S1.A1.2001297581",
"area": "1",
"fee": "30400",
"insurance_fee": "15000",
"tracking_id": 2001297581,
"estimated_pick_time": "Sáng 2017-07-01",
"estimated_deliver_time": "Chiều 2017-07-01",
"products": [],
"status_id": 2
}
}
When an error occurs:
{
"success": false,
"message": "Chưa có thông tin order"
}
warning
GHTK's process does not allow an order code to be pushed again if it has already been successfully created on the GHTK’s system. In the case where the order.id already exists on the GHTK system occurs, the API will return an error along with the following information:
- partner_id: the partner's order code
- ghtk_label: GHTK's order label
- created: the time when the order was created
- status: the current status of the 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", // id trong request đẩy sang của bạn
"ghtk_label": "S1.A1.1737345", // nhãn đơn GHTK, tương ứng với id của bạn
"created": "2016-11-02T12:18:39+07:00",
"status": 5 // trạng thái đơn hàng hiện tại trên hệ thống GHTK, tra bảng mã trạng thái đơn trong phần webhook
}
}
Note
info
Note: The unit of weight GHTK uses for each product is kilograms (KG)
warning
Note: The initial shipping fee will be calculated based on the total weight of all products in the order.
warning
Note:
- If the order is set is_freeship =
1,the COD will only collect from the recipient an amount equal topick_money - If the value is set to
0, the COD will collect from the recipient an amount equal topick_money+shipping fee of the order. The default value is0. - Some fields in the response may be hidden.