---
id: cancel
title: "Cancel order"
sidebar_label: Cancel order
hide_title: true
description: "Management API - Orders - Cancel order"
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import Ingress from "../../../src/components/ingress/ingress.react";

<Ingress title="Cancel order">
  When order items should no longer be delivered to the end customer, use this
  endpoint to cancel every remaining item that has not yet been captured.
</Ingress>

:::danger Canceling cannot be undone
Once you cancel, the remaining items are released for good. There is no way to bring them back, so
check the order before you call this.

Canceled items should not be delivered to the customer. If the order used a direct payment method,
the customer is refunded the amount of the canceled rows.
:::

:::note Works on `NotActivated`, `PartActivated`, and `Expired` orders
Captured items are unaffected. See [Order lifecycle](/docs/manage/concepts/order-lifecycle) for what
each status allows.
:::

<Tabs defaultValue="req" values={[
{ label: 'Request', value: 'req', },
{ label: 'Response', value: 'res', }
]}>

<TabItem value="req">

```http
POST /manage/orders/{{orderId}}/cancel HTTP/1.1
Host: api.uat.walleydev.com // Test environment. Production uses a different hostname.
Authorization: Bearer {{accessToken}}
Content-Type: application/json

/* Optional body */
{
  "actionReference": "test-cancelref-123"
}
```

</TabItem>

<TabItem value="res">

```http
HTTP/1.1 202 Accepted
Location: /manage/orders/1b1f5ef6-92n1-4b46-b1dc-ae2e00c4c315

/* No body */
```

</TabItem>

</Tabs>

| Http status code | Description                                                         |
| ---------------- | ------------------------------------------------------------------- |
| 202              | Cancel accepted                                                     |
| 401              | Token missing, expired, or invalid                                  |
| 403              | No permission for this store, or the order has not finished syncing |
| 404              | Order not found, or the order has not finished syncing              |
| 409              | A request with the same idempotency key is already in progress      |

See [Errors](/docs/manage/errors) for what to do about each of these.

## Data Model

### Request

#### Request headers

| Header            | Required | Explanation                                                                                                             |
| ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| **Authorization** | Yes      | See [Authentication](/docs/manage/getting-started/authentication) for how to generate the Bearer token value |

#### Request body

| Property            | Required | Explanation                               | Type   | Notes                                                                                                |
| ------------------- | -------- | ----------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------- |
| **actionReference** | No       | A reference to this specific cancellation. | string | This will be visible in the order events and searchable in the Merchant Hub. Maximum 255 characters. |

### Response

A successful cancel answers `202 Accepted` with an empty body and a `Location` header pointing at
the order.

:::note The cancel is not live yet
`202` means Walley accepted the request, not that it has been applied. Reading the order back right
away usually returns the old version. See
[Asynchronous operations](/docs/manage/concepts/asynchronous-operations) for how to read the result
and retry safely.
:::
