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

# Environment Variables

> Configure project environment variables

# Environment Variables

Environment variables let you store configuration values like API keys, database URLs, and feature flags for your project. They are encrypted at rest and injected into the workspace when it starts.

## How It Works

1. You set environment variables on a project
2. When a workspace starts, the variables are written to a `.env` file in the project directory
3. Your application and the agent can read them from the environment

<Warning>
  Environment variable values are encrypted at rest. When listing variables, only the keys are shown — values are hidden to prevent accidental exposure.
</Warning>

## Setting Variables

<Tabs>
  <Tab title="Web">
    Go to your project's **Settings > Environment Variables**. Enter the key and value, then click **Save**.
  </Tab>

  <Tab title="CLI">
    ```bash theme={null}
    aether env set DATABASE_URL --value "postgres://user:pass@host:5432/mydb"
    ```
  </Tab>
</Tabs>

## Listing Variables

```bash theme={null}
aether env list
```

Output shows keys only:

```
KEY                   SET
DATABASE_URL          Yes
STRIPE_SECRET_KEY     Yes
NEXT_PUBLIC_API_URL   Yes
```

## Getting a Variable

```bash theme={null}
aether env get DATABASE_URL
```

Returns the decrypted value for the specified key.

## Deleting Variables

```bash theme={null}
aether env delete STRIPE_SECRET_KEY
```

## Importing from a File

You can import variables in bulk from a `.env` file:

```bash theme={null}
aether env import .env.production
```

The file should use standard `.env` format:

```bash theme={null}
# .env.production
DATABASE_URL=postgres://user:pass@host:5432/mydb
STRIPE_SECRET_KEY=sk_live_...
NEXT_PUBLIC_API_URL=https://api.example.com
```

<Note>
  Importing merges with existing variables. If a key already exists, its value is updated. Existing keys not in the file are left unchanged.
</Note>

## API Endpoints

For programmatic access, environment variables are available through the REST API:

| Method   | Endpoint                         | Description               |
| -------- | -------------------------------- | ------------------------- |
| `GET`    | `/projects/{id}/env-vars`        | List all variable keys    |
| `GET`    | `/projects/{id}/env-vars/{key}`  | Get a variable's value    |
| `PUT`    | `/projects/{id}/env-vars/{key}`  | Set or update a variable  |
| `DELETE` | `/projects/{id}/env-vars/{key}`  | Delete a variable         |
| `POST`   | `/projects/{id}/env-vars/import` | Import from `.env` format |

## Workspace Injection

When a workspace starts, all project environment variables are written to the `.env` file in the project's working directory. This means:

* Frameworks like Next.js, Vite, and Express automatically pick them up
* The agent can reference them in code and configuration
* Restarting the workspace refreshes the values from the latest project settings

<Info>
  If you update an environment variable while a workspace is running, the change takes effect on the next workspace restart. The `.env` file is only written during workspace startup.
</Info>
