Environments
Named environments let the CLI target multiple the0 API endpoints (for example, a local Docker Compose stack and a production cluster) without rewriting environment variables or overwriting your saved API key.
Each environment stores its own:
- URL - e.g.
http://localhost:3000orhttps://api.the0.app - API key - validated against the URL before it is saved
Environments live in ~/.the0/environments.json.
Add an Environment
the0 env add local --url http://localhost:3000
the0 env add prod --url https://api.the0.app --api-key the0_xxxxxxxxxxxxIf --api-key is omitted, the CLI prompts for it. The key is tested against the URL and only persisted if the API accepts it, so typos fail fast.
The first environment you add becomes the active one automatically. If you previously logged in with the0 auth login, that existing credential is migrated into a default environment so nothing is lost.
Switch the Active Environment
the0 env use prodAll subsequent commands use the new active environment.
One-off Override
Every command accepts a global --env <name> flag that overrides the active environment for that single invocation:
the0 bot list --env prod
the0 custom-bot deploy --env localList Environments
the0 env listACTIVE NAME URL
* local http://localhost:3000
prod https://api.the0.appAPI keys are never printed.
Show the Active Environment
the0 env currentRemove an Environment
the0 env remove prodIf you remove the active environment, no environment is active until you run the0 env use <name>.
Resolution Precedence
When the CLI needs a URL and API key, it resolves them in this order (highest wins):
--env <name>flag passed on the command- Active environment in
environments.json - Legacy
THE0_API_URLenv var +~/.the0/auth.json(back-compat for users who haven't runthe0 env addyet) - Default URL
http://localhost:3000
Migrating From THE0_API_URL
The THE0_API_URL environment variable and the old the0 auth config command have been replaced by named environments. Existing setups keep working until you run your first the0 env add, which migrates your legacy credential into a default environment.
Next Steps
- Authentication -
auth loginwrites to the active environment - Installation - Install the CLI