Create Order

API Create Order

 

Automatic send order information such as weight, address, phone number, and many more to GHN system. We will process these information and start the shipment

Caution: The API Create Order need to infusion token and shopid in header

post/get
https://online-gateway.ghn.vn/shiip/public-api/v2/shipping-order/create
https://dev-online-gateway.ghn.vn/shiip/public-api/v2/shipping-order/create
curl --location --request POST 'https://dev-online-gateway.ghn.vn/shiip/public-api/v2/shipping-order/create' \
                    --header 'Content-Type: application/json' \
                    --header 'ShopId: 885' \
                    --header 'Token: 285518-c4bb-11ea-be3a-f636b1deefb9' \
                    --data-raw '{
                        "payment_type_id": 2,
                        "note": "Tintest 123",
                        "from_name":"Tin",
                        "from_phone":"0909999999",
                        "from_address":"123 Đường 3/2",
                        "from_ward_name":"Phường 5",
                        "from_district_name":"Quận 11",
                        "from_province_name":"TP Hồ Chí Minh",
                        "required_note": "KHONGCHOXEMHANG",
                        "return_name": "Tin",
                        "return_phone": "0909999999",
                        "return_address": "123 Đường 3/2",
                        "return_ward_name": "Phường 5",
                        "return_district_name": "Quận 11",
                        "return_province_name":"TP Hồ Chí Minh",
                        "client_order_code": "",
                        "to_name": "Độ Mixi",
                        "to_phone": "0909998877",
                        "to_address": "Streaming house",
                        "to_ward_name":"Phường 14",
                        "to_district_name":"Quận 10",
                        "to_province_name":"TP Hồ Chí Minh",
                        "cod_amount": 200000,
                        "content": "Theo New York Times",
                        "weight": 200,
                        "length": 1,
                        "width": 19,
                        "height": 10,
                        "pick_station_id": 1444,
                        "deliver_station_id": null,
                        "insurance_value": 10000000,
                        "service_id": 0,
                        "service_type_id":2,
                        "coupon":null,
                        "pick_shift":null,
                        "pickup_time": 1665272576,
                        "items": [
                             {
                                 "name":"Áo Polo",
                                 "code":"Polo123",
                                 "quantity": 1,
                                 "price": 200000,
                                 "length": 12,
                                 "width": 12,
                                 "height": 12,
                                 "category": 
                                 {
                                     "level1":"Áo"
                                 }
                             }
                             
                         ]
                    }'
                    

Parameter

Field Require Type Data Size Description
token
X
String  

Must be sent with all client requests. This Token helps server to validate request source. Provided by GHN.

shop_id
X
Int  

Manage information for shop/seller

from_name   String 1024

Name of the sender.

from_phone   String  

Phone of the sender.

from_address   String 1024

Address of sender

from_ward_name   String  

Ward of the sender. Use API Get Ward

from_district_name   String  

District of the sender. Use API Get District

from_province_name   String  

Province of the sender. Use API Get Province

to_name
X
String 1024

Client name. (Customer / Buyer)

to_phone
X
String  

Client phone number. (Customer / Buyer)

to_address
X
String 1024

Client address. (Customer / Buyer)

to_ward_name
X
String  

Ward pick up parcels. Use API Get Ward

to_district_name
X
String  

District drop off parcels. Use API Get District

to_province_name
X
String  

Province drop off parcels. Use API Get Province

return_phone   String  

Contact phone number to return parcels.

return_address   String 1024

Address return parcels.

return_ward_name   String  

Ward return parcels. Use API Get Ward.

return_district_name   String  

District return parcels. Use API Get District.

return_province_name   String  

Province return parcels. Use API Get Province.

client_order_code   String 50

External order code managed by logged client [Unique field].

Default value: null

 Note: Client_order_code will get back the order that already has this Client_order_code
cod_amount   Int  

Amount cash to collect.

Maximum 10.000.000

Default value: 0

content   String 2000

Content for order

weight
X
Int  

Weight (gram)

Maximum : 30000gram
length
X
Int  

Length (cm)

Maximum : 150cm
width
X
Int  

width (cm)

Maximum : 150cm
height
X
Int  

height (cm)

Maximum : 150cm
pick_station_id   Int  

The shipper not pickup parcels at shop’s address

Value > 0

insurance_value   Int  

Use to declare parcel value. GHN will base on this value for compensation if any unexpected things happen (lost, broken...).

Maximum 5.000.000

Default value: 0

coupon   String  

Coupon Code for discount.

service_type_id
X
Int  

Call API SERVICE to show service.

Default value:  2:E-commerce delivery

If not input service_id.

service_id
X
Int  

Call API SERVICE  to show service.

If not input service_type_id

payment_type_id
X
Int  

Choose who pay shipping fee.

1: Shop/Seller.

2: Buyer/Consignee.

note   String 5000

Client note for shipper.

Ex: Please call before delivery

required_note
X
String 500

Note shipping order.Allowed values: CHOTHUHANG, CHOXEMHANGKHONGTHU, KHONGCHOXEMHANG 

CHOTHUHANG mean Buyer can request to see and trial goods
CHOXEMHANGKHONGTHU mean Buyer can see goods but not allow to trial goods
KHONGCHOXEMHANG mean Buyer not allow to see goods

pick_shift      

Picking shift, take API Pick Shift

pickup_time    Int  

Use for pickup time. Can input: null

Format: Unix Timestamp.

Items
X
   

Content for order

name
X
String  

Name of product

code   String  

Code of product

quantity
X
Int  

Quantity of product

price   Int  

Price of product

length   Int  

Length of product

weight 
X
Int  

Weight  of product

width   Int  

Width of product

height   Int  

Height of product

category      

Category of product have 3 level,level1, level2, level3

level1   String  

Product category classification

Note: If you do not transmit Return information, the system will get information of From. If still not transmitted From, the system will get address information from ShopID by default as the address for From and Return.

{
                        "code": 200,
                        "message": "Success",
                        "data": 
                        {
                        "district_encode":"" 
                        "expected_delivery_time":"2020-06-03T16:00:00Z" 
                        "fee":
                        { 
                        coupon:0    
                        "insurance":11000 
                        "main_service":22000 
                        "r2s":0 
                        "return":0 
                        "station_do":0 
                        "station_pu":0 
                        },
                        "order_code":"FFFNL9HH"
                        "sort_code":"19-60-06"
                        "total_fee":"33000"
                        "trans_type":"truck"
                        "ward_encode":""
                        }
                    }

Structure Response

Field Description
expected_delivery_time

Expected delivery time.

fee

Fee.

coupon

Coupon Code for discount.

insurance

Insuarance value

main_service

Service fee

r2s

Fee of delivery parcel again

return

Fee of Return to ship

station_do

Pickup fee at Station

station_pu

Delivery fee at Station

order_code

Code order

sort_code

Sort code

total_fee

Total fee

trans_type

Transportation type

{
                        "code": 400,
                        "message": "Sai thông tin Required Note",
                        "data": null
                        "code_message":"USER_ERR_COMMON"
                    }