> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenfactory.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# auth - Configure credentials and profiles

Configure authentication tokens and manage profiles. Each profile stores
credentials for a different project or environment.

## Examples

```bash theme={null}
# Save a token (secure prompt, no echo)
contree auth

# Save to a named profile
contree auth --profile=personal

# Force overwrite existing profile
contree auth -y

# List all profiles and probe whether they work
contree auth ls

# Structured output for scripts and agents
contree -f json auth ls

# List profiles without network probes
contree auth ls --offline

# Switch active profile
contree auth switch personal

# Remove a profile
contree auth remove personal
contree auth rm personal -y
```

## Help output

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree auth --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree auth</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--token </span><span style={{"color":"#e5c07b"}}>AUTH\_TOKEN</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-u </span><span style={{"color":"#e5c07b"}}>AUTH\_URL</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--type </span><span style={{"color":"#e5c07b"}}>\{iam,jwt}</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-P </span><span style={{"color":"#e5c07b"}}>AUTH\_PROJECT</span><span style={{"color":"#c5c8c6"}}>]</span><br /><span style={{"color":"#c5c8c6"}}>                    \[</span><span style={{"color":"#98c379"}}>-p </span><span style={{"color":"#e5c07b"}}>PROFILE</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-y</span><span style={{"color":"#c5c8c6"}}>]</span><br /><span style={{"color":"#c5c8c6"}}>                    </span><span style={{"color":"#98c379"}}>\{list,ls,profiles,switch,remove,rm,del} ...</span><br /><br /><span style={{"color":"#c5c8c6"}}>Configure authentication credentials.</span><br /><br /><span style={{"color":"#c5c8c6"}}>Validates a token against the API (GET /v1/whoami) and saves it to the</span><br /><span style={{"color":"#c5c8c6"}}>config file under the specified profile. The token is prompted securely</span><br /><span style={{"color":"#c5c8c6"}}>via getpass if --token is not provided.</span><br /><br /><span style={{"color":"#c5c8c6"}}>Supports two auth types:</span><br /><span style={{"color":"#c5c8c6"}}>  iam (default) — bearer token + project ID, default URL provided</span><br /><span style={{"color":"#c5c8c6"}}>  jwt (legacy)  — bearer token only, URL must be specified</span><br /><br /><span style={{"color":"#c5c8c6"}}>Environment variable fallbacks during registration:</span><br /><span style={{"color":"#c5c8c6"}}>  CONTREE\_TOKEN / NEBIUS\_API\_KEY     used when --token is omitted</span><br /><span style={{"color":"#c5c8c6"}}>  CONTREE\_URL                        used when --url is omitted</span><br /><span style={{"color":"#c5c8c6"}}>  CONTREE\_PROJECT / NEBIUS\_AI\_PROJECT used when --project is omitted (IAM)</span><br /><br /><span style={{"color":"#c5c8c6"}}>Other commands ignore these variables; only \`\`contree auth\`\` reads</span><br /><span style={{"color":"#c5c8c6"}}>them. \`\`CONTREE\_PROFILE\`\` selects the profile for any command.</span><br /><br /><span style={{"color":"#c5c8c6"}}>Subcommands:</span><br /><span style={{"color":"#c5c8c6"}}>  profiles    List saved profiles (\* marks active)</span><br /><span style={{"color":"#c5c8c6"}}>  switch NAME Switch the active profile</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>\{list,ls,profiles,switch,remove,rm,del}</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>list (ls, profiles)</span><br /><span style={{"color":"#c5c8c6"}}>                        List saved profiles</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>switch</span><span style={{"color":"#c5c8c6"}}>              Switch active profile</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>remove (rm, del)</span><span style={{"color":"#c5c8c6"}}>    Remove a saved profile</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>            show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--token</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>AUTH\_TOKEN</span><span style={{"color":"#c5c8c6"}}>    API token (prompted if omitted)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-u</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--url</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>AUTH\_URL</span><span style={{"color":"#c5c8c6"}}>    API base URL</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--type</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>\{iam,jwt}</span><span style={{"color":"#c5c8c6"}}>      Auth type (default: iam)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-P</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--project</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>AUTH\_PROJECT</span><br /><span style={{"color":"#c5c8c6"}}>                        Project ID (IAM only)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-p</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--profile</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>PROFILE</span><br /><span style={{"color":"#c5c8c6"}}>                        Profile name (default: default)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-y</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--force</span><span style={{"color":"#c5c8c6"}}>           Overwrite existing profile without confirmation</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents:</span><br /><span style={{"color":"#c5c8c6"}}>  \`auth\` verifies token with /v1/whoami before writing config</span><br /><span style={{"color":"#c5c8c6"}}>  mutates local config file and may prompt for token if omitted</span><br /><span style={{"color":"#c5c8c6"}}>  use \`auth profiles\` for read-only profile discovery</span><br /><br /><span style={{"color":"#c5c8c6"}}>agent note:</span><br /><span style={{"color":"#c5c8c6"}}>  Before using this command in an automated workflow, read:</span><br /><span style={{"color":"#c5c8c6"}}>    contree agent</span></code></pre></div>

## Behavior

When you run `contree auth`, the CLI:

1. Prompts for the **token** securely via `getpass` (no echo, not stored in
   shell history)
2. Prompts for the **project ID**
3. Verifies the token with the API (`GET /v1/whoami`)
4. Writes credentials to `~/.config/contree/auth.ini`
5. If the profile already exists, prompts for confirmation (use `-y`
   to skip)

### Flags

* `--token` — API token (prompted securely if omitted)
* `--url` — API base URL (default: `https://api.tokenfactory.nebius.com/sandboxes`)
* `--project` — Project ID (prompted if omitted)
* `--profile` — Profile name (default: `default`)
* `-y` / `--force` — Overwrite existing profile without confirmation

### Environment variable shortcuts

When CLI flags (`--token`, `--url`, `--project`) are not passed,
`contree auth` checks these environment variables before falling back
to an interactive prompt:

| Variable            | Fallback for | Priority                                                |
| ------------------- | ------------ | ------------------------------------------------------- |
| `CONTREE_TOKEN`     | `--token`    | flag > `CONTREE_TOKEN` > `NEBIUS_API_KEY` > prompt      |
| `NEBIUS_API_KEY`    | `--token`    | (see above)                                             |
| `CONTREE_URL`       | `--url`      | flag > env > type-specific default > prompt             |
| `CONTREE_PROJECT`   | `--project`  | flag > `CONTREE_PROJECT` > `NEBIUS_AI_PROJECT` > prompt |
| `NEBIUS_AI_PROJECT` | `--project`  | (see above)                                             |

These variables are read **only** during `contree auth`. Other commands
ignore them and read credentials strictly from the saved profile.

If the relevant variables are set, `contree auth` runs fully
non-interactively (no prompts):

```bash theme={null}
export NEBIUS_API_KEY=eyJ...
export NEBIUS_AI_PROJECT=your-project-id
contree auth -y      # no prompts, saves immediately
```

## `auth list`

`contree auth list` (alias `auth ls`, `profiles`) prints every saved
profile from `auth.ini` and verifies each one against the API with a
2-second timeout, adding a `status` column that tells you at a glance
which profiles are usable. Pass `--offline` to suppress the probe
entirely when you only want to inspect what is saved locally.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree auth list --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree auth list</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-O</span><span style={{"color":"#c5c8c6"}}>]</span><br /><br /><span style={{"color":"#c5c8c6"}}>List configured local profiles and active marker.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>     show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-O</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--offline</span><span style={{"color":"#c5c8c6"}}>  Do not probe /v1/whoami; mark all profile statuses as offline</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: read-only command</span></code></pre></div>

Possible `status` values:

* `ok` – probe succeeded and the token has the `list` permission
* `inactive` – probe succeeded but the token lacks the `list`
  permission, meaning sandboxes are disabled on this project
* `timeout` – probe did not complete within 2 seconds
* `error` – probe failed for another reason, such as a bad token or
  another network/API error
* `offline` – you passed `--offline`, so no probe was attempted

For automation and agents, prefer:

```bash theme={null}
contree -f json auth ls
contree -f json auth ls --offline
```

## `auth switch`

`contree auth switch NAME` rewrites the `active` pointer in `auth.ini`
so subsequent commands resolve credentials from that profile. The
profile must already exist (created by `contree auth --profile=NAME`).
Switching does not touch token data, so it is safe to run as often as
you like to bounce between projects.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree auth switch --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree auth switch</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>profile\_name</span><br /><br /><span style={{"color":"#c5c8c6"}}>Set \[DEFAULT] profile in local config file.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>profile\_name</span><span style={{"color":"#c5c8c6"}}>  Profile to activate</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>    show this help message and exit</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: mutates local config state</span></code></pre></div>

## `auth remove`

`contree auth remove NAME` (aliases `rm`, `del`) deletes the profile
from `auth.ini` and removes its per-profile session database
(`sessions-NAME.db`). If the deleted profile was the active one, the
CLI promotes the first remaining profile to active (or falls back to
`default` if none remain). Confirmation is required unless `-y` is
passed.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree auth remove --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree auth remove</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-y</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>profile\_name</span><br /><br /><span style={{"color":"#c5c8c6"}}>Delete a profile section from config.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>profile\_name</span><span style={{"color":"#c5c8c6"}}>  Profile to remove</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>    show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-y</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--force</span><span style={{"color":"#c5c8c6"}}>   Do not ask for confirmation</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: mutates local config state</span></code></pre></div>

```bash theme={null}
contree auth remove personal
contree auth rm personal         # alias
contree auth del personal -y     # skip confirmation
```

<Warning>
  Avoid `--token=eyJ...` on the command line — the token is visible in
  process listings (`ps`) and shell history. Omit `--token` to use the
  secure prompt instead.
</Warning>

## Alternative authentication

Runtime commands always read credentials from the saved profile.
To authenticate without an interactive `auth` flow, either:

```bash theme={null}
# 1. Bootstrap the profile non-interactively from environment vars
export CONTREE_TOKEN=eyJ...
export CONTREE_URL=https://api.tokenfactory.nebius.com/sandboxes
contree auth -y --type jwt
contree images

# 2. Or pass the token inline per-command (visible in process listings)
contree --token=eyJ... images
```

Setting `CONTREE_TOKEN` alone (without first running `contree auth`)
will not authenticate runtime commands.

## See also

* [Install & Authenticate](../tutorial/installation) – full authentication guide
* [Configuration & Profiles](../tutorial/configuration) – config file format and precedence
