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

# Cancel an operation

> Stop a transfer with POST /partner/operations/:operationId/cancel using the same window as the widget receipt

## Overview

`POST /partner/operations/:operationId/cancel` uses the same rules as the cancel button on the widget receipt. The clock starts when the user presses **Make Payment** (`operation.createdAt`) and lasts **30 minutes** unless your environment uses a different window.

Check first with `GET /partner/operations/:operationId`. The detail includes `data.cancellation`:

```json theme={null}
{
  "allowed": true,
  "mode": "request",
  "expiresAt": "2026-08-28T12:30:00.000Z"
}
```

| `cancellation.mode` | When | What cancel does |
| - | - | - |
| `void` | Before the corridor has executed | Stops the canonical operation. No funds have moved. |
| `request` | Operation is `executed` or `committed` | Stops the canonical operation and asks the corridor to cancel. That can reverse funds. |

Set `BASE_URL` from the [Partner API overview](/raas-widgets/api-reference/introduction).

```bash theme={null}
curl -X POST "$BASE_URL/partner/operations/op_acme_abc123/cancel" \
  -H "X-API-Key: raas_sandbox_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Customer asked us to stop this transfer."}'
```

`reason` is optional (max 500 characters). It is stored on the operation and sent on [`operation.cancelled`](/raas-widgets/webhooks/events#operationcancelled) as `cancellationReason`. That webhook also includes `cancelledBy: "partner"`.

### Success

```json theme={null}
{
  "success": true,
  "data": {
    "operationId": "op_acme_abc123",
    "status": "cancelled",
    "mode": "request",
    "cancellationReason": "Customer asked us to stop this transfer.",
    "cancelledAt": "2026-08-28T12:10:00.000Z",
    "corridorCancel": { "outcome": "ok" }
  }
}
```

`corridorCancel.outcome` is `ok` (corridor accepted), `failed` (canonical operation is cancelled, corridor call failed — Leap support is notified), or `not_applicable` (no corridor operation id).

## When cancel is refused

A refusal is **HTTP 409**. `error.code` matches `error.data.unavailableReason` in uppercase. `error.data.nextStep` says what to do. `retryable` is `true` only for `IN_FLIGHT`.

| `error.code` | Why | What to do |
| - | - | - |
| `IN_FLIGHT` | The operation is inside a step that cannot be interrupted (`executing`, `funding`, and similar). | Retry in a few seconds. The window is still open. |
| `WINDOW_EXPIRED` | More than the cancellation window has passed since Make Payment. | `error.data.expiresAt` is when it closed. Open a support case if the customer still needs the transfer stopped. |
| `ALREADY_SETTLED` | Status is `completed` or `failed`. | This endpoint cannot reverse a paid-out or failed transfer. Open a support case if funds must be recovered. |
| `ALREADY_CANCELLED` | The operation is already `cancelled`. | No further cancel is required. |

```json theme={null}
{
  "success": false,
  "error": {
    "code": "WINDOW_EXPIRED",
    "message": "The cancellation window has expired. Please contact support.",
    "data": {
      "unavailableReason": "window_expired",
      "status": "processing",
      "flowState": "executed",
      "createdAt": "2026-08-28T12:00:00.000Z",
      "expiresAt": "2026-08-28T12:30:00.000Z",
      "windowMinutes": 30,
      "retryable": false,
      "nextStep": "The cancellation window closed at 2026-08-28T12:30:00.000Z (30 minutes after createdAt 2026-08-28T12:00:00.000Z). Open a support case if the customer still needs the transfer stopped."
    }
  }
}
```

A missing operation, or one that belongs to another partner, is **404** `OPERATION_NOT_FOUND`.


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