XM
Members
Cancel Order by Order ID
This documentation is now outdated, please find the latest docs for this endpoint here
Path:
1
POST https://{baseurl}/api-order/orders/user/cancel?orderId={orderId}
Copied!
This API enables shoppers (customer context) to cancel their orders directly from your e-commerce site. And, this is secured by Authorization Token. An order can be cancelled only if it is placed with in 24 hours and is not shipped. That is, order cancellation is supported only for the these order statuses - Order_Payment_Authorized or Order_Created.

Headers

Content-Type : application/json
Authorization: JWT
x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

Parameters

Type : query
Name : The 15 character order ID, which is generated after successful checkout.
Required: true
Type: requestBody
Name: The cancellation code and optionally the cancellation message.
Required: true

Sample Request

Path:
1
POST https://{baseurl}/api-order/orders/user/cancel?orderId=8917-2674-99643
Copied!
1
{
2
"cancellationCode": "3000",
3
"cancellationMessage": "Customer found better price elsewhere"
4
}
Copied!

Response

Response Code: 200
Message: OK
Description: You will see this message when the requested order is successfully cancelled.
1
{
2
"orderId": "8917-2674-99643",
3
"status": "Successfully cancelled order"
4
}
Copied!
Error Code: 404
Message: Not Found
Description: You will see this error when the Order ID is not found.
1
{
2
"code": "ORDER_NOT_FOUND",
3
"message": "Order Id Not Found"
4
}
Copied!
Error Code: 404
Message: Not Found
Description: You will see this error when the cancellation code is incorrect.
1
{
2
"code": "CUSTOMER_ORDER_CANCELLATION_CODE_NOT_FOUND",
3
"message": "Customer Cancellation Code Not Found"
4
}
Copied!
Error Code: 400
Message: Bad Request
Description: You will see this error when the current status of the order doesn't support cancellation.
1
{
2
"code": "ORDER_CANCELLATION_INVALID",
3
"message": "Order status must be ORDER_PAYMENT_AUTHORIZED or ORDER_CREATED"
4
}
Copied!
Error Code: 400
Message: Bad Request
Description: You will see this error when the order ID is not provided.
1
{
2
"code": "REQUEST_VALIDATION",
3
"message": "Invalid data in query: should have required property 'orderId'"
4
}
Copied!
Error Code: 400
Message: Bad Request
Description: You will see this error when the order is not within the cancellation window.
1
{
2
"code": "ORDER_CANCELLATION_INVALID",
3
"message": "Order was placed more than 24 hours ago"
4
}
Copied!
Error Code: 400
Message: Bad Request
Description: You will see this error when the specified order ID is lesser or greater than 15 characters.
1
{
2
"code": "REQUEST_VALIDATION",
3
"message": "Invalid data in body: /orderId should NOT be shorter than 15 characters"
4
}
Copied!
Error Code: 400
Message: Bad Request
Description: You will see this error when the user is not authorized to cancel the order.
1
{
2
"orderId": "7061-7821-86562",
3
"status": "User not allowed to cancel"
4
}
Copied!
Error Code: 500
Message: Internal Server Error
Description: You will see this error when the account number is incorrect in the x-site-context (for a multi-tenent client).

Change Log

  • June - 2021
  • July - 2020 First updated
Last modified 1mo ago
Copy link
Contents
Change Log