Remove disposable and risky emails from your list before sending campaigns. This tutorial walks you through a five-step workflow using the Emailyze batch API, with a complete Python script you can run today.
Sending to a polluted list hurts deliverability, wastes credits, and skews metrics. This tutorial shows you how to:
1. Export your list and extract the email column 2. Chunk emails into batches of 1,000 (API limit) 3. Call the batch API for each chunk 4. Merge results and filter disposables 5. Export a clean list for your ESP
Export List → Extract Emails → Chunk (1000) → Batch API → Filter → Export Clean
Export your list from your CRM, ESP, or database. Ensure you have a column with valid email addresses (e.g. email, Email, contact_email).
If using CSV:
import csv
def load_emails_from_csv(filepath, email_column="email"):
emails = []
with open(filepath, "r", encoding="utf-8") as f:
reader = csv.DictReader(f)
for row in reader:
email = row.get(email_column, "").strip().lower()
if email and "@" in email:
emails.append(email)
return list(set(emails)) # Deduplicate
The batch API accepts up to 1,000 emails per request. Split your list:
def chunk_list(lst, size=1000):
for i in range(0, len(lst), size):
yield lst[i : i + size]
For each chunk, send a POST request:
POST https://api.emailyze.xyz/v1/check/batch/
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{"emails": ["[email protected]", "[email protected]", ...]}
Python:
import requests
import os
def check_batch(emails):
response = requests.post(
"https://api.emailyze.xyz/v1/check/batch/",
json={"emails": emails},
headers={"Authorization": f"Bearer {os.environ['EMAILYZE_API_KEY']}"},
)
response.raise_for_status()
return response.json()
The response is a list of objects, one per email, with email, is_disposable, risk_score, provider_type, etc.
Combine results from all chunks. Filter out disposables (or use risk_score for segmentation):
def filter_disposables(results):
clean = []
disposable = []
for r in results:
if r.get("is_disposable"):
disposable.append(r["email"])
else:
clean.append(r["email"])
return clean, disposable
Optional: Segment by risk score
risk_score >= 80: Remove (high risk)31–79: Review or segment separately (medium)0–30: Keep (low risk)def segment_by_risk(results):
high_risk = [r["email"] for r in results if r.get("risk_score", 0) >= 80]
medium = [r["email"] for r in results if 31 <= r.get("risk_score", 0) < 80]
low_risk = [r["email"] for r in results if r.get("risk_score", 0) < 31]
return high_risk, medium, low_risk
Write the clean emails back to CSV (or re-join with original rows if you need other columns):
def export_clean_list(emails, output_path):
with open(output_path, "w", newline="", encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerow(["email"])
for e in emails:
writer.writerow([e])
#!/usr/bin/env python3
"""
Clean email list using Emailyze batch API.
Usage: python clean_list.py input.csv output_clean.csv
"""
import csv
import os
import sys
import requests
API_KEY = os.environ.get("EMAILYZE_API_KEY")
BATCH_URL = "https://api.emailyze.xyz/v1/check/batch/"
BATCH_SIZE = 1000
def load_emails(filepath, column="email"):
emails = []
with open(filepath, "r", encoding="utf-8") as f:
reader = csv.DictReader(f)
for row in reader:
email = row.get(column, "").strip().lower()
if email and "@" in email:
emails.append(email)
return list(set(emails))
def check_batch(emails):
r = requests.post(BATCH_URL, json={"emails": emails},
headers={"Authorization": f"Bearer {API_KEY}"})
r.raise_for_status()
return r.json()
def main():
if not API_KEY:
print("Set EMAILYZE_API_KEY environment variable")
sys.exit(1)
input_path = sys.argv[1]
output_path = sys.argv[2]
emails = load_emails(input_path)
print(f"Loaded {len(emails)} unique emails")
all_results = []
for i, chunk in enumerate(range(0, len(emails), BATCH_SIZE)):
batch = emails[chunk : chunk + BATCH_SIZE]
results = check_batch(batch)
all_results.extend(results)
print(f"Processed batch {i+1}")
clean = [r["email"] for r in all_results if not r.get("is_disposable")]
disposable = [r["email"] for r in all_results if r.get("is_disposable")]
print(f"Clean: {len(clean)}, Disposable: {len(disposable)}")
with open(output_path, "w", newline="", encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerow(["email"])
for e in clean:
writer.writerow([e])
print(f"Wrote clean list to {output_path}")
if __name__ == "__main__":
main()
Run:
export EMAILYZE_API_KEY=your_key_here
python clean_list.py subscribers.csv subscribers_clean.csv
If your CSV has columns beyond email (name, company, signup date, etc.), you'll want to keep those for the clean list. Modify the script to:
1. Load full rows (not just emails) into a list of dicts. 2. Extract emails for the batch API. 3. Build a mapping: email → result from API responses. 4. Filter rows where mapping[email]["is_disposable"] is false. 5. Write the filtered rows (with all columns) to the output CSV.
Example:
rows = list(csv.DictReader(open(input_path)))
emails = [r["email"] for r in rows]
results = {} # email -> check result
for chunk in chunk_list(emails):
for r in check_batch(chunk):
results[r["email"]] = r
clean_rows = [r for r in rows if not results.get(r["email"], {}).get("is_disposable")]
# Write clean_rows to output with original columns
For lists over 50,000 emails, consider: