Documentation Index
Fetch the complete documentation index at: https://leadmagic.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
Credit Balance
Monitor your credit balance programmatically. Use this endpoint to:
- Track usage across your applications
- Set up alerts before running low
- Build internal dashboards
This endpoint is FREE - no credits consumed and no rate limiting applied.
Quick Example
curl 'https://api.leadmagic.io/v1/credits' \
-H 'X-API-Key: YOUR_API_KEY'
Response
Response Fields
| Field | Type | Description |
|---|
credits | number | Your current credit balance |
Additional Endpoints
| Endpoint | Method | Description |
|---|
GET /v1/credits | GET | Get current credit balance |
POST /v1/credits/refresh | POST | Force refresh credits from database (use if balance seems stale) |
GET /v1/credits/health | GET | Validate API key and check authentication status |
Best Practices
Don’t call this endpoint before every API request. Cache the balance and refresh periodically (e.g., every 5 minutes).let cachedCredits = null;
let lastFetch = 0;
const CACHE_TTL = 60000; // 1 minute
async function getCredits() {
if (cachedCredits && Date.now() - lastFetch < CACHE_TTL) {
return cachedCredits;
}
const response = await fetch('https://api.leadmagic.io/v1/credits', {
headers: { 'X-API-Key': apiKey }
});
const { credits } = await response.json();
cachedCredits = credits;
lastFetch = Date.now();
return credits;
}
Use response headers instead
Implement alerts when credits fall below a threshold to avoid service interruptions.const { credits } = await checkCredits();
if (credits < 100) {
sendCriticalAlert('CRITICAL: Credits below 100!');
} else if (credits < 1000) {
sendWarning('Low credit balance: ' + credits);
}
Need More Analytics?
For comprehensive usage analytics, see our Analytics API which includes:
- Real-time dashboard with rate limits and usage stats
- Daily and monthly credit consumption history
- Per-product breakdown with success rates
- Latency percentiles and error tracking
Analytics API
Get detailed insights into your API usage with our comprehensive analytics suite.
Your LeadMagic API key. Header name is case-insensitive (X-API-Key, X-API-KEY, x-api-key all work).
Successful credits retrieval