The Emailyze batch API (POST /v1/check/batch/) is designed for high-throughput email validation. This guide covers how to use it effectively for lists ranging from hundreds to millions of email addresses.
#### Chunk Large Lists Into ≤1,000 Emails Per Request
The batch endpoint accepts a maximum of 1,000 email addresses per request. For larger lists, split your input into chunks of at most 1,000 before sending.
Chunking also provides natural retry boundaries: if one chunk fails, you retry only that chunk rather than the entire list.
Rule of thumb: Use chunks of 500–1,000 emails. Smaller chunks increase HTTP overhead; larger chunks are rejected.
#### Rate Limit Awareness by Plan
Each API call — whether single-check or batch — counts as one API call against your rate limit. A batch request of 1,000 emails is still one API call (one request per second counted against your rate limit), but counts as 1,000 checks against your daily quota.
| Plan | Rate Limit | Daily Checks | Max concurrent batch requests | |------|-----------|-------------|-------------------------------| | Free | 1 req/s | 1,000 | 1 | | Starter | 10 req/s | 10,000 | 10 | | Growth | 50 req/s | 100,000 | 50 | | Enterprise | Custom | Custom | Custom |
For a Growth plan processing 100,000 emails at 1,000 per batch with 50 req/s, the theoretical minimum time is 2 seconds (100 batches / 50 req/s). In practice, allow for network latency and add backoff.
#### Deduplicate Before Sending
The batch API deduplicates within a single request, but does not deduplicate across requests. If your source list contains duplicates, filter them out before chunking to avoid wasting daily quota.
emails = list(set(raw_emails)) # Remove duplicates
For large lists, use a set or a seen-tracking structure as you read the source file, rather than loading everything into memory first.
#### Handling Partial Failures
A batch request either succeeds (HTTP 200) or fails as a whole (HTTP 4xx/5xx). There is no partial success response — if the request fails, none of the emails in that chunk have been processed. This makes retry logic straightforward: retry the entire chunk on failure.
However, individual email results within a successful response may have provider_type: "unknown" or a low risk_score if the domain is not yet in the database. These are valid results, not errors — the lookup succeeded but the domain is unclassified.
Recommended handling:
1. On HTTP 200: store all results. Flag unknown results for a follow-up check in 1–2 hours (after ETL propagation). 2. On HTTP 429: back off and retry the same chunk. 3. On HTTP 5xx: retry with exponential backoff up to 3 times, then log the failed chunk for manual review. 4. On HTTP 400 (bad request): inspect the request body — likely a malformed email or invalid JSON.
#### Async Processing with Webhooks for Lists >10,000
For lists larger than 10,000 emails, processing synchronously in a single script creates risk: network interruptions, process crashes, or rate limit pauses can lose progress. Use an async pattern instead.
Recommended architecture:
1. Split the list into chunks and enqueue each chunk as a job (e.g., Celery task, SQS message, Redis queue). 2. Workers pick up chunks, call the batch API, and store results. 3. Retry queues handle failed chunks automatically. 4. Completion detection: track chunk status (pending / done / failed) in a database or cache. Mark the job complete when all chunks are done.
For very large lists (>100,000), consider using GET /v1/download/ to obtain the full classified domain database and run lookups locally without API calls. This is available on Growth and Enterprise plans and is the most efficient approach for bulk classification.
#### Python Example: Chunking + Retry Logic
import time
import requests
from typing import Iterator
API_KEY = "your_api_key_here"
API_URL = "https://api.emailyze.xyz/v1/check/batch/"
CHUNK_SIZE = 1000
MAX_RETRIES = 3
BACKOFF_BASE = 1 # seconds
def chunks(lst: list, size: int) -> Iterator[list]:
"""Yield successive chunks of `size` from `lst`."""
for i in range(0, len(lst), size):
yield lst[i : i + size]
def check_batch(emails: list[str], retries: int = MAX_RETRIES) -> list[dict]:
"""Call the batch API with retry + exponential backoff."""
headers = {"X-API-Key": API_KEY, "Content-Type": "application/json"}
payload = {"emails": emails}
for attempt in range(retries):
try:
response = requests.post(API_URL, json=payload, headers=headers, timeout=30)
if response.status_code == 200:
return response.json().get("results", [])
if response.status_code == 429:
wait = BACKOFF_BASE * (2 ** attempt)
print(f"Rate limited. Waiting {wait}s before retry {attempt + 1}/{retries}")
time.sleep(wait)
continue
if response.status_code >= 500:
wait = BACKOFF_BASE * (2 ** attempt)
print(f"Server error {response.status_code}. Retry {attempt + 1}/{retries} in {wait}s")
time.sleep(wait)
continue
# 4xx errors (except 429) are not retryable
print(f"Request failed: {response.status_code} {response.text}")
return []
except requests.exceptions.RequestException as e:
wait = BACKOFF_BASE * (2 ** attempt)
print(f"Request exception: {e}. Retry {attempt + 1}/{retries} in {wait}s")
time.sleep(wait)
print(f"All {retries} retries exhausted for chunk of {len(emails)} emails")
return []
def process_email_list(raw_emails: list[str]) -> list[dict]:
"""Deduplicate, chunk, and process a list of email addresses."""
unique_emails = list(dict.fromkeys(raw_emails)) # Deduplicate, preserve order
print(f"Processing {len(unique_emails)} unique emails ({len(raw_emails)} total, {len(raw_emails) - len(unique_emails)} dupes removed)")
all_results = []
for i, chunk in enumerate(chunks(unique_emails, CHUNK_SIZE)):
print(f"Chunk {i + 1}: {len(chunk)} emails")
results = check_batch(chunk)
all_results.extend(results)
# Respect rate limit — adjust sleep based on your plan
# Starter: 10 req/s → ~0.1s between requests
# Growth: 50 req/s → ~0.02s between requests
time.sleep(0.1)
return all_results
if __name__ == "__main__":
# Load your email list
with open("emails.txt") as f:
emails = [line.strip() for line in f if line.strip()]
results = process_email_list(emails)
# Only store disposable results to minimize storage
disposable = [r for r in results if r.get("is_disposable")]
print(f"Found {len(disposable)} disposable addresses out of {len(results)} checked")
with open("disposable_results.jsonl", "w") as out:
import json
for r in disposable:
out.write(json.dumps(r) + "\n")
#### Storing Results Efficiently
For most use cases, you do not need to store every result — only the actionable ones. Best practice:
If you need full audit trails (e.g., for compliance), store the complete response per email, but compress old records (>30 days) to cold storage.
For very large datasets, consider storing only the domain classification (not the full email address) in your database, keyed by domain. Many email addresses share the same domain, so domain-level deduplication reduces storage significantly.
#### Summary of Best Practices
1. Chunk requests to ≤1,000 emails per call 2. Deduplicate before sending to conserve daily quota 3. Implement exponential backoff on 429 and 5xx responses 4. Use async job queues for lists >10,000 emails 5. For lists >100,000, evaluate the JSONL download for local lookups 6. Store only disposable (and temporarily unknown) results 7. Re-check unknown results after 1–2 hours to catch newly classified domains