Clay logo

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

Recap
LeadMagicDocs

SDK errors

How the leadmagic SDK reports failures: six kinds to branch on, stable codes from the API, and what to do about each.

API and network failures come back in error. Branch on error.kind; use error.code when you need the detail.

Kinds

kindMeansWhat to do
configMissing or malformed key, key in a public env var, key used in a browser, or a base URL that is not httpsFix the setup. These throw instead of returning
authKey invalid, revoked, outside its scopes, or blocked by its IP allowlistCheck the key in Settings → API Keys
billingOut of credits, credits frozen, no plan, or a spending limit reachedAdd credits or raise the limit
rate_limitToo many requestsWait retryAfter seconds
invalid_inputNot an email address, missing field, unknown resourceFix the request. Not billed
unavailableTimeout, network failure, or a LeadMagic outageRetry later. error.retryable is true

Fields

Field
codeStable code from the API, such as insufficient_credits, or an SDK code below
kindOne of the six kinds
statusHTTP status, or 0 when no response arrived
messageWhat went wrong
reasonExtra detail, such as api_key_scope or plan_entitlement
paramRequest fields the API rejected
requestIdQuote this to support
retryAfterSeconds to wait, from Retry-After
actionThe API's suggested next step
retryabletrue for rate_limit and unavailable

The API's full code list is in Errors.

SDK codes

codekind
missing_api_keyconfig
public_api_keyconfig
malformed_api_keyconfig
insecure_base_urlconfig
browser_runtimeconfig
invalid_inputinvalid_input
timeoutunavailable
network_errorunavailable
unexpected_responseunavailable

Retries

The SDK retries 429, 502, 503, 504 and network errors up to twice. It waits for Retry-After when the API sends one, uses the same idempotency key for every attempt, and stops when the next wait would pass timeoutMs.

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.