Skip to main content
This page covers env zero CLI version 2.6.0. Run env0 <command> --help to print the flags of the version you have installed. To install the CLI and run a first deployment, see env zero CLI.

Global flags and environment variables

Every command accepts these flags: The CLI also reads these environment variables: Each value resolves in this order: flag, then environment variable, then stored context, then default. In CI and agents, set the environment variables so each run is explicit and does not depend on stored state.

Sign-in and stored context

env0 login stores credentials and a default host, organization, and project, so later commands need no flags.
  • Browser sign-in. With no API key set and a terminal attached, login opens a browser sign-in and asks you to confirm a short code. --no-browser prints the URL instead.
  • API key. When --api-key-id and --api-key-secret (or ENV0_API_KEY_ID and ENV0_API_KEY_SECRET) are set, login validates and stores that key.
  • No key and no terminal. login exits 3. CI and agents should set the API key environment variables and skip login.
On a terminal, login then asks you to pick an organization and project. Without a terminal, it stores the --organization and --project you pass. Credentials are stored in the OS keychain. If the keychain write fails, the CLI writes them to a plain-text file readable only by your user, prints a warning: line on stderr naming the file, and still exits 0. env0 logout removes that file. Credentials are scoped to the API host they were issued for. Signing in to a second host does not sign you out of the first, and a host you have not signed in to exits 3 even when another host is authenticated. The host, organization, and project are stored once, in config.json, so switching hosts means running login again. Browser sign-in works out which env zero tenant to use from the API host. For a host outside env0.com, it exits 64 unless you pass --tenant. API keys work against any host.

Output

Every command prints one JSON envelope, except env0 skill show (raw Markdown) and env0 deployment logs --follow (a log stream). Data goes to stdout and errors go to stderr:
  • -o json prints indented JSON. -o compact prints the same JSON on one line, for jq. -o table prints aligned columns.
  • On error, stdout is empty and the exit code is non-zero, so env0 ... -o compact | jq .data is safe.
  • Arrays are always arrays. An empty result is [], never null or a missing key.
  • error.host names the host the CLI was pointed at. It is absent for usage errors and for failures before a host is chosen. Credentials and paths are removed from it.

Pagination

environment list, deployment list, and plan list return at most 100 rows by default and add a page object next to data:
"truncated": true means more rows exist. Pass --all to fetch every page. --limit accepts 1 to 100. organization list, project list, and template list are not paginated. They return the whole collection and take no --limit or --all.

Exit codes

With --wait or deployment logs --follow, the exit code reflects the deployment’s final status: The deployment is printed to stdout in both cases, including failedCommand and errorMessage when it failed. WAITING_FOR_USER means the deployment needs approval, not that it failed.

context

Returns an environment’s state, recent deployments, and a failure summary in one call. Read .data.summary first, then .data.deployments, then deployment logs for the full error. The output has these keys:
  • environment: the same object environment get returns.
  • deployments: recent deployments, newest first.
  • summary: drift status and the latest deployment’s status and type. When that deployment failed (FAILURE, INTERNAL_FAILURE, or TIMEOUT), it also carries failedCommand, a truncated errorMessage, and exitCode. It carries costEstimation when the environment has one.
  • subEnvironments: for a workflow environment, each sub-environment’s alias, plus the revision and status of its latest deployment.

Organizations

organization list

Lists every organization you can access. org is an alias for organization.

organization get

organization use

Stores a default organization for later commands. Without an id on a terminal, it shows a picker.

Projects

project list

Lists every project in the organization.

project get

project create

The new project does not become your stored project. Pass its id (.data.id) as --project to later commands, or run env0 project use <project-id>. Requires permission to create projects in the organization.

project archive

Archives the project. project get and project list still return it with isArchived: true. The CLI cannot unarchive a project, and archiving a project cannot be undone.

project use

Stores a default project, and its organization, for later commands. Without an id on a terminal, it shows a picker of the stored organization’s projects.

Templates

template list

Lists templates in exactly one scope. Passing both flags, or neither with no stored context, exits 64.

template get

template create

Requires permission to manage templates in the organization.

template assign

Assigns a template to a project. environment create --template only deploys templates assigned to the target project.

template delete

Removes the template from template list. template get can still return the record.

Environments

env is an alias for environment. Actions take an environment id, not a name.

environment list

All filters are optional and combine. The list does not include workflow sub-environments. To see them, run context on the workflow environment.

environment get

The output always includes tags, as {} when the environment has none.

environment create

Creates an environment and starts its first deployment. The output is that deployment. With --wait, its environmentId is the new environment’s id. A --repository environment gets a single-use template that needs no cleanup. When no cloud credential is assigned to the project, pass provider credentials as --secret, for example --secret AWS_ACCESS_KEY_ID=.... An assigned credential keeps keys out of your shell history and process list.

environment deploy

Starts a deployment and prints it. A deployment started while another is running is queued, not rejected. --manifest, --node, and --run-from-here are covered in Deploy workflows with the CLI.

environment destroy

Destroys the environment’s resources. This cannot be undone, so it requires --yes (or --force) and has no prompt. On an environment that requires approval, the destroy waits at WAITING_FOR_USER like any deployment.

environment archive

Marks the environment inactive without running a deployment, so its cloud resources stay. Run destroy first to remove them. See mark an environment as inactive.

environment tag list

With an id, prints that environment’s tags, for example {"team": ["eng", "payments"]}. Without one, prints every tag key and value used in the organization. tags is an alias for tag.

environment tag set

Replaces the whole value list of each key you name and leaves other keys alone. To keep an existing value, pass it again: team=eng team=payments. Prints the updated environment.

environment tag remove

Removes each key with all of its values. Passing KEY=VALUE exits 64. Tag limits and permissions are listed in Environment tags. Tags are visible to anyone who can view the environment, so do not put secrets in them.

environment ttl set

Replaces the environment’s lifespan. A duration counts from now, not from the current end, so ttl set <environment-id> 2h can bring the end forward. The minimum is 1h. Read the new end from lifespanEndAt in the output: env zero truncates it to the minute.

environment ttl extend

Adds the duration to the current end, or to now if the end has passed. On an environment with no TTL, exits 2. extend reads the current end and then writes a new one, so a TTL change someone makes in between is overwritten.

environment ttl clear

Removes the TTL, so env zero never destroys the environment automatically. lifespanEndAt disappears from the output. For default and maximum TTLs, see Configure policy TTL.

Waiting for a deployment

--wait polls the deployment until it reaches a final status, then exits with the code for that status. It retries 5xx and 429 responses. A deployment that reaches WAITING_FOR_USER stops the wait with exit 0. Approve it with deployment approve. While it waits, the deployment’s step logs stream to stderr. Stdout still receives only the final deployment, so --wait -o compact | jq works. Logs keep their color on a terminal and lose it when redirected. Secrets are redacted before the logs reach the CLI.

Deployments

deployment list

Lists deployments, newest first. Paginated, see Pagination.

deployment get

Includes a truncated errorMessage, failedCommand, and exitCode for a failed deployment.

deployment logs

Without --follow, prints the deployment’s captured output and full errorMessage, with color codes removed. Use it for the root cause of a failure. With --follow (-f), streams the logs to stdout until the deployment finishes, then exits like --wait. The stream is text grouped by step. With -o json or -o compact it is newline-delimited JSON, one {"step", "level", "message", "timestamp"} object per line, with no envelope. --poll-interval defaults to 3s.

deployment approve

Resumes a deployment at WAITING_FOR_USER. The status changes a few seconds later. Approving a deployment that has already moved on exits 2 and is harmless. Approval rights do not approve your own deployments automatically.

deployment cancel

Cancels a QUEUED deployment, or rejects one at WAITING_FOR_USER.

deployment abort

Aborts an IN_PROGRESS deployment. approve, cancel, and abort return right away and take no --wait. To follow a resumed deployment, poll deployment get until its status leaves WAITING_FOR_USER, then run deployment logs <deployment-id> --follow.

Plans

plan list

Lists plan summaries across an environment’s deployments. Paginated, see Pagination.

plan get

Returns the plan stored with a deployment. Check planAvailable first: most deployments, including those at WAITING_FOR_USER, store no plan. With no plan, resourceChanges and outputChanges are [], the same as a plan with no changes.
  • resourceChanges[].action shows delete and recreate only when a plan is stored.
  • The deployment’s planSummary counts can be higher than the entries in resourceChanges. Use resourceChanges for the actual resources.
  • To see what drifted, run plan get on the latest deployment with type driftDetection. See Drift detection.

Cost estimation

environment get, context (under summary), plan get, and deployment get include costEstimation: totalMonthlyCost and the deployment’s monthlyCostDiff, as numbers with no currency. The table output assumes USD. The field is null when cost estimation is off for the organization or the deployment produced no estimate.

Variables

variable list

Lists the variables configured on a scope, with sensitive values masked. var is an alias for variable.

VCS connections

vcs list

Lists the organization’s VCS connections. Pass a connection’s id as --vcs-connection-id to template create or environment create for a private repository. Its accessScope, for example Organization:acme, must cover the repository’s owner. --type filters by provider, for example GitHub or GitLab.

API keys

The CLI manages two kinds of API key: Use an organization key for shared CI. Use a personal key on your own machine, or when actions must be attributed to you. Both create commands print apiKeySecret once. No command returns it again. The returned apiKeyId and apiKeySecret are the values for ENV0_API_KEY_ID and ENV0_API_KEY_SECRET. Keys do not expire.

api-key list

Lists the organization’s keys without secrets, including lastUsedAt. Custom roles show as their id.

api-key create

No command shows a key’s project roles after creation.

api-key revoke

Takes the id field from api-key list, which looks like auth0|abc123, not the apiKeyId field. Quote it, because | is a shell pipe. Revoking cannot be undone. The key leaves the list at once but can keep authenticating for a short time afterwards. --force is an alias for --yes.

personal-api-key list

personal-api-key create

Creates a key with your permissions. It stops working when your user account does.

personal-api-key revoke

Takes the id field, not apiKeyId. Another user’s key id exits 4.

Sign-in commands

login

See Sign-in and stored context.

status

Always exits 0. Check .data.authenticated, not the exit code.

logout

Removes the current host’s credentials. Keeps the stored host, organization, and project. Other hosts stay signed in.

Agent skill

skill install

Writes a guide to the CLI into a coding agent’s configuration. AGENTS.md and the Copilot file are edited only between managed markers, so the rest of the file is kept. Running install again is safe. --global installs in your home directory, for claude and codex. --path writes to a file or directory you choose.

skill show

Prints the guide as Markdown, not JSON. Ignores -o.

skill uninstall

Deletes the Claude Code or Cursor file, or removes the managed block from a shared file.

Other commands

Telemetry

The CLI sends anonymous usage events and request traces: the command, output format, detected agent or CI system, authentication method, error type, exit code, CLI version, and organization id. Events use a random per-install id. They never include credentials, arguments, output, resource names or ids, or file paths. Telemetry never blocks or fails a command. To turn off both telemetry and tracing, set ENV0_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1. env0 status shows whether each is on.

Next steps