# MD_CANCEL_FLIGHT_RUN
> Cancel an in-progress Flight run.
Cancels an in-progress run of a [Flight](/concepts/flights). The run transitions to `RUN_STATUS_CANCELLED`.

Cancelling a run that's already in a terminal status (`SUCCEEDED`, `FAILED`, `CANCELLED`) or a run that doesn't exist returns an error.

## Syntax

```sql
CALL MD_CANCEL_FLIGHT_RUN(
    flight_id := '<flight_id>',
    run_number := <n>
);
```

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `flight_id` | `UUID` | Yes | Identifier of the Flight. |
| `run_number` | `INTEGER` | Yes | The run number to cancel. |

## Examples

Cancel the most recent run if it's still in progress:

```sql
WITH latest AS (
    SELECT run_number, status
    FROM MD_FLIGHT_RUNS(flight_id := '<flight_id>')
    ORDER BY run_number DESC LIMIT 1
)
SELECT MD_CANCEL_FLIGHT_RUN(flight_id := '<flight_id>', run_number := latest.run_number)
FROM latest
WHERE latest.status IN ('RUN_STATUS_PENDING', 'RUN_STATUS_RUNNING');
```

Cancel a specific run:

```sql
CALL MD_CANCEL_FLIGHT_RUN(
    flight_id := '80000000-0000-0000-0000-000000000001',
    run_number := 42
);
```

## Related

- [`MD_FLIGHT_RUNS`](../md-flight-runs) — Find runs that are still in progress.
- [`MD_RUN_FLIGHT`](../md-run-flight) — Trigger an on-demand run.
- [`cancel_flight_run` MCP tool](/sql-reference/mcp/) — AI-agent equivalent.


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/sql-reference/motherduck-sql-reference/flights/md-cancel-flight-run/",
  "page_title": "MD_CANCEL_FLIGHT_RUN",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
