Skip to main content
The LeadMagic API uses API key authentication to secure all requests. Your API key must be included in the header of every request.

Getting Your API Key

1

Log in to LeadMagic

Visit app.leadmagic.io and sign in to your account.
2

Navigate to Account Settings

Click on your profile icon and select “Account Profile” or “API Keys”.
3

Copy your API Key

Your API key will be displayed. Click to copy it to your clipboard.
Treat your API key like a password. Never share it publicly.

Using Your API Key

Include your API key in the X-API-Key header of every request:
curl -X POST 'https://api.leadmagic.io/v1/people/email-validation' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -d '{"email": "test@example.com"}'

Authentication Errors

If your API key is missing or invalid, you’ll receive a 401 Unauthorized response:
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing API key",
    "status": 401
  }
}
IssueSolution
Missing headerEnsure X-API-Key header is included
Typo in header nameUse exactly X-API-Key (case-sensitive)
Invalid keyVerify your key in the dashboard
Expired keyRegenerate your API key

Security Best Practices

Use Environment Variables

Store your API key in environment variables, not in your code.
export LEADMAGIC_API_KEY="your_key_here"

Server-Side Only

Never expose your API key in client-side JavaScript or mobile apps.

Use Secrets Managers

For production, use AWS Secrets Manager, HashiCorp Vault, or similar.

Rotate Regularly

Regenerate your API key periodically and if you suspect compromise.
When team members leave: Always regenerate your API key when employees with access leave your organization. This prevents unauthorized access.

Checking Your Credits

Monitor your credit balance to avoid service interruptions.
Use the Check Credits endpoint to programmatically monitor your balance:
curl -X GET 'https://api.leadmagic.io/v1/credits' \
  -H 'X-API-Key: YOUR_API_KEY'
Response:
{
  "credits": 10000,
  "used_this_month": 2500
}

Regenerating Your API Key

If you need to regenerate your API key:
1

Go to Account Settings

Navigate to your Account Profile in the LeadMagic dashboard.
2

Click Regenerate

Find the API Key section and click “Regenerate Key”.
3

Update your applications

Replace the old key in all your applications with the new one.
The old key will stop working immediately after regeneration.

Next Steps