cancelOrder mutation

The cancelOrder mutation allows a customer to cancel an order, passing its encoded order id and a cancellation reason.

A customer can cancel an order only if the following conditions are true:

If the customer has been charged for the order, the order is placed in the CLOSED state, and the customer will be issued a refund. Otherwise, the status of the order is set to CANCELED.

The mutation returns an error if the order cannot be cancelled.

Syntax

mutation: {cancelOrder(input: CanceOrderInput!) {CancelOrderOutput}}

Reference

The cancelOrder reference provides detailed information about the types and fields defined in this mutation.

Example usage

The following example cancels order ID Nzg= and includes the reason for its cancellation.

Request:

mutation {
    cancelOrder(
        input: {
            order_id: "Nzg=",
            reason: "The order was placed by mistake"
        }
    ){
        errorV2 {
            code
            message
        }
        order {
            status
        }
    }
}

Response:

{
  "data": {
    "cancelOrder": {
      "errorV2": null,
      "order": {
        "status": "Canceled"
      }
    }
  }
}