> ## Documentation Index
> Fetch the complete documentation index at: https://docs-test.rye.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# cancelOrder

> Cancel an existing order.

> [!NOTE]
>
> Due to Rye requiring Amazon Business accounts be connected to Rye via Amazon's app marketplace, this mutation has been deprecated and will be removed in the future.
> Cancellations can be handled via your Amazon Business account. See our [Connecting your Amazon Business account](https://docs-test.rye.com/docs/amazon-business/overview) on how to connect your Amazon Business account to Rye

***

### Arguments

**input** `[CancelOrderInput!](/api-reference/cancelorderinput)` *required*

The `input` object contains the orderId.

***

### Returns

**CancelOrderResponse.**\* `[CancelOrderResponse!](/api-reference/cancelorderresponse)`

Any requested field from the [`CancelOrderResponse`](https://docs-test.rye.com/docs/api-reference/cancelorderresponse) object.

***

### Example - request

```json Query arguments theme={null}
{
  "input": {
    "orderId": "orderId-123-456-789"
  }
}
```

```GraphQL GraphQL theme={null}
mutation ($input: CancelOrderInput!) {
  cancelOrder(input:$input){
    result {
      ... on CancelAmazonOrderResult { items { amazonOrderId, status, failReason } }
      ... on CancelShopifyOrderResult { status }
    }
    error {
      message
      code
    }
  }
}
```

Calling the endpoint initiates a cancellation attempt. Response below is an example response for an amazon order

### Example - response

```json Response theme={null}
{
  "data": {
    "cancelOrder": {
      "result": {
        "items": [
          {
            "amazonOrderId": "111-9474033-3741041",
            "status": "CANCEL_PROCESSING",
            "failReason": null
          }
        ]
      },
      "error": null
    }
  }
}
```

***

### Errors

If a cancellation request has a status `CANCEL_FAILED` the payload would look like below:

```json Response theme={null}
{
  "data": {
    "cancelOrder": {
      "result": {
        "items": [
          {
            "amazonOrderId": "111-9474033-3741041",
            "status": "CANCEL_FAILED",
            "failReason": "Error attempting to request cancellation"
          }
        ]
      },
      "error": null
    }
  }
}
```

The error field will display errors not related to actual status of a cancellation request.

```json Response theme={null}
{
  "data": {
    "cancelOrder": {
      "result": [],
      "error": {
        "message": "There was a problem cancelling this order. Contact Rye to cancel the order manually.",
        "code": "REQUEST_MANUAL_CANCELLATION"
      },
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.