The env zero CLI is a single binary for managing your environments and deployments from the terminal or CI. It reads environments, deployments, plans, projects, and templates, and acts on them: create, deploy, destroy, and approve, cancel, or abort a deployment. Output is JSON on stdout, errors go to stderr, and exit codes are stable, so it fits cleanly into scripts.
The old CLI, the Node package @env0/cli version 1.x, is deprecated. The current CLI is a single binary and is the recommended way to use env zero from the terminal. Pin @env0/cli@^1 to stay on the old one while you migrate.
Prerequisites
- An env zero account with appropriate permissions
- A cloud credential assigned to the project you deploy into, so deployments can authenticate to your cloud provider
Step 1: Install
Homebrew covers macOS and Linux. The npm package installs the same binary, where version 2 is the current CLI. Binaries are also on the latest release. Verify with env0 version.
Step 2: Sign in
On your own machine, sign in through the browser:
This confirms a short code, signs you in, and lets you pick a default organization and project. The session is stored in your OS keychain when available, so later commands need no flags. Use --no-browser to print the URL instead, and env0 status or env0 logout to check or clear the session.
From CI
Browser login needs a terminal, so automation uses an API key instead (any env zero key works). Create one under Organization → Settings → API Keys and set it as environment variables:
Copy the API Key secret when you create it. It is not shown again.
You can also pass --api-key-id and --api-key-secret on a single command.
Step 3: Deploy
environment create provisions a new environment and starts its first deployment. environment deploy runs a new deployment on one that already exists. Add --wait to either to block until it finishes and take the exit code from its result:
To create from a git repository instead, use --repository with --type (for example terraform) and --organization. While a deploy waits, step logs (git clone, then plan and apply for Terraform or OpenTofu) stream to stderr.
Actions take an environment id, not a name. Resolve a name to an id with:
Step 4: Approvals
When an environment requires approval, its deployment pauses. Find the deployment id (the deploy output carries it at .data.id, or list the latest one):
Then act on it:
Set the gate per run with --requires-approval on environment deploy or destroy, and stop a running deployment with env0 deployment abort <deployment-id>.
Step 5: Inspect and destroy
Read commands print JSON for jq. Use -o compact for one line or -o table for a readable view:
env0 context returns an environment’s state, recent deployments, and a drift or failure summary in one call, so it is a fast way to see why something failed. Run env0 --help or env0 <command> --help for the full command surface.
Destroy an environment when you no longer need it. This deletes real infrastructure, so it requires confirmation:
Use the CLI with AI agents
The CLI is built for agents and scripts, not only people: JSON on stdout, errors on stderr, stable exit codes (0 success, 3 auth, 4 not found, and so on), and env0 context for one-request diagnosis. In an agent or CI context, authenticate with the ENV0_API_KEY_ID and ENV0_API_KEY_SECRET environment variables rather than browser login.
Install the skill
env0 skill install writes a usage guide into your coding agent’s config, so it knows the commands, flags, and output without you explaining them:
It installs for Claude Code by default. Use --agent cursor, --agent codex, or --agent copilot for others, --global to install for your user account instead of the project, or --path for a specific file. env0 skill show prints the guide and env0 skill uninstall removes it. The same guide ships as an asset on every release, so you can download it without the CLI from the latest release.
Migration from v1
The old CLI was the Node package @env0/cli version 1.x. The current CLI covers the same actions and adds a full read and diagnosis surface, but it is not a drop-in replacement: it targets environments by id, renames two environment variables, and prints JSON by default instead of streaming logs. Pin the old one while you migrate:
Install and authentication
ENV0_ORGANIZATION_ID, ENV0_PROJECT_ID, and ENV0_API_URL are unchanged. ENV0_ENVIRONMENT_NAME and ENV0_BLUEPRINT_ID are no longer read.
Commands
Flags
Legacy flags map across, though some now belong to a specific command:
environment deploy: -v to --var, -q to --secret, -u to --tf-var, -r to --revision, -t to a repeatable --target, -a to --requires-approval
environment destroy: -a to --requires-approval, -z to --skip-state-refresh, plus --checkout-updated-code
environment create: -w to --workspace-name (set once at creation, cannot change later), plus the same variable, --revision, and --requires-approval flags as deploy
The old CLI acted by name and blocked while streaming logs. The current CLI acts by id and returns the started deployment right away; add --wait to block, and env0 deployment logs <id> for the output.
Next steps
- User API Keys - Generate API keys for authenticating CLI and API calls.
- Quick Start - Deploy your first environment end to end.
- Workflows - Orchestrate multi-environment deployment pipelines.