Skip to main content
The LeadMagic CLI requires an API key for chat, enrichment, validation, and all API-powered features. One key powers everything.

Sign In

The recommended way to authenticate is the browser-based OAuth flow:
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:
lm login -y
lm login also accepts the aliases lm auth, lm signin, and lm sign-in.

Set Your API Key

After signing in, set your API key for enrichment and validation:
lm config set apiKey
This prompts for your key securely — the value is not saved in shell history. You can also pass it directly:
lm config set apiKey lm_your_api_key_here
Get your API key from Settings > API in the LeadMagic dashboard.

Environment Variable

As an alternative to the config file, set the LEADMAGIC_API_KEY environment variable:
export LEADMAGIC_API_KEY="lm_your_api_key_here"
Add this to your shell profile (~/.zshrc, ~/.bashrc, etc.) for persistence. The environment variable takes precedence over the config file.

Config File

Authentication state and API key are 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.
Keep your API key secret. Never commit config.json to version control. The .leadmagic/ directory should be in your .gitignore.

One Key for Everything

Your LeadMagic API key powers all CLI features:
FeatureRequires API Key
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:
lm logout
This removes the stored auth token but preserves your API key configuration. Aliases: lm signout, lm sign-out.

Verify Authentication

Check that your credentials are working:
lm dashboard
This displays your account info and credit balance. If authentication is failing, run lm doctor to diagnose the issue.

Next Steps