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

# Manage environment variables from the CLI

> List, set, remove or replace the environment variables of a Square Cloud application with squarecloud app env, including loading them from a .env file.

`squarecloud app env` manages the environment variables of an application. How your application reads them is covered in [Environment variables](/en/platform/environment-variables).

`list` takes the app ID as its argument. `set`, `remove` and `replace` use their arguments for variables, so they take the ID with `--app`. Both are optional: see [how the CLI finds your app](/en/cli-reference/quickstart#how-the-cli-finds-your-app).

## `squarecloud app env list`

```bash Usage theme={"system"}
squarecloud app env list [appID] [--json]
```

Prints each variable as `KEY=value`, sorted by name.

```bash theme={"system"}
squarecloud app env list <appID> --json
# Prints the variables as a JSON object.
```

## `squarecloud app env set`

```bash Usage theme={"system"}
squarecloud app env set KEY=VALUE... [--from-file <path>] [--app <appID>]
```

| Flag | Description |
| - | - |
| `--from-file <path>` | Reads variables from a `.env` style file. `KEY=VALUE` arguments override the same keys from the file. |
| `--app <appID>` | The application to change. |

Sets one or more variables and leaves the others as they are.

```bash theme={"system"}
squarecloud app env set NODE_ENV=production PORT=80
# Sets two variables on the app in the ID= line.
```

```bash theme={"system"}
squarecloud app env set --from-file .env --app <appID>
# Sets every variable of a .env file.
```

```bash Output theme={"system"}
✓ Environment variables set: 2
```

## `squarecloud app env remove`

```bash Usage theme={"system"}
squarecloud app env remove KEY... [--app <appID>]
squarecloud app env remove --all [--app <appID>] [-y]
```

**Aliases:** `delete`, `unset`

| Flag | Description |
| - | - |
| `--all` | Removes every variable of the application, after a confirmation. Can't be combined with variable names. |
| `-y`, `--yes` | Skips the confirmation of `--all`. |
| `--app <appID>` | The application to change. |

```bash theme={"system"}
squarecloud app env remove API_KEY OLD_FLAG
# Removes two variables.
```

## `squarecloud app env replace`

```bash Usage theme={"system"}
squarecloud app env replace KEY=VALUE... [--from-file <path>] [--app <appID>] [-y]
```

| Flag | Description |
| - | - |
| `--from-file <path>` | Reads variables from a `.env` style file. |
| `-y`, `--yes` | Skips the confirmation prompt. |
| `--app <appID>` | The application to change. |

Replaces the **entire** set of variables with the ones you pass: variables you don't list are removed. It asks for `y/N` confirmation first, and needs at least one variable. To remove every variable, use `remove --all`.

```bash theme={"system"}
squarecloud app env replace --from-file .env --app <appID> -y
# Makes the app's variables exactly the ones in .env, without asking.
```

## Values with spaces and special characters

Your application loads its variables through a shell. So that it receives each value exactly as you typed it, the CLI quotes values that contain spaces or characters such as `$`, `&`, `;` or `#`. `env list` then shows the stored value with those quotes.

```bash theme={"system"}
squarecloud app env set 'GREETING=hello world'
# The application reads: hello world
```

A value you wrap in one pair of quotes is sent as written, so the shell of your application can expand it. Use it to build a value from another variable:

```bash theme={"system"}
squarecloud app env set 'API_URL="${HOST}:3000"'
# The application reads the value of HOST followed by :3000.
```

## The `--from-file` format

* One `KEY=VALUE` per line. Blank lines, lines starting with `#` and lines without `=` are skipped.
* An `export ` prefix is allowed, and a UTF-8 BOM at the start of the file is ignored.
* A value in matching quotes is taken as it is between them.
* In an unquoted value, anything from ` #` on is a comment: `A=foo #bar` sets `foo`. Quote values that contain ` #`.
* Escape sequences and values that span several lines are not supported.

## Related

| Command | API | JavaScript SDK | VS Code |
| - | - | - | - |
| `list` | [`GET .../envs`](/en/api-reference/endpoint/apps/envs/get) | [`api.apps.envs.get()`](/en/sdks/js/environment_variables) | [Environment variables](/en/vscode-extension/features#applications) |
| `set` | [`POST .../envs`](/en/api-reference/endpoint/apps/envs/add_n_edit) | [`api.apps.envs.set()`](/en/sdks/js/environment_variables) | [Environment variables](/en/vscode-extension/features#applications) |
| `remove` | [`DELETE .../envs`](/en/api-reference/endpoint/apps/envs/remove) | [`api.apps.envs.delete()`](/en/sdks/js/environment_variables) | [Environment variables](/en/vscode-extension/features#applications) |
| `replace` | [`PUT .../envs`](/en/api-reference/endpoint/apps/envs/overwrite) | [`api.apps.envs.replace()`](/en/sdks/js/environment_variables) | |
