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

# Authentication

> Sign in to the LeadMagic CLI with browser OAuth

The LeadMagic CLI uses browser OAuth for chat, enrichment, validation, credits, and account-backed features. Your session is stored locally and refreshed when possible.

## Sign In

The recommended way to authenticate is the browser-based OAuth flow:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm login
```

This opens your browser to sign in to LeadMagic. After authentication, your session is saved locally. You can skip the browser confirmation prompt with `-y`:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm login -y
```

<Tip>
  `lm login` also accepts the aliases `lm auth`, `lm signin`, and `lm sign-in`.
</Tip>

## Config File

Authentication state is stored in the config file:

* **Global:** `~/.leadmagic/config.json`
* **Project-local:** `.leadmagic/config.json` (when run inside a project directory)

The CLI uses project-local config when a `.leadmagic/` directory exists in the current or parent directory. Otherwise it falls back to the global config.

<Warning>
  Keep authentication files secret. Never commit `config.json` to version control. The `.leadmagic/` directory should be in your `.gitignore`.
</Warning>

## One Login For Everything

Your LeadMagic login powers account-backed CLI features:

| Feature                          | Requires Login                  |
| -------------------------------- | ------------------------------- |
| AI Chat (`lm chat`)              | Yes - routes through AI Gateway |
| Enrichment (`lm enrich`)         | Yes                             |
| Email Validation (`lm validate`) | Yes                             |
| Contact Finding (`lm find`)      | Yes                             |
| Credit Check (`lm dashboard`)    | Yes                             |
| File Analysis (`lm analyze`)     | No                              |
| Database Queries (`lm query`)    | No                              |
| Health Check (`lm doctor`)       | No                              |

## Sign Out

To clear your authentication:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm logout
```

This removes the stored auth token while preserving non-auth configuration such as database, theme, and integration settings. Aliases: `lm signout`, `lm sign-out`.

## Verify Authentication

Check that your credentials are working:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm dashboard
```

This displays your account info and credit balance. If authentication is failing, run `lm doctor` to diagnose the issue.

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="bolt" href="/docs/cli/quickstart">
    Run your first enrichment workflow.
  </Card>

  <Card title="Configuration" icon="sliders" href="/docs/cli/configuration">
    All config options including database, model, and theme.
  </Card>
</CardGroup>
