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

# API keys

> How @carbon-js/connect resolves your Carbon API key, and how to point different coding apps at different spaces.

`@carbon-js/connect` authenticates each app with a space-scoped Carbon API key. Generate one in the dashboard under **Settings → API Keys** ([oncarbon.site/app/settings/api-keys](https://oncarbon.site/app/settings/api-keys)).

## Resolution order

When you connect an app, the key is resolved in this order — the first one present wins:

<Steps>
  <Step title="--key flag">
    ```bash theme={null}
    npx @carbon-js/connect@latest connect codex --key crb_…
    ```
  </Step>

  <Step title="CARBON_API_KEY environment variable">
    Keeps the secret out of your shell history — the right choice for CI:

    ```bash theme={null}
    export CARBON_API_KEY=crb_…
    npx @carbon-js/connect@latest connect claude-code
    ```
  </Step>

  <Step title="Interactive prompt">
    If neither is set, `@carbon-js/connect` prompts for the key (and links to the page where you generate one).
  </Step>
</Steps>

## Per-app keys

Each app's key is written into **its own** config, so different apps can report to different Carbon spaces:

```bash theme={null}
@carbon-js/connect connect codex --key <key-for-space-A>
@carbon-js/connect connect claude-code --key <key-for-space-B>
```

The interactive flow offers the same choice — connect multiple apps in one run, with a key per app.

<Note>
  The key is stored in the app's local config on your machine (see [How it works](/documentation/connect/how-it-works)),
  never uploaded anywhere except as the bearer token on each app's OTLP export to Carbon.
</Note>
