Clay logo

LeadMagic has made more than one billion API calls with Clay and won The Unstoppable Wheel award.

Recap
LeadMagicDocs

Keeping your key safe

How the leadmagic SDK keeps API keys out of browsers and limits what a public form route can spend.

An API key in browser code can be copied and used by anyone. The SDK is built so that does not happen by accident.

What the SDK enforces

  • Server only. With a key, the SDK throws browser_runtime in a browser.
  • No public env vars. It refuses to run outside production when NEXT_PUBLIC_LEADMAGIC_API_KEY, VITE_LEADMAGIC_API_KEY or a similar variable is set, and warns in production.
  • Never logged. Error messages and logs never include the key.
  • HTTPS only. The key is sent over https. A plain http base URL throws insecure_base_url, except on localhost.
  • No redirects. A request that carries the key never follows a redirect, so the key cannot be forwarded to another host.

What the form route enforces

The route from leadmagic/next is public, so it is limited by default:

  • Same-origin JSON requests only, with a 2 kB body limit.
  • Email validation only. Company lookup is never exposed.
  • Returns { verdict, roleBased }. Company and mail server details stay on your server.
  • Caches answers per address.
  • Caps the checks that reach LeadMagic: 10 a minute per visitor IP and 120 a minute in total, on each server instance. Over a cap it answers unknown and spends nothing. Change the caps with rateLimit.

The caps are counted in memory, so separate server instances do not share them. Add protect for bot detection or a rate limiter backed by a shared store.

What you should do

  1. Use a scoped key. In Settings → API Keys, create a key for your website and allow Email Validation only.
  2. Restrict it by IP when your server has fixed outbound addresses.
  3. Rotate it if it was ever committed or bundled.

The package

  • No runtime dependencies and no install scripts.
  • Published from GitHub Actions with npm provenance, so each version links to the commit that built it. Check it with npm audit signatures.
  • Report a security problem through the security policy.
API key for REST · OAuth for LeadMagic CLI and MCP

Get your LeadMagic API key and test endpoints live.

Use your API key in the interactive REST playground. For the LeadMagic CLI, install the lm command and run lm login; hosted MCP clients also sign in with OAuth.