Skip to main content
Profiles let you store credentials for multiple projects or environments and switch between them. This section walks through setting up profiles, switching contexts, and understanding how configuration is resolved.

Creating profiles

Each profile stores a token and API URL for a specific project or environment. When you first ran contree auth, it created a profile called default. Add more with --profile:
Each command prompts for a token securely (no echo), verifies it against the API, and writes it to ~/.config/contree/auth.ini. The resulting config file looks like this:
Each profile is a [profile:NAME] section with token, url, type, and project keys. The [DEFAULT] section stores the name of the active profile.

Listing profiles

See all saved profiles and which one is active:
The output shows the profile name, URL, a token hash (first 16 chars of SHA256), active status, and a health check result. auth ls verifies each profile against the API with a 2-second timeout. Possible status values:
  • ok — token is valid and has the required sandbox permission
  • timeout — server did not respond in time
  • error — bad token or network error
  • offline mode — you passed -O / --offline
  • no url — the profile has no API URL configured (re-run contree auth)
  • inactive — token authenticates, but the configured project does not grant the sandbox permission this CLI needs
Skip the network check:
For automation, use structured output:

Switching profiles

Persistent switch

Change the active profile for all future commands:

Per-command override

Use -p / --profile on any command:

Environment variable

Override for the entire shell session:

Inline token

Pass --token and --url directly:
Avoid --token on the command line in production — the token is visible in process listings and shell history.

Removing profiles

Delete a profile and its session database:
If the removed profile was active, the CLI switches to the first remaining profile.

Profiles and sessions

Each profile has its own session database (~/.config/contree/sessions-{profile}.db), so:
  • Same profile, same terminal — resumes the existing session
  • Different profile, same terminal — different session, different data
Switching from default to personal does not affect your default sessions — you can switch back and continue where you left off.
To share a session across profiles (rare), set CONTREE_SESSION:

Data storage

All data lives in CONTREE_HOME (default $XDG_CONFIG_HOME/contree, falling back to ~/.config/contree when XDG_CONFIG_HOME is unset): Override with $CONTREE_HOME:

cli.ini

cli.ini is meant for hand-editing. Create it yourself; the CLI never writes to it. Two kinds of sections are supported:

[cli] section: per-flag defaults

Keys here become argparse defaults. Use the argparse dest name (not the flag name): Example:
Precedence: CLI flag > environment variable > cli.ini > built-in default. A cli.ini setting always loses to an explicit flag.

[profile:NAME] sections: CLI-scoped profiles

cli.ini accepts the same [profile:NAME] sections as auth.ini and supports the same fields: The two files are merged at load time and auth.ini wins on conflict. What cli.ini is for: profiles (or any field, including token) you want only the contree CLI to see. The CLI merges cli.ini with auth.ini. Other contree-related tooling that talks to the API directly (the SDK, the MCP server) reads only auth.ini. Use cli.ini when you need a profile that should be invisible to those direct-API consumers, or to keep auth.ini minimal and shared. Example, CLI-only profile alongside the shared one:
The active profile is still selected by the profile key in [DEFAULT] of auth.ini (or by --profile / $CONTREE_PROFILE).

Environment variables

Read at runtime by any command: Read only by contree auth (registration-time fallbacks for omitted flags):

Resolution precedence

For token, URL, and project at runtime:
  1. CLI flag (--token, --url, --project) — overrides profile for the current invocation only
  2. Saved profile field
  3. Built-in default URL for IAM: https://api.tokenfactory.nebius.com/sandboxes
Environment variables are not consulted at runtime; to refresh credentials from environment variables, run contree auth (which reads CONTREE_TOKEN / NEBIUS_API_KEY, CONTREE_URL, and CONTREE_PROJECT / NEBIUS_AI_PROJECT as fallbacks for the corresponding flags). For profiles:
  1. -p / --profile flag
  2. CONTREE_PROFILE environment variable
  3. profile key in config [DEFAULT] section
  4. Falls back to default

See auth - Configure credentials and profiles for the full auth command reference, or Command Reference for all commands.