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

# astro env variable export

<Info>
  This command is only available on Astro.
</Info>

Export the environment variables for a scope as `KEY=VALUE` lines suitable for a `.env` file. The output round-trips with the `--from-file` flag on [`astro env variable create`](/docs/cli/v1.43/astro-env-variable-create) and [`astro env variable update`](/docs/cli/v1.43/astro-env-variable-update), so you can promote variables between Workspaces or pull them into a local Astro project.

By default, the CLI masks secret values. Pass `--include-secrets` to include them, subject to an Organization policy that allows it. When you use `--include-secrets`, the CLI prints a sensitive-data warning to stderr so the warning never lands in the exported file.

## Usage

```bash wrap theme={null}
astro env variable export
```

## Options

| Option              | Description                                                                                                              | Possible Values             |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------ | --------------------------- |
| `--output`          | Write the output to a file. Use `-` for stdout. Defaults to `-`.                                                         | Any valid file path, or `-` |
| `--include-secrets` | Surface secret values in the export. Requires an Organization policy that allows it.                                     | None                        |
| `--workspace-id`    | Set the Workspace scope. Mutually exclusive with `--deployment-id`. Defaults to your current Workspace from CLI context. | Any valid Workspace ID      |
| `--deployment-id`   | Set the Deployment scope. Mutually exclusive with `--workspace-id`.                                                      | Any valid Deployment ID     |

## Examples

```bash wrap theme={null}
# Export Workspace variables to a local .env file
astro env variable export --workspace-id <workspace-id> > .env

# Include secret values in the export
astro env variable export --workspace-id <workspace-id> --include-secrets > .env

# Promote variables from one Workspace to another
astro env variable export --workspace-id <dev-workspace-id> | \
  astro env variable update --workspace-id <prod-workspace-id> --from-file -
```

## Related commands

* [`astro env variable list`](/docs/cli/v1.43/astro-env-variable-list)
* [`astro env variable create`](/docs/cli/v1.43/astro-env-variable-create)
* [`astro env variable update`](/docs/cli/v1.43/astro-env-variable-update)
