Browser login and API keys
A refused command exits 3.
TRACEROOT_TOKEN holds a session token and acts like a browser login, unless its value starts with tr- or tr_, which makes it an API key. API authentication covers where a session token comes from.
What login does
traceroot login opens a browser sign-in only when no other credential wins. In a repository setup has configured, a key in ./.env or ./.traceroot/config.json usually wins, so login may not open a browser. To sign in through the browser anyway, run login from a directory with neither file, with TRACEROOT_API_KEY unset. The session then applies to that host from any directory.
Naming a host with
--host or TRACEROOT_HOST_URL, in the environment or in --env-file, skips that last row: a saved key is checked against the new host, and otherwise the browser sign-in runs.
traceroot status shows who the credential belongs to and where it came from.
traceroot logout depends on the credential too:
- Saved session: revokes and removes it. A key in
./.traceroot/config.jsonthen takes over, so runlogoutagain to remove that too. If the revoke fails, the session stays and the command exits 5. - Session token in
TRACEROOT_TOKEN: revokes the session. Unset the variable yourself. - Key in
./.traceroot/config.json: removes the key. - Any other key: changes nothing. Remove it yourself.
Which credential is used
Highest first:--api-key--env-file:TRACEROOT_TOKEN, thenTRACEROOT_API_KEYTRACEROOT_TOKEN- The saved browser login for this host
TRACEROOT_API_KEYapi_keyin./.traceroot/config.jsonTRACEROOT_API_KEYin./.env
TRACEROOT_API_KEY, so pass --api-key to use a key on a machine with both. Until you do, the key and its project don’t apply. ./.env never supplies TRACEROOT_TOKEN.
Choose a project
A browser login needs a project for project data, or the command exits 2. Highest first:--projectTRACEROOT_PROJECT_IDin--env-fileTRACEROOT_PROJECT_IDproject_idin./.traceroot/config.json, whichsetupsaves on a browser loginTRACEROOT_PROJECT_IDin./.env
traceroot projects list shows the IDs, and traceroot status shows the project in use.
The CLI reads ./.traceroot/config.json and ./.env from the current directory only, unless TRACEROOT_CONFIG_PATH names another config file. So after a browser-login setup, reads work from the directory you ran it in. Anywhere else, pass --project.
An API key names its own project, so read commands ignore all of these under a key, --project included. setup is different: its --project takes a name or ID and looks it up, which needs a browser login, so don’t combine it with a key.
Some commands have their own --project-id. It outranks the list above, and must match an API key’s project.
Use another host
--host sets the API. --auth-host sets where you sign in. Highest first:
- Host:
--host,TRACEROOT_HOST_URLin--env-file, then in the environment,host_urlin./.traceroot/config.json,TRACEROOT_HOST_URLin./.env, thenhttps://app.traceroot.ai. - Auth host:
--auth-host,TRACEROOT_AUTH_URLin--env-file, then in the environment, the one saved with the winning browser login,TRACEROOT_AUTH_URLin./.env, then the host.
Environment variables
Files
The path variables move the first two, and the CLI keeps them at mode
0600 and git-ignores .traceroot/. --env-file reads what ./.env does, plus TRACEROOT_TOKEN. When a .env.local exists, setup writes there instead, and the CLI doesn’t read that file.