Skip to main content

7. Order cancellation API

This API is used to cancel an order that has been pushed to the GHTK system

Endpoint

When using GHTK’s tracking code:

POST /services/shipment/cancel/{TRACKING_ORDER}
warning

If you are using the partner’s order code (the order.id value provided during order creation), please use the format below:

  • TRACKING_ORDER = partner_id:PARTNER_CODE
POST /services/shipment/cancel/partner_id:{PARTNER_CODE}

Headers

  • Token: {API_TOKEN}
  • X-Client-Source: {PARTNER_CODE}
  • Content-Type: application/json

Parameters

ParameterRequiredDescription
TRACKING_ORDERYesThe GHTK order code or the partner’s order code is passed through the order.id field in the order creation API

Code

GET /services/shipment/cancel/{TRACKING_ORDER} HTTP/1.1
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}

Response

Successful cancellation

{
"success": true,
"message": "",
"log_id": "..."
}

Canceled order

{
"success": false,
"message": "Đơn hàng đã đã ở trạng thái hủy",
"log_id": "..."
}

Cases where order cancellation is not allowed

danger

Orders cannot be canceled once they have been successfully picked up. The API can only cancel orders in the following statuses:

  • “Not yet received” status (1)
  • “Received” status (2)
  • “Picking up in progress” status (12)
{
"success": false,
"message": "Đơn đã lấy hàng, không thể hủy đơn.",
"log_id": "..."
}