|
| 1 | +--- |
| 2 | +title: Authentication |
| 3 | +description: Sign in from the terminal, authenticate CI with an API key, and keep several accounts side by side |
| 4 | +--- |
| 5 | + |
| 6 | +import { Callout } from 'fumadocs-ui/components/callout' |
| 7 | + |
| 8 | +The CLI authenticates with a Sim API key. On a workstation, `sim login` mints and |
| 9 | +stores one for you. In CI, you supply one through the environment and nothing |
| 10 | +touches the filesystem. |
| 11 | + |
| 12 | +## Signing in |
| 13 | + |
| 14 | +```bash |
| 15 | +sim login |
| 16 | +``` |
| 17 | + |
| 18 | +The terminal prints a pairing code and a URL: |
| 19 | + |
| 20 | +``` |
| 21 | +Pairing code: K7M2-P9XT |
| 22 | +Confirm this code matches what the browser shows before approving. |
| 23 | +
|
| 24 | +https://sim.ai/cli/auth?request=…&scope=platform |
| 25 | +Waiting for approval… |
| 26 | +
|
| 27 | +✓ Logged in. Key stored in /Users/you/.sim/credentials |
| 28 | + Personal key, defaulting to ws_abc123. Override per command with --workspace. |
| 29 | +``` |
| 30 | + |
| 31 | +This is the same browser handoff shape as `gh auth login`. Nothing redeemable |
| 32 | +crosses the browser leg, and there is no loopback listener — so it works over |
| 33 | +SSH and inside containers. |
| 34 | + |
| 35 | +<Callout type="warn"> |
| 36 | +Confirm the pairing code in your terminal matches the one the browser shows |
| 37 | +before you approve. That check is what binds the approval to *your* terminal. |
| 38 | +</Callout> |
| 39 | + |
| 40 | +| Option | What it does | |
| 41 | +| --- | --- | |
| 42 | +| `--no-browser` | Print the URL instead of opening a browser | |
| 43 | +| `--scope <scope>` | Key space to mint from: `platform` (default) or `copilot` | |
| 44 | +| `-y, --yes` | Overwrite an existing profile without prompting | |
| 45 | + |
| 46 | +### Picking a workspace |
| 47 | + |
| 48 | +The approval page is where you choose the workspace — the terminal has no key |
| 49 | +yet, so it cannot list them for you. |
| 50 | + |
| 51 | +`sim login` issues a **personal** key. The workspace you pick becomes the |
| 52 | +profile's default `workspace`; it does **not** restrict the key to that |
| 53 | +workspace. Target another workspace the key can reach with `--workspace`: |
| 54 | + |
| 55 | +```bash |
| 56 | +sim workflows list --workspace ws_other |
| 57 | +``` |
| 58 | + |
| 59 | +`sim login --workspace <id>` preselects a workspace in the picker, and |
| 60 | +re-logging into an existing profile preselects the one already configured. |
| 61 | + |
| 62 | +## Checking who you are |
| 63 | + |
| 64 | +```bash |
| 65 | +sim whoami |
| 66 | +``` |
| 67 | + |
| 68 | +This prints the resolved endpoint, workspace, output format, and account — and |
| 69 | +which source each value came from. Reach for it first whenever a command targets |
| 70 | +something you did not expect. |
| 71 | + |
| 72 | +## Signing out |
| 73 | + |
| 74 | +```bash |
| 75 | +sim logout # remove the stored key |
| 76 | +sim logout --all # remove the profile entirely, including its settings |
| 77 | +``` |
| 78 | + |
| 79 | +<Callout type="warn"> |
| 80 | +`sim logout` removes the key from disk but does **not** revoke it. Revoke keys in |
| 81 | +Sim under **Settings → API keys**. |
| 82 | +</Callout> |
| 83 | + |
| 84 | +## Authenticating CI |
| 85 | + |
| 86 | +Skip `sim login` entirely. Set the key and workspace in the environment and the |
| 87 | +CLI never reads or writes a config file: |
| 88 | + |
| 89 | +```bash |
| 90 | +export SIM_API_KEY="sim_…" |
| 91 | +export SIM_WORKSPACE="ws_abc123" |
| 92 | + |
| 93 | +sim workflows run wf_7Yb2 --input '{"source":"nightly"}' --output json |
| 94 | +``` |
| 95 | + |
| 96 | +Create the key in Sim under **Settings → API keys**. Store it as a secret in your |
| 97 | +CI provider — never commit it. |
| 98 | + |
| 99 | +<Callout type="info"> |
| 100 | +`SIM_CONFIG_DIR` relocates both files if you do need them somewhere other than |
| 101 | +`~/.sim` — a container image, or a runner with no writable home directory. |
| 102 | +</Callout> |
| 103 | + |
| 104 | +### GitHub Actions |
| 105 | + |
| 106 | +```yaml title=".github/workflows/nightly.yml" |
| 107 | +jobs: |
| 108 | + digest: |
| 109 | + runs-on: ubuntu-latest |
| 110 | + steps: |
| 111 | + - uses: actions/setup-node@v4 |
| 112 | + with: |
| 113 | + node-version: '20' |
| 114 | + - run: npm install --global sim |
| 115 | + - run: sim workflows run wf_7Yb2 --output json |
| 116 | + env: |
| 117 | + SIM_API_KEY: ${{ secrets.SIM_API_KEY }} |
| 118 | + SIM_WORKSPACE: ${{ vars.SIM_WORKSPACE }} |
| 119 | +``` |
| 120 | +
|
| 121 | +## Several accounts at once |
| 122 | +
|
| 123 | +Each profile holds one identity and one set of defaults, so a production account |
| 124 | +and a local stack can coexist without re-authenticating: |
| 125 | +
|
| 126 | +```bash |
| 127 | +sim login --profile dev --endpoint http://localhost:3000 |
| 128 | +sim login --profile prod |
| 129 | + |
| 130 | +sim workflows list --profile dev |
| 131 | +sim workflows list --profile prod |
| 132 | +``` |
| 133 | + |
| 134 | +See [Configuration](/cli/configuration) for how profiles are stored and resolved. |
| 135 | + |
| 136 | +## Self-hosted and non-production deployments |
| 137 | + |
| 138 | +Point the CLI at any Sim deployment with `--endpoint`, then sign in against it: |
| 139 | + |
| 140 | +```bash |
| 141 | +sim login --profile local --endpoint http://localhost:3000 |
| 142 | +``` |
| 143 | + |
| 144 | +Save it so you do not have to repeat the flag: |
| 145 | + |
| 146 | +```bash |
| 147 | +sim configure --set-endpoint http://localhost:3000 --profile local |
| 148 | +``` |
| 149 | + |
| 150 | +## Where the key is stored |
| 151 | + |
| 152 | +Keys live in `~/.sim/credentials`, written with `0600` permissions, kept apart |
| 153 | +from the non-secret `~/.sim/config` so the two can be handled differently — you |
| 154 | +can commit `config` to a dotfiles repo, and never `credentials`. |
| 155 | + |
| 156 | +```ini title="~/.sim/credentials" |
| 157 | +[default] |
| 158 | +api_key = sim_… |
| 159 | + |
| 160 | +[dev] |
| 161 | +api_key = sim_… |
| 162 | +``` |
| 163 | + |
| 164 | +## Organization audit logs |
| 165 | + |
| 166 | +`sim audit-logs` requires a **personal** API key — the kind `sim login` issues. |
| 167 | +A workspace-scoped key cannot read organization-level audit logs. |
0 commit comments