XM

Cancel Order

Path:

PATCH https://{baseurl}/api-order/orders/cancel

This API enables you (storefront context) to cancel an individual order. An order can be cancelled only if it is placed with in 24 hours and is not yet shipped. That is, an order can be cancelled only in the following statuses - Order_Payment_Authorized or Order_Created. This API is secured by x-api-key.

Headers

Content-Type : application/json

x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

x-api-key : d41d8cd98f00b204e9800998ecf8427e

Parameters

Type: body

Name: The order ID and a cancellation code to cancel the order.

Required: true

Sample Request

Path:

PATCH https://{baseurl}/api-order/orders/cancel
{
"orderId": "8568-9704-74294",
"cancellationCode": "2001"
}

Response

Response Code: 200

Message: OK

Description: You will see this message when the requested order is successfully cancelled.

{
"orderId": "8568-9704-74294",
"status": "Successfully cancelled order"
}

Error Code: 400

Message: Not Found

Description: You will see this error when the Order ID is not found.

{
"code": "ORDER_NOT_FOUND",
"message": "Order Id Not Found"
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the current status of the order doesn't support cancellation.

{
"code": "ORDER_CANCELLATION_INVALID",
"message": "Order status must be ORDER_PAYMENT_AUTHORIZED or ORDER_CREATED"
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the order is not within the cancellation window.

{
"code": "ORDER_CANCELLATION_INVALID",
"message": "Order was placed more than 24 hours ago"
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the specified order ID is lesser or greater than 15 characters.

{
"code": "REQUEST_VALIDATION",
"message": "Invalid data in body: /orderId should NOT be shorter than 15 characters"
}

‚Äč

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