Why We Build This Way
Our Philosophy: APIs should be predictable, transparent, and never surprise you. Every decision in our API design prioritizes developer happiness and operational confidence.
Design Principles
Standards-First
We follow RFC 9457 for errors, IETF draft-ietf-httpapi-ratelimit-headers for rate limits, and RFC 7807 patterns throughout. No proprietary formats to learn.
Observable by Default
Every response includes 15+ headers giving you complete visibility into credits, rate limits, concurrency, and usage - without extra API calls.
Graceful Degradation
Soft-mode rate limiting, automatic retries, and fallback mechanisms mean our limits guide you rather than break you.
Context-Rich Errors
Errors include actionable suggestions, documentation links, and machine-readable context so you can handle them programmatically.
Why Response Headers Matter
Traditional APIs force you to make extra calls to check your balance or limits. LeadMagic embeds everything in response headers:- Your remaining credits (
X-Credits-Remaining) - Rate limit status (
RateLimit-Remaining,RateLimit-Reset) - Daily quota (
X-RateLimit-Remaining-Daily) - Usage percentages (
X-RateLimit-Daily-Usage-Percent) - Soft mode status (
X-RateLimit-Soft-Mode)
Response Headers
Every API response includes comprehensive headers for monitoring, debugging, and rate limit management.- Rate Limit Headers
- Credits Headers
- Usage Metrics
- Soft Mode Headers
- Concurrency Headers
IETF Standard Headers (Recommended)
Following the IETF draft-ietf-httpapi-ratelimit-headers standard:| Header | Description | Example |
|---|---|---|
RateLimit-Limit | Maximum requests per minute | 3000 |
RateLimit-Remaining | Requests remaining this minute | 2847 |
RateLimit-Reset | Seconds until limit resets | 42 |
Legacy X- Headers (Backwards Compatible)
| Header | Description | Example |
|---|---|---|
X-RateLimit-Limit | Maximum requests per minute | 3000 |
X-RateLimit-Remaining | Requests remaining this minute | 2847 |
X-RateLimit-Reset | Unix timestamp when limit resets | 1706745600 |
Daily Limit Headers
| Header | Description | Example |
|---|---|---|
X-RateLimit-Limit-Daily | Maximum requests per day | 500000 |
X-RateLimit-Remaining-Daily | Requests remaining today | 485000 |
X-RateLimit-Reset-Daily | Unix timestamp when daily limit resets | 1706832000 |
Complete Header Reference
Here’s a real-world example showing all headers in a typical response:Request Headers
Required Headers
| Header | Description | Example |
|---|---|---|
X-API-Key | Your API key (case-insensitive) | lm_live_abc123... |
Content-Type | Always application/json for POST | application/json |
Case-Insensitive Authentication: The
X-API-Key header accepts any case variation: X-API-Key, X-API-KEY, x-api-key all work identically.Optional Headers
| Header | Description | Use Case |
|---|---|---|
User-Agent | Identifies your application | Used for timeout optimization (Clay integrations get longer timeouts) |
X-Request-ID | Your request tracking ID | Returned in error responses for debugging |
Accept | Response format | application/json (default) |
Success Messages
Every endpoint returns a human-readablemessage field that tells you exactly what happened. These are designed to be user-friendly and can be displayed directly in your UI.
- Email Validation
- Email Finder
- Mobile Finder
- Profile Search
- Company Search
- Role Finder
- Employee Finder
- Job Change Detector
| Message | Meaning |
|---|---|
Email is valid. | Email verified as deliverable |
Email is valid (catch-all domain with engagement data). | Valid with extra confidence on catch-all domain |
Email is invalid. | Email doesn’t exist or bounces |
Domain accepts all emails (catch-all). Unable to verify specific address. | Can’t verify on catch-all domain |
Unable to determine email validity. | Verification inconclusive |
Why Messages Matter: These aren’t just for humans - they’re also machine-readable. Check the
message field to determine success vs. not-found scenarios, especially when credits_consumed might still be > 0 for verified “not found” results.Analytics Endpoints
Monitor your API usage programmatically with our comprehensive analytics suite.All analytics endpoints are FREE - they don’t consume any credits and are exempt from rate limiting.
Dashboard Overview
Get a real-time snapshot of your account status:Available Analytics Endpoints
GET /v1/analytics/dashboard
Real-time dashboard with credits, rate limits, and usage stats for today, this week, and this month.
GET /v1/analytics/usage
Daily usage summary with total requests, credits consumed, and chargeable rates.Query params:
?days=30 (1-90)GET /v1/analytics/products
Per-product breakdown showing requests, credits, success rates, and average costs.Query params:
?days=30 (1-90)GET /v1/analytics/credits
Credit consumption history with daily breakdown and chargeable request analysis.Query params:
?days=30 (1-90)GET /v1/analytics/summary
All-time statistics including total requests, credits consumed, success rates, and first/last request timestamps.Query params:
?start_date=YYYY-MM-DD&end_date=YYYY-MM-DDGET /v1/analytics/daily
Detailed daily metrics with latency percentiles, error rates, and performance data.Query params:
?days=30 (1-90)GET /v1/analytics/day/:date
Per-product breakdown for a specific day. Top 15 products plus aggregated “other” category.Path param:
:date in YYYY-MM-DD formatUsage Example: Daily Breakdown
Credits Endpoints
Check Your Balance
Additional Credits Endpoints
| Endpoint | Method | Description |
|---|---|---|
GET /v1/credits | GET | Get current credit balance |
POST /v1/credits/refresh | POST | Force refresh credits from database |
GET /v1/credits/health | GET | Validate API key and check authentication status |
Error Handling
LeadMagic follows RFC 9457 Problem Details for standardized, machine-readable error responses.Error Response Format
Response Fields Explained
| Field | Description |
|---|---|
type | URI identifying the error type (machine-readable) |
title | Human-readable summary (safe to display to users) |
status | HTTP status code |
detail | Specific explanation of what went wrong |
code | Short error code for programmatic handling |
action | Suggested fix or next steps |
docs | Link to relevant documentation |
context | Machine-readable details (varies by error type) |
HTTP Status Codes
200
Success - Request completed
400
Bad Request - Invalid input
401
Unauthorized - Invalid API key
402
Payment Required - Low credits
429
Too Many Requests - Rate limited
500
Server Error - Our fault
Error Types
- 401 Authentication
- 400 Validation
- 429 Rate Limits
- 402 Credits
- 5xx Server
HTTP 401 - Unauthorized
| Code | Description |
|---|---|
missing_authentication | No API key provided in X-API-Key header |
invalid_api_key | API key doesn’t exist or is incorrect |
insufficient_permissions | API key lacks access to this resource |
Idempotency
Every request can include a unique identifier for tracking and debugging:X-Request-ID is returned in error responses and logged for debugging:
Graceful Degradation
LeadMagic is designed to handle failures gracefully:| Scenario | Behavior |
|---|---|
| DO Timeout | Falls back to direct database query |
| Rate limit in soft mode | Logs warning but allows request |
| External service failure | Returns 502 with retry guidance |
| Database unavailable | Returns 503 with retry timing |
High Availability: Our Durable Objects provide sub-millisecond rate limiting with automatic failover to PostgreSQL when needed.
Best Practices
Implement Exponential Backoff
Implement Exponential Backoff
When you receive a 429 error, use the
Retry-After header:Monitor Rate Limit Headers
Monitor Rate Limit Headers
Build proactive monitoring using response headers:
Use Request IDs for Debugging
Use Request IDs for Debugging
Always include a request ID for easier debugging:
Cache Credits Check
Cache Credits Check
Don’t call
/v1/credits before every request. Cache and refresh periodically:SDK Support
While we don’t have official SDKs yet, our REST API works seamlessly with any HTTP client:Node.js
Use native
fetch or axios for HTTP requests.Python
Use
requests or httpx for async support.Any Language
Any HTTP client works - just send JSON with your API key.
Why We Built It This Way
RFC 9457 Problem Details for Errors
RFC 9457 Problem Details for Errors
Traditional APIs return cryptic errors like
{"error": "Bad request"}. This leaves developers guessing what went wrong and how to fix it.Our approach: Every error follows RFC 9457 Problem Details, a standard designed by the IETF specifically for HTTP API errors. This means:type: A URI identifying the error type (bookmarkable, consistent)title: Human-readable summary you can show usersstatus: HTTP status code (redundant but useful)detail: Specific explanation of what went wrongaction: Suggested fix (unique to LeadMagic)docs: Link to relevant documentationcontext: Machine-readable details (credits needed, rate limits, etc.)
type while showing users the title and action.IETF Rate Limit Headers
IETF Rate Limit Headers
We implement the IETF draft-ietf-httpapi-ratelimit-headers standard for rate limit headers:Why this matters:
- These headers are on track to become an official standard
- Libraries already support them (many HTTP clients auto-parse)
- Consistent across all modern APIs that implement the spec
- No need to learn LeadMagic-specific header names
X-RateLimit-* headers for backwards compatibility.Soft Mode Rate Limiting
Soft Mode Rate Limiting
Most APIs hard-block you when you hit limits. This causes:
- Unexpected failures in production
- Data loss if you’re mid-batch
- Frustrated developers
- Log the violation
- Set
X-RateLimit-Soft-Exceeded: true - Still process your request
Credits in Every Response
Credits in Every Response
Checking your balance shouldn’t require extra API calls. Every enrichment response includes:Benefits:
- Build credit alerts without polling
- Log spend per-request for cost attribution
- Pause automatically when credits run low
- Never wonder “how much did that cost?”
Meaningful Success Messages
Meaningful Success Messages
Our
message field isn’t just “success” - it tells you what actually happened:"Email is valid."- Great, use it!"Domain accepts all emails (catch-all)."- Be cautious"No email found for this person."- Try different inputs
- Display messages directly to end users
- Make programmatic decisions based on outcomes
- Distinguish between “not found” and “error”
Zero-Cost Analytics
Zero-Cost Analytics
All analytics endpoints are FREE - no credits consumed, no rate limits. This means you can:
- Poll
/v1/analytics/dashboardevery minute - Build real-time dashboards
- Set up alerting without worrying about cost
- Audit your usage as often as needed

