# Cancel Execution

`POST /api/workflows/{id}/executions/{executionId}/cancel`

## Description
Cancel a running or queued execution. Requires write-level access to the workflow. Scoped and organization keys need a write grant. success is true when the cancellation was durably recorded, aborted an in-process run, or cancelled the durable workflow.

## Parameters

- **id** (path) (required) — `string`: The unique identifier of the workflow.

- **executionId** (path) (required) — `string`: The unique identifier of the execution to cancel.

## Responses

### 200 — Cancellation processed. Check success: false means the request was accepted but no cancellation could be recorded.

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Whether the cancellation took effect through at least one mechanism."
    },
    "executionId": {
      "type": "string",
      "description": "The execution that was cancelled."
    },
    "redisAvailable": {
      "type": "boolean",
      "description": "Whether the cancellation store was reachable."
    },
    "durablyRecorded": {
      "type": "boolean",
      "description": "Whether the cancellation was recorded durably."
    },
    "locallyAborted": {
      "type": "boolean",
      "description": "Whether an in-process run on this server was aborted."
    },
    "temporalCancelled": {
      "type": "boolean",
      "description": "Whether the durable workflow was cancelled. Present only when the execution is bound to one."
    },
    "reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why the cancellation was not durably recorded, for example redis_unavailable."
    }
  }
}
```

### 401 — Invalid or missing API key. Ensure the X-API-Key header is set with a valid key.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 403 — The caller lacks write access to the workflow, or the key is not authorized for its workspace.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  }
}
```

### 404 — The requested resource was not found. Verify the ID is correct and belongs to your workspace.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 409 — The execution does not belong to this workflow.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  }
}
```
