---
title: "Sign in and switch accounts"
url: "https://docs.alisx.com/how-to/cli/sign-in-and-switch-accounts/"
---
# Sign in and switch accounts

Sign in to AlisX from the terminal, check which user you are, and choose the account your Build usage is measured against and that is invoiced for it each month.

## Prerequisites

- The CLI installed ([Install the CLI](https://docs.alisx.com/tutorials/install-the-cli.md)).
- An AlisX account.

## Sign in

1. Start the browser flow:

    ```bash title="Terminal"
    alis login --open
    ```

    The sign-in page opens in your browser and the terminal waits for a code.

2. Sign in, copy the code the page shows, paste it into the terminal and press ++enter++.

3. Confirm:

    ```bash title="Terminal"
    alis whoami
    ```

    ```text
    ana@example.com (<user-id>)
    ```

=== "From a coding agent"

    An agent must never run bare `alis login`: it blocks on stdin. It asks for the URL, hands it to you, and finishes with the code you paste back:

    ```bash title="Agent runs"
    alis login --json
    ```

    ```json
    {"url": "https://identity.alisx.com/authorize?redirect_uri=offline", "agent": "Ask the user to open url in a browser, sign in, and paste the code back to you; then run `alis login <code> --json`."}
    ```

    ```bash title="Agent runs"
    alis login <code> --json
    ```

## Choose the active account

Every command that touches the platform needs an active account. A fresh sign-in may have none, and you may belong to several.

1. List the accounts you can choose from:

    ```bash title="Terminal"
    alis accounts list --json
    ```

    ```json
    {
      "accounts": [
        {"name": "accounts/<id>", "display_name": "Acme", "active": true},
        {"name": "accounts/<other-id>", "display_name": "Acme Labs", "active": false}
      ]
    }
    ```

2. Select one. Your session is refreshed with it:

    ```bash title="Terminal"
    alis accounts select accounts/<other-id> --json
    ```

From now on the usage you generate is measured against that account, and it receives the invoice for its users' spend at the end of the month. `alis ideate` also reads and creates projects in this account, and the console switches to it too. In the TUI, ++ctrl+a++ opens the same picker.

## Recognise a signed-out session

Any command that exits with code 4 means the session has expired or you are signed out. Run `alis login` again and retry. A command that returns `ACTIVE_BUILD_ACCOUNT_REQUIRED` (exit 1) needs an account selected first. An agent that sees either code must hand the step to you: it never picks a billing account on your behalf.

## Sign out

In the TUI, press ++z++. There is no CLI sign-out command.

Related: [alis login](https://docs.alisx.com/reference/cli/login.md), [alis accounts](https://docs.alisx.com/reference/cli/accounts.md), [Accounts and billing](https://docs.alisx.com/explanation/accounts-and-billing.md).
