401 Errors
Fix invalid API key and authentication errors on LeadMagic API requests.
A 401 Unauthorized response means your API key wasn't accepted.
Quick checklist
- Header name: use
X-API-Key(case-insensitive) - Key value: copy fresh from Settings → API Keys
- No extra characters: no quotes, spaces, or line breaks in the key
- Key not revoked: check if the key was deleted in Settings
Correct request format
Common mistakes
| Mistake | Fix |
|---|---|
Key in query string (?api_key=) | Use header only |
Bearer prefix inside X-API-Key | Send the key alone in X-API-Key, or use Authorization: Bearer <key> |
| Wrong workspace key | Regenerate if team changed key access |
Key was working, now fails
- Key may have been rotated or revoked: create a new one
- Check if your subscription is active: past-due accounts may block API access
- If you get
402withcode: "org_closed"instead of401, the key is fine but the subscription has ended. Resubscribe and retry with the same key; rotating the key won't help
Getting 429 after repeated 401s
If the same rejected key is retried 10 or more times within 10 minutes, the API pauses it and returns
429 with a Retry-After header. Stop the retry loop, fix the key (or resubscribe for org_closed), then
send requests again after the Retry-After time.
Integration-specific
- Clay: Re-paste key in Clay integration settings
- Zapier: Disconnect and reconnect the LeadMagic account
- Custom code: Log the header value length (not the key itself) to verify it's being sent
Full auth guide: API documentation
Still failing? Contact support with timestamp and endpoint (not your API key).
Was this article helpful?