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

# devbox auth

> Log in, log out, and check authentication with the Devbox CLI.

Use `devbox auth` to manage the local user credentials used by the Devbox CLI. Log in through a browser, inspect the stored credential, check it from automation, or remove it when you no longer need access.

<h2 id="auth-usage">
  Usage
</h2>

```bash theme={null}
devbox auth [command]
```

## `devbox auth login`

Authenticate with Namespace through a browser. The command prints a login URL, waits for you to authorize the request, and stores the resulting user credential in your operating system's user configuration directory.

<Info>
  Use the `devbox login` alias for a shorter command.
</Info>

<h3 id="login-usage">
  Usage
</h3>

<CodeGroup>
  ```bash Canonical theme={null}
  devbox auth login [flags]
  ```

  ```bash Alias theme={null}
  devbox login [flags]
  ```
</CodeGroup>

### Log in through the browser

<CodeGroup>
  ```bash Canonical theme={null}
  devbox auth login
  ```

  ```bash Alias theme={null}
  devbox login
  ```
</CodeGroup>

```text Output nocopy theme={null}
Please complete the login flow in your browser.

  https://cloud.namespace.so/login/...

You are now logged into workspace "<workspace>", have a nice day.
```

Some login flows also display a verification code. Approve the request only if the authorization page displays the same code as the CLI.

<h3 id="login-options">
  Options
</h3>

<ResponseField name="--browser" type="boolean" default="true">
  Open the login URL in the default browser.

  Pass `--browser=false` to prevent the CLI from opening a browser automatically. The command still prints the URL so you can open it manually.
</ResponseField>

***

## `devbox auth logout`

Remove the locally stored user credential and its cached token. This affects subsequent local CLI and SDK authentication that relies on that credential.

<Info>
  Use the `devbox logout` alias for a shorter command.
</Info>

<h3 id="logout-usage">
  Usage
</h3>

<CodeGroup>
  ```bash Canonical theme={null}
  devbox auth logout
  ```

  ```bash Alias theme={null}
  devbox logout
  ```
</CodeGroup>

### Log out

<CodeGroup>
  ```bash Canonical theme={null}
  devbox auth logout
  ```

  ```bash Alias theme={null}
  devbox logout
  ```
</CodeGroup>

```text Output nocopy theme={null}
You are now logged out, have a nice day.
```

***

## `devbox auth check`

Print information about the locally stored user credential. The command displays the workspace identifier and, when present in the credential, its expiration time.

Use this command for interactive inspection. It exits successfully even when no valid local credential is found and prints `Not logged in.` instead. Use `devbox auth check-login` when a script needs the exit status to represent the result.

<h3 id="check-usage">
  Usage
</h3>

```bash theme={null}
devbox auth check
```

### Check the current login

```bash theme={null}
devbox auth check
```

```text Output nocopy theme={null}
Logged in.
  Tenant: <workspace-id>
  Expires: <expiration-time>
```

When no valid local credential is available, the command prints:

```text Output nocopy theme={null}
Not logged in.
```

***

## `devbox auth check-login`

Check the locally stored user credential and return a successful exit status when it is usable. The command produces no output on success, making it suitable for scripts and other automation.

It returns a non-zero exit status when the local credential is missing or invalid. For bearer credentials with an expiration time, it also fails when the credential is expired or expires within the requested duration.

<h3 id="check-login-usage">
  Usage
</h3>

```bash theme={null}
devbox auth check-login [flags]
```

### Require 30 minutes of remaining validity

```bash theme={null}
devbox auth check-login --duration 30m
```

<h3 id="check-login-options">
  Options
</h3>

<ResponseField name="--duration" type="duration" default="5m">
  Fail when a bearer credential expires within this duration.
</ResponseField>

## Related topics

<Columns cols={2}>
  <Card title="Authenticate with Namespace" icon="key" href="/docs/reference/typescript-sdk/authentication">
    Configure authentication for the TypeScript Devbox SDK.
  </Card>

  <Card title="Devboxes" icon="container" href="/docs/devbox">
    Create your first Devbox.
  </Card>
</Columns>
