# Cancel an operation

`PATCH https://api.cademi.com.br/api/v3/operations/{operation_id}`

Operation ID: `operations.update` · API v3

Requests cancellation of an operation. Set `cancellation_requested` to `true` and optionally provide a `reason`.

Cancellation is cooperative: a queued operation is canceled immediately, while a running operation stops between items. Items that have already been processed are not reverted.

Setting `cancellation_requested` to `false` has no effect; a cancellation request cannot be withdrawn. Operations that have already reached a terminal status return `operation_not_cancelable`.

Required permissions: `operations.manage`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `operation_id` | path | string | yes |  |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `cancellation_requested` | boolean | yes |  |
| `reason` | string or null | no |  |

## Responses

### 200

Returns the operation with its current state.

Body: `data`: Operation.

Fields of Operation:

| Field | Type | Required | Description |
|---|---|---|---|
| `attempt` | object or null | yes |  |
| `cancellation_requested` | boolean | yes |  |
| `created_at` | string (date-time) | yes |  |
| `error` | object or null | yes |  |
| `expires_at` | string (date-time) | yes |  |
| `finished_at` | string or null (date-time) | yes |  |
| `id` | string | yes | Public ID, with the op_ prefix. |
| `items_url` | string | yes |  |
| `object` | string, one of `operation` | yes |  |
| `progress` | object | yes |  |
| `result_url` | string or null | yes |  |
| `started_at` | string or null (date-time) | yes |  |
| `status` | string, one of `queued`, `running`, `succeeded`, `partially_succeeded`, `failed`, `canceled` | yes |  |
| `type` | string | yes | Type of the operation, from a fixed set of values. |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 404

The operation was not found or is not accessible with the current credentials.

Body: Error.

### 422

The operation has already reached a terminal status and can no longer be canceled.

Body: Error.

Full schema: https://cademi.dev/openapi/v3.json
