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

# Authentication

> Log in to your BRICKS workspace and manage profiles

BRICKS CLI uses authentication profiles to connect to your workspace. Each profile stores a token tied to a specific workspace.

## Login

Get a one-time passcode from [BRICKS Controller](/controller) and use it to log in:

```bash theme={null}
bricks auth login <passcode>
```

Generate the one-time passcode from **Manage API Tokens** in your workspace. The passcode expires after 5 minutes and can only be used once. You can also log in with a workspace token directly:

```bash theme={null}
bricks auth login-token -t <token>
```

Generate or copy your workspace token from **Manage API Tokens** in [BRICKS Controller](/controller/workspaces).

## Profiles

Profiles let you manage multiple workspace connections. Each login creates or updates a profile.

```bash theme={null}
# Login and save to a named profile
bricks auth login <passcode> -p my-workspace

# List all profiles
bricks auth list

# Switch the active profile
bricks auth use <profile>

# Check which profile is active
bricks auth status
```

### Per-command profile override

Use `-ap` or `--auth-profile` to run any command as a different profile without switching:

```bash theme={null}
bricks -ap staging device list
bricks --auth-profile production app list
```

**Resolution order:** `--auth-profile` flag > `BRICKS_PROFILE` environment variable > stored active profile.

## Logout

```bash theme={null}
# Remove the current profile's token
bricks auth logout

# Remove a specific profile
bricks auth logout -p my-workspace

# Remove all profiles
bricks auth logout -a
```
