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

# login

> Log into your Openlayer account through Openlayer CLI

The `openlayer login` command logs you into your Openlayer account — or creates one — through
Openlayer CLI. It saves the resulting credentials to a
[CLI profile](/api-reference/cli/commands/profile), so the other commands authenticate without
asking again.

<Info>
  [`openlayer init`](/api-reference/cli/commands/init) signs you in as one of
  its steps, so you do not need to run `login` separately when setting up a
  project for the first time.
</Info>

## Usage

```bash theme={null}
openlayer login
```

`login` first asks for a profile name, defaulting to `default` — this prompt is skipped when you
pass [`--profile-name`](/api-reference/cli/global-options#profile-name). It then asks how you
want to sign in:

| Option    | What it does                                                             |
| --------- | ------------------------------------------------------------------------ |
| `Browser` | Signs you in through your browser, where you can also create an account. |
| `API Key` | Signs you in with an existing [Openlayer API key](#api-key-sign-in).     |
| `Abort`   | Exits without touching your profiles.                                    |

## Browser sign-in

<Steps>
  <Step title="Confirm the API URL">
    `login` asks for the Openlayer API URL, defaulting to the one in your
    profile. Keep `https://api.openlayer.com` if you use
    [https://app.openlayer.com](https://app.openlayer.com); enter your own
    server URL if you are on a self-hosted or on-prem deployment.
  </Step>

  <Step title="Enter the code in your browser">
    The CLI prints an authentication code and opens the verification page in
    your browser. If it cannot open a browser — over SSH, for example — it
    prints the URL for you to open manually. Enter the code there, then select
    your workspace. If you do not have an Openlayer account yet, you can create
    one on that page, so no separate signup step is needed.
  </Step>

  <Step title="Wait for approval">
    The CLI waits while you finish signing in, then writes the credentials to
    your profile and makes it the current profile.
  </Step>
</Steps>

## API key sign-in

`login` asks for the Openlayer API URL, then for your
[Openlayer API key](/workspace-and-projects/find-your-api-key) as a hidden prompt. It verifies
the key against that URL before saving the profile, so an invalid key fails immediately.

## Non-interactive sign-in

`login` skips every prompt when either of these is true:

* You supply an API key explicitly, through
  [`--api-key`](/api-reference/cli/global-options#api-key) or the `OPENLAYER_API_KEY`
  environment variable.
* You pass [`--output-mode ci`](/api-reference/cli/global-options#output-mode).

In this mode `login` verifies the key, writes the profile and exits. It needs both of the
following, and fails with a message naming the missing one:

* A valid API key, from `--api-key` or `OPENLAYER_API_KEY`.
* A valid API base URL. This defaults to `https://api.openlayer.com`, so you only set
  `--base-url` or `OPENLAYER_BASE_URL` for a self-hosted, on-prem or local deployment.

```bash theme={null}
openlayer login --output-mode ci --api-key="$OPENLAYER_API_KEY"
```

<Note>
  Only an *explicitly* supplied key skips the prompts. A key already saved in
  your profile does not, so `openlayer login` still offers the sign-in menu when
  you want to switch accounts or workspaces.
</Note>

<Tip>
  In CI you often do not need `login` at all: set `OPENLAYER_API_KEY` and
  `OPENLAYER_PROJECT_ID` and the other commands authenticate directly. See
  [environment
  variables](/api-reference/cli/global-options#environment-variables) and the
  [GitHub Actions guide](/guides/gh-actions).
</Tip>
