> ## 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`.

## 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`.

## 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

> [card] [Quickstart](https://leadmagic.io/docs/cli/quickstart.md)
>
> Run your first enrichment workflow.

> [card] [Configuration](https://leadmagic.io/docs/cli/configuration.md)
>
> All config options including database, model, and theme.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.