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

# Environment Variables

> Manage encrypted environment variables for MCP servers

Environment variables are stored encrypted at rest and injected into the server process at runtime. Variable values are **never** returned via the API — only the variable names (keys) are exposed.

**Required scope:** `servers:read` (list), `servers:write` (set/delete)

***

## Reserved variable names

A small set of names are reserved for platform-injected configuration and cannot be overridden by a customer-set variable. If you `POST`/`PUT` a variable using one of these names, the call still succeeds, but the platform value is used at deploy time instead of yours — your value is silently ignored.

| Name                           | Purpose                                                                           |
| ------------------------------ | --------------------------------------------------------------------------------- |
| `AUTO_STOP_SECONDS`            | Idle-timeout before the machine auto-stops                                        |
| `HEALTH_CHECK_PATH`            | Path used for the machine's health check                                          |
| `HEALTH_CHECK_TIMEOUT_SECONDS` | Timeout for the health check                                                      |
| `SERVER_SUBDOMAIN`             | The server's provisioned subdomain                                                |
| `OAUTH_BASE_URL`               | Control-plane auth base URL used for OAuth 2.1 token introspection                |
| `EZFORGE_MCP_PUBLIC_URL`       | Canonical public HTTPS URL used as the OAuth 2.1 audience for token introspection |
| `FLY_MCP_REPLAY_TOKEN`         | Fly-replay auth token used for routing                                            |

***

## List env var names

```
GET /v1/servers/:serverId/env
```

Returns the names of all environment variables set on the server. Values are not returned.

**Response `200`:**

```json theme={null}
{
  "data": ["DATABASE_URL", "API_SECRET", "LOG_LEVEL"]
}
```

***

## Set env var

```
POST /v1/servers/:serverId/env
```

Creates or updates an environment variable. The variable is available on the next deployment.

**Request body:**

```json theme={null}
{
  "name": "DATABASE_URL",
  "value": "postgres://user:pass@host:5432/db"
}
```

| Field   | Type   | Required | Description                                                                                                             |
| ------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `name`  | string | ✓        | Variable name — uppercase letters, digits, or underscores; must start with a letter or underscore (e.g. `DATABASE_URL`) |
| `value` | string | ✓        | Variable value (stored encrypted)                                                                                       |

**Response `201`** (new variable) or **`200`** (updated variable):

```json theme={null}
{
  "data": {
    "id": "env_abc123",
    "serverId": "srv_xyz789",
    "name": "DATABASE_URL",
    "createdAt": "2026-01-15T10:00:00Z",
    "updatedAt": "2026-01-15T10:00:00Z"
  }
}
```

***

## Set env var by name

```
PUT /v1/servers/:serverId/env/:name
```

Creates or updates the env var identified by `:name` in the URL path.

**Request body:**

```json theme={null}
{
  "value": "postgres://user:pass@host:5432/db"
}
```

**Response `201`** (new) or **`200`** (updated): Env var object (same shape as above).

***

## Delete env var

```
DELETE /v1/servers/:serverId/env/:name
```

Removes the named environment variable. The change takes effect on the next deployment.

**Response `204`:** No content.
