# checkly env - Checkly Docs

> Manage the global variables of a Checkly account.

Source: https://www.checklyhq.com/docs/cli/checkly-env/

---

Back to top
- Usage
- Subcommands
- checkly env add
- checkly env update
- checkly env ls
- checkly env pull
- checkly env rm
- Variable Types Regular Variables
- Locked Variables
- Secrets

- Variable Scope
- Best Practices
- Related Commands

CLI Commands

# checkly env

Manage the global variables of a Checkly account.

The `checkly env` command manages global environment variables in your Checkly account. Create, update, list, export, and remove variables that are available across all checks in your account.

Prerequisites

Before using `checkly env`, ensure you have:

- An initialized Checkly CLI project

- At least one check or resource defined in your project

- Valid Checkly account authentication (run `npx checkly login` if needed)

- A `checkly.config.ts` or `checkly.config.js` configuration file

For additional setup information, see [CLI overview](https://www.checklyhq.com/docs/cli/overview).

## Usage

The basic command structure uses subcommands to manage environment variables.
Terminal

```
npx checkly env [arguments] [options]
```

## Subcommands

Subcommand Description

`add` Create and add a new environment variable.

`update` Update an existing environment variable.

`ls` List all global environment variables.

`pull` Export variables to a local file.

`rm` Remove an environment variable.

## `checkly env add`

Create a new global environment variable.
**Usage:**
Terminal

```
npx checkly env add [value] [options]
```

If you leave out the value, the CLI asks for it with a hidden input, which keeps it out of your shell history.

`checkly env add` fails if a variable with the same key already exists. Use `checkly env update` to change its value, or pass `--secret` to `env update` to turn a plain variable into a secret.

**Options:**
Option Required Description

`--locked, -l` - Lock variable.

`--secret, -s` - Store as secret.

**Examples:**
Terminal

```
# Add regular variable
npx checkly env add ENVIRONMENT "production"

# Add locked variable
npx checkly env add INTERNAL_API_URL "https://internal.api.com" --locked

# Add secret variable
npx checkly env add API_SECRET "super-secret-key" --secret
```

## `checkly env update`

Update an existing global environment variable.
**Usage:**
Terminal

```
npx checkly env update [value] [options]
```

If you leave out the value, the CLI asks for it with a hidden input, which keeps it out of your shell history.

`env update` always saves the variable with the `--locked` and `--secret` flags you pass. Pass `--locked` again when you update a locked variable, or it is saved unlocked. Pass `--secret` again when you update a secret, or the update fails.

**Options:**
Option Required Description

`--locked, -l` - Lock variable.

`--secret, -s` - Store as secret.

**Examples:**
Terminal

```
# Update regular variable
npx checkly env update ENVIRONMENT "staging"

# Update and convert to locked
npx checkly env update API_KEY "new-secret-key" --locked

# Update existing secret
npx checkly env update DATABASE_PASSWORD "new-password" --secret
```

## `checkly env ls`

List all global environment variables in your account.
**Usage:**
Terminal

```
npx checkly env ls
```

**Examples:**
Terminal

```
# List all variables
npx checkly env ls
```

Shows variable keys and their values. Secret values are hidden for security.

## `checkly env pull`

Export global variables from your Checkly account to a local file.
**Usage:**
Terminal

```
npx checkly env pull [filename] [options]
```

**Options:**
Option Required Description

`--force, -f` - Overwrite existing file without confirmation

**Examples:**
Terminal

```
# Pull to default .env file
npx checkly env pull

# Pull to specific file
npx checkly env pull .env.production

# Force overwrite existing file
npx checkly env pull .env.production --force
```

## `checkly env rm`

Remove a global environment variable.
**Usage:**
Terminal

```
npx checkly env rm [options]
```

**Options:**
Option Required Description

`--force, -f` - Skip confirmation dialog

**Examples:**
Terminal

```
# Remove with confirmation
npx checkly env rm ENVIRONMENT

# Remove without confirmation
npx checkly env rm OLD_VARIABLE --force
```

## Variable Types

### Regular Variables

Standard key-value pairs visible to all team members:
Terminal

```
npx checkly env add ENVIRONMENT "production"
```

### Locked Variables

Locked environment variables can only be accessed by team members with “Read & Write” access or above.
Terminal

```
npx checkly env add INTERNAL_API_URL "https://internal.api.com" --locked
```

### Secrets

Once saved, secrets are never shown in the UI or in logs. The secret value cannot be accessed via the CLI or API.
Terminal

```
npx checkly env add API_SECRET "super-secret-key" --secret
```

## Variable Scope

Environment variables managed by `checkly env` are **global** and available to:

- All checks in your account

- All check groups

- All team members (unless locked)

For check-specific or group-specific variables, use the web UI or configure them directly in your monitoring-as-code setup.

## Best Practices

- **Use secrets for sensitive data** like API keys, passwords, and tokens

- **Lock internal variables** that shouldn’t be visible to read-only users

- **Use descriptive names** following standard conventions (UPPER_SNAKE_CASE)

- **Document variables** and their purposes for team collaboration

- **Regular cleanup** of unused variables to maintain security

## Related Commands

- [`checkly test`](https://www.checklyhq.com/docs/cli/checkly-test) - Test your setup before deployment

- [`checkly deploy`](https://www.checklyhq.com/docs/cli/checkly-deploy) - Deploy your Checkly configuration

Was this page helpful?

[Suggest edits](https://github.com/checkly/docs/edit/main/cli/checkly-env.mdx)[Raise issue](https://github.com/checkly/docs/issues/new?title=Issue%20on%20docs&body=Path:%20/cli/checkly-env)

[checkly destroy Previous](https://www.checklyhq.com/docs/cli/checkly-destroy)[checkly import Next](https://www.checklyhq.com/docs/cli/checkly-import)

[x](https://x.com/checklyhq)[github](https://github.com/checkly)[linkedin](https://linkedin.com/company/checkly)

[Powered by This documentation is built and hosted on Mintlify, a developer documentation platform](https://www.mintlify.com/?utm_campaign=poweredBy&utm_medium=referral&utm_source=checkly-422f444a)
