# MD_GET_FLIGHT_VERSION
> Fetch the full content (source, requirements, config, token, secrets) for a specific Flight version.
Returns the full content of a single `FlightVersion`. Use this when you need the source code or requirements that ran for a specific historical run.

## Syntax

```sql
SELECT * FROM MD_GET_FLIGHT_VERSION(
    flight_id := '<flight_id>',
    version_number := <n>
);
```

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `flight_id` | `UUID` | Yes | Identifier of the Flight. |
| `version_number` | `INTEGER` | Yes | The version to fetch. Version numbers start at `1` and increment on each content update. |

## Return columns

| Column | Type | Description |
|---|---|---|
| `flight_version` | `INTEGER` | The version number. |
| `source_code` | `VARCHAR` | The Python source as of this version. |
| `requirements_txt` | `VARCHAR` | The `requirements.txt` contents as of this version. |
| `access_token_name` | `VARCHAR` | The access token label as of this version. |
| `flight_secret_names` | `LIST(VARCHAR)` | The secret names list as of this version. |
| `config` | `MAP(VARCHAR, VARCHAR)` | The config map as of this version. |
| `created_at` | `TIMESTAMP WITH TIME ZONE` | When this version was created. |

## Behavior

Content fields that are not patched in an update **carry forward** from the previous version. For example, a `source_code`-only update on version 2 produces a version 3 where `requirements_txt`, `config`, `access_token_name`, and `flight_secret_names` match version 2 but `source_code` is the new value.

## Examples

```sql
SELECT flight_version, source_code, requirements_txt
FROM MD_GET_FLIGHT_VERSION(
    flight_id := '80000000-0000-0000-0000-000000000001',
    version_number := 1
);
```

Cross-reference a run's version to read the exact source it executed:

```sql
WITH r AS (
    SELECT flight_version
    FROM MD_FLIGHT_RUNS(flight_id := '<flight_id>')
    WHERE run_number = <n>
)
SELECT v.source_code, v.requirements_txt
FROM r, MD_GET_FLIGHT_VERSION(flight_id := '<flight_id>', version_number := r.flight_version) v;
```

## Related

- [`MD_FLIGHT_VERSIONS`](../md-flight-versions) — List all versions for a Flight.
- [`MD_GET_FLIGHT`](../md-get-flight) — Fetch current summary metadata only.
- [`get_flight` MCP tool](/sql-reference/mcp/) — AI-agent equivalent (pass a `version` argument).


---

## 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-get-flight-version/",
  "page_title": "MD_GET_FLIGHT_VERSION",
  "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.
