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

# Authentication in CLI

There are two ways to authenticate with the E2B CLI:

## Option 1: browser authentication

> [!WARNING]
>
> This option requires an interactive browser environment.

Run the following command to sign in through your browser:

```bash theme={"theme":"css-variables"}
e2b auth login
```

This will open your default browser and prompt you to authenticate with your E2B account.

The CLI stays signed in: it uses your session's access token for every request and refreshes it automatically before it expires.

## Option 2: setup environment variables

This is the recommended option for non-interactive environments like CI/CD pipelines, servers, and containers. Set a single environment variable with your API key:

```bash theme={"theme":"css-variables"}
export E2B_API_KEY=your_api_key_here
```

With the API key set, you can run CLI commands directly without `e2b auth login`. Use CLI version 2.12.1 or later.

> [!NOTE]
>
> Learn more about obtaining and managing your API key on the [API Key page](https://docs.e2b.dev/api-key.md).

## Switch the active project

If your E2B account has access to more than one [project](https://docs.e2b.dev/projects.md), you can choose which one the CLI uses. When you sign in, the CLI selects the project in your personal workspace (if you only belong to SSO workspaces, you pick one).

```bash theme={"theme":"css-variables"}
e2b workspace list           # workspaces you belong to
e2b project list             # projects you can access, the current one marked with *
e2b project use <project>    # use this project from now on
e2b project info             # the current project and what selected it
```

`e2b project list --workspace <workspace>` lists the projects in one workspace. `e2b auth configure` does the same as `e2b project use`, with an interactive list. A project can be given by its ID, `prj_` ID, slug or name. These commands need `e2b auth login`.

To use a different project for a single command, set the `E2B_PROJECT_ID` environment variable:

```bash theme={"theme":"css-variables"}
E2B_PROJECT_ID=my-other-project e2b sandbox list
```

When `E2B_API_KEY` is set, the API key decides the project instead.
