Commands Reference

Here is the complete reference list of available CLI commands. All commands support the --help flag for additional details.

1. Login (with 2FA support)

stash login

Authenticate with your Stash account using email and password. If your account has two-factor authentication (2FA) enabled, the CLI will prompt you to enter the 6-digit code from your authenticator app. Your session is saved locally and stays active while you keep using the CLI. If it has expired, just run stash login again.

Non-interactive options: --email, --password-stdin (read the password from stdin), --otp (2FA code) and --force (log in again even if the session still works). For CI/CD, use a service token instead of logging in.

2. List Projects

stash projects list

View all projects you have access to, including their IDs, names, and environments. The default project and environment saved with stash config set are marked with *.

3. Create Project

stash projects create <project_name>

Create a new project directly from your terminal. Stash will automatically initialize default environments: dev, staging, and prod.

4. Add Environment

stash projects add-env <environment_name> [--project <project_name_or_ID>]

Add a new custom environment (e.g. qa, testing) to a specific project. If no project flag is provided, it uses the default project from your config.

stash projects rename-env <environment_name> <new_name> [--project <project_name_or_ID>]
stash projects delete-env <environment_name> [--project <project_name_or_ID>]

Rename an environment, or delete it together with all of its secrets. A project always keeps at least one environment.

5. Configure Defaults

stash config set --project <project_name_or_ID> --env <environment>

Set a default project and environment so you don't have to specify them in every command. Stash checks with the backend that the project and the environment exist. If the project has a single environment, it is selected automatically.

stash status
stash config set --lang es|pt|en|auto
stash config unset [--project] [--env] [--lang]

stash status (also stash whoami or stash config show) shows the signed-in account and the selected project and environment. stash config unset forgets the saved values. Every command accepts --project and --env to override them; if one is missing or misspelled, the error lists the projects or environments you can use.

Language: the CLI speaks English, Spanish and Portuguese. It follows your system language unless you choose one: --lang es for a single command, the STASH_LANG environment variable, or stash config set --lang pt to save it (auto goes back to the system language). stash status shows the active language. Output that scripts read, such as stash pull, stash secrets get and command names, never changes with the language.

Tab completion: stash completion bash|zsh|fish|powershell prints a script for your shell, and --project / --env then complete with your real project and environment names. In PowerShell, add stash completion powershell | Out-String | Invoke-Expression to your $PROFILE.

6. Manage Individual Secrets

stash secrets list [--project <project_name_or_ID>] [--env <environment>]
stash secrets get <KEY> [--project <project_name_or_ID>] [--env <environment>]
stash secrets set <KEY> [VALUE] [--project <project_name_or_ID>] [--env <environment>]
stash secrets delete <KEY> [--project <project_name_or_ID>] [--env <environment>] [--yes]
  • list shows only the keys; values are masked.
  • get prints the exact value, with no trailing newline when piped, so it works in scripts: export TOKEN=$(stash secrets get API_TOKEN). If the key doesn't exist, it suggests one that differs only in case.
  • set creates or updates a secret. If you leave out the value it is read from standard input, which is handy for multi-line values and keeps the value out of your shell history: cat key.pem | stash secrets set TLS_KEY.
  • delete asks for confirmation in a terminal; --yes skips it. Scripts without a terminal are never asked.

If no project or environment is given, the defaults from your config are used. The project can still be passed as the last argument (stash secrets list my-project), as in older versions.

7. Push Secrets

stash push [--project <project_name_or_ID>] [--env <environment>] [--file <input_filename>] [--dry-run] [--overwrite=false]

Upload secrets from a local env file to Stash. Reads .env.<environment> by default (for example .env.dev). New keys are created and existing keys are updated; use --overwrite=false to only add new keys, and --dry-run to preview which keys are new, changed or unchanged without uploading. Supports export, quotes, inline comments and multi-line values. The command fails (non-zero exit code) if any secret could not be uploaded.

8. Pull Secrets

stash pull [--project <project_name_or_ID>] [--env <environment>] [--file <output_filename>] [--format env|json|shell] [--force]

Download secrets and save them to a file, .env.<environment> by default. Values are always quoted and escaped, so they survive a round trip through stash push unchanged. An existing file is only replaced after you confirm, or with --force. Use --file - to print to the terminal instead, and --format json or --format shell for other formats.

9. Run with Secrets (Subprocess Injection)

stash run [--project <project_name_or_ID>] [--env <environment>] [--no-override] -- <command>

Execute a command with secrets injected as environment variables. Secrets only exist in the memory of that process and are never written to disk. Stash exits with your command's exit code and passes Ctrl+C through to it, so it behaves like running the command directly. Secrets replace existing environment variables with the same name; use --no-override to keep the existing ones. Add --verbose to see which project and environment were loaded.

On Windows, shell built-ins such as echo or set need cmd /c: stash run -- cmd /c echo %API_KEY%.

Example usage:

stash run --project myproject --env production -- npm start
stash run --env dev -- python app.py
stash run -- npm run build

10. Logout

stash logout

Securely log out, remove your local access token, and send a request to the backend server to invalidate the session in the database.

11. Update CLI

stash update

Check for and install the latest version of Stash CLI. The download is verified against the release checksums before it replaces the current binary. The CLI also checks for new versions in the background (at most once an hour) and shows a short notice when one is available; stash update always checks right away.

12. Service Tokens

stash tokens create <name> [--env <environment>] [--access read|read_write] [--expires-in-days <n>]
stash tokens list
stash tokens revoke <name_or_ID>

Create, list and revoke service tokens for the current project. See CI/CD & Service Tokens for how to use them.