Complete guide to integrating CleanMail's email verification API into your application.
All API requests require authentication using your API key via the X-API-Key header.
curl -X POST https://cleanmail.dev/api/verify \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key_here" \
-d '{"email": "user@example.com"}'
There are two ways to authenticate, and they are not interchangeable. The
/api/* routes take the API key in the X-API-Key header. The
/auth/* routes belong to the signed-in account and take the session token
from POST /auth/login in the X-Session-Token header - an API key
will not work on them.
Every endpoint the service publishes, generated from openapi.json (38 endpoints). The /auth/* routes take the session token from POST /auth/login in the X-Session-Token header - they are for the signed-in account, not for the API key.
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| DELETE | /auth/account |
Session token | Delete the account and its data | |
| GET | /auth/api-key |
Session token | The signed-in account's API key | |
| POST | /auth/change-password |
Session token | Change the password | |
| GET | /auth/export |
Session token | Everything we hold about the account | |
| POST | /auth/forgot-password |
None (public) | Ask for a password reset link | |
| POST | /auth/login |
None (public) | Log in | |
| GET | /auth/me |
Session token | The signed-in account | |
| PUT | /auth/profile |
Session token | Ask for a new email address | |
| POST | /auth/profile/confirm |
Session token | Confirm the new email address | |
| POST | /auth/resend-code |
None (public) | Send the confirmation code again | |
| POST | /auth/resend-key |
Session token | Send the API key to the address on the account | |
| POST | /auth/reset-password |
None (public) | Set a new password with the reset code | |
| POST | /auth/rotate-key |
Session token | Rotate the API key | |
| POST | /auth/signup |
None (public) | Create an account | |
| POST | /auth/verify |
None (public) | Confirm an account with the emailed code |
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| POST | /api/verify |
API key | Verify one email address | |
| POST | /api/verify/batch |
API key | Verify up to 500 addresses in one request | |
| POST | /api/verify/quick |
API key | Verify one email address, fast |
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| POST | /api/demo/verify |
None (public) | Verify one address without an API key |
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| POST | /api/batch/cancel/{jobId} |
API key | Cancel a running job | |
| GET | /api/batch/download/{jobId} |
API key | Download the results of a finished job | |
| GET | /api/batch/history |
API key | List this key's batch jobs | |
| DELETE | /api/batch/jobs |
API key | Delete every finished job on this key | |
| DELETE | /api/batch/jobs/{jobId} |
API key | Delete one of this key's batch jobs | |
| GET | /api/batch/status/{jobId} |
API key | Check a batch job | |
| POST | /api/batch/upload |
API key | Upload a CSV of addresses |
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| GET | /api/webhooks |
API key | List the webhooks registered for this key | |
| POST | /api/webhooks/register |
API key | Register a webhook | |
| DELETE | /api/webhooks/{id} |
API key | Remove a webhook |
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| GET | /api/billing/portal |
Session token | A link to the Paddle customer portal | |
| GET | /api/billing/subscription |
Session token | The signed-in account's subscription | |
| POST | /api/billing/webhook |
None (public) | The Paddle payment webhook |
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| GET | /api/usage |
API key | Current usage for the API key |
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| GET | /api/features |
None (public) | The features this deployment supports |
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| GET | /api/key/{key} |
None (public) | Check whether an API key is valid |
| Method | Path | Needs | What it does | |
|---|---|---|---|---|
| GET | /health |
None (public) | Liveness check |
| Method | Path | Needs | What it does |
|---|---|---|---|
| GET | /mcp |
API key | The server-to-client stream is not offered |
| POST | /mcp |
API key | Call CleanMail through the Model Context Protocol |
Verify an email address to check if it's valid, deliverable, and not a spam trap or disposable.
{
"email": "user@example.com"
}
{
"success": true,
"email": "user@example.com",
"deliverable": true,
"reason": "valid",
"riskLevel": "low",
"riskScore": 5,
"isDisposable": false,
"isRoleAccount": false,
"isFreeProvider": false,
"isSpamTrap": false,
"isGreylisted": false,
"mxRecord": "gmail-smtp-in.l.google.com",
"responseCode": "250"
}
retryAfterSeconds and a Retry-After
header - ask again after that long. A busy or
unknown check is not charged: you only pay for answers.
X-RateLimit-Limit, X-RateLimit-Remaining,
X-Cost (1 for an answer, 0 when the server did not answer)
and Retry-After when the server was busy.
Receive real-time notifications when email verifications complete.
Webhooks enable asynchronous processing. Submit verification requests and receive results at your callback URL when processing completesβperfect for high-volume applications.
1. Register your callback URL:
POST /api/webhooks/register
{
"url": "https://yourapp.com/webhooks/cleanmail"
}
2. Keep the webhookId the response gives you:
{
"success": true,
"webhookId": "a1b2c3d4e5f60718",
"url": "https://yourapp.com/webhooks/cleanmail"
}
3. Send a batch with that webhookId:
POST /api/verify/batch
{
"emails": ["user@example.com"],
"options": { "webhookId": "a1b2c3d4e5f60718" }
}
4. Receive the results when the batch finishes:
POST https://yourapp.com/webhooks/cleanmail
{
"event": "batch_complete",
"timestamp": "2026-12-02T12:00:00Z",
"batchId": "4f3c2a1b8d9e0f12",
"summary": { "total": 1, "deliverable": 1 },
"results": [ ... ]
}
{
"event": "batch_complete",
"timestamp": "2026-12-02T12:00:00Z",
"batchId": "4f3c2a1b8d9e0f12",
"summary": {
"total": 500,
"deliverable": 431,
"invalid": 52,
"risky": 11,
"disposable": 4,
"catchall": 2,
"roleAccounts": 6
},
"results": [
{
"email": "user@example.com",
"deliverable": true,
"reason": "valid",
"riskScore": 5,
"riskLevel": "low"
}
]
}
batch_complete; a batch that failed arrives as batch_error with an error message. Webhooks belong to a batch - a single POST /api/verify always answers with the result inline.
POST /api/verify/batch with the webhookId and the callback arrives when that batch finishes. The CSV upload path (POST /api/batch/upload) does not call a webhook, so a job is followed with GET /api/batch/status/{jobId} and collected with GET /api/batch/download/{jobId} instead.
webhookId you register works on any of them, and it is still there after a restart. List yours with GET /api/webhooks and remove one with DELETE /api/webhooks/{id}.
127.0.0.1 means our server and not your machine. Register a public HTTPS URL that answers with a 2xx status.
127.0.0.1, 169.254.169.254, 10.0.0.0/8, 192.168.0.0/16 or a name like localhost is answered with 400 PRIVATE_URL. The same check runs again when the callback is delivered, so a name that resolves to a private address is refused there too.
429 or a 5xx is tried again up to three times with a short pause. A 4xx is not retried, because the receiver understood the request and said no. GET /api/webhooks shows the counters for each registration: calls is the number of deliveries that landed, attempts is every delivery tried, failures is the ones that did not work, and lastStatus and lastError say what happened last.
batchId in the payload is also the job id. GET /api/batch/status/{batchId} shows how the batch went and GET /api/batch/download/{batchId} returns the results as a CSV, so a callback that never arrived does not cost you the results.
200 OK immediately, then process asynchronously to avoid timeouts.
Verify a whole list at once with batch verification. Send up to 500 addresses inline in one request, or upload a CSV of up to 5,000 rows, then monitor the progress and download the results.
Use batch when you have a list of emails to verify. Single API calls are for real-time verification. Batch processing is more efficient for large lists and includes premium fields like DMARC, SPF, and domain age.
Upload a CSV file with email addresses. Maximum 5,000 emails per upload.
curl -X POST https://cleanmail.dev/api/batch/upload \
-H "X-API-Key: your_api_key" \
-F "file=@emails.csv"
Create a CSV with a single column of email addresses, one per line:
user@example.com
john.doe@company.com
sales@business.org
curl https://cleanmail.dev/api/batch/status/your-job-id \
-H "X-API-Key: your_api_key"
Response:
{
"success": true,
"jobId": "abc123",
"status": "processing",
"total": 500,
"processed": 234,
"valid": 45,
"invalid": 189,
"queued": 0,
"result_url": null
}
result_url is the download link for the finished CSV. It is null until the job reaches the completed state.
Returns your recent batch jobs (last 20).
curl "https://cleanmail.dev/api/batch/download/abc123?key=your_api_key"
curl -X POST https://cleanmail.dev/api/batch/cancel/abc123 \
-H "X-API-Key: your_api_key"
Removes the job and the results file it owns. A job that is still running has to be cancelled first. The usage history is kept β it is the record of what was verified and the daily quota is counted from it.
curl -X DELETE https://cleanmail.dev/api/batch/jobs/abc123 \
-H "X-API-Key: your_api_key"
DELETE /api/batch/jobs without an id deletes every finished job on the key
at once. Jobs that are still running are left alone.
When complete, download the CSV with these columns:
| Column | Description |
|---|---|
| The email address | |
| deliverable | true/false - the mail server accepted the recipient |
| reason | Why valid or invalid |
| risk_level | low/medium/high |
| is_spamtrap | Spam trap detected |
| is_disposable | Disposable email domain |
| is_role_account | Role account (info@, support@) |
| is_free_provider | Gmail, Yahoo, Outlook, etc. |
| is_catchall | Catch-all domain |
| has_dmarc | DMARC record present |
| dmarc_policy | none/quarantine/reject |
| has_spf | SPF record present |
| spf_strict | Strict SPF enforcement |
| domain_age_days | Age of domain in days |
| mx_record | MX server hostname |
| risk_score | 0-100 risk score |
Try CleanMail without an API key! The demo endpoint is rate-limited but lets you test the service.
curl -X POST https://cleanmail.dev/api/demo/verify \
-H "Content-Type: application/json" \
-d '{"email": "test@example.com"}'
Payments are handled by Paddle. The pricing cards on the home page open a Paddle checkout, Paddle takes the card details, and CleanMail never sees them. A plan is only ever changed by a signed event from Paddle, so a plan cannot be bought by editing a request.
Returns the plan on the account and the subscription behind it: the subscription id, the status, the next billing date and any scheduled change (for example a cancellation that takes effect at the end of the period). It takes the session token from POST /auth/login in the X-Session-Token header, not an API key. The subscription is null when the account has never had one.
Returns links into Paddle's customer portal, where you can update the card, cancel with the cancellation flow and download your invoices. The links are signed by Paddle and point at your own subscription, so they cannot be guessed or reused for another account. It takes the same session token.
The account page at /app.html shows the plan, the status, the next billing date and any scheduled change, and it opens this portal for you.
active is a live subscription, past_due means a payment did not go through and Paddle is retrying it (your access continues in the meantime - update the card in the portal to stop the retries), paused means the subscription is on hold, and canceled means it has ended and the account is back on the free plan.
The whole public API is described in a machine-readable OpenAPI 3.1 document, and every endpoint is available as a Postman collection. Point a code generator at the description, or import the collection and send a request in one click.
Download the OpenAPI description · Download the Postman collection · Download the Postman environment
llms.txt · llms-full.txt — the same reference written for language models, with the plans, the limits and every endpoint in plain text.
agents.md — the working manual for an AI agent: what to call, in what order, and what not to do.
Send a real check straight from this page. It uses the free demo endpoint, so no API key is needed - ten checks a minute per IP address.
Model Context Protocol. One endpoint that speaks JSON-RPC, so an AI agent can call CleanMail as a tool instead of writing the requests itself. Point the agent at https://cleanmail.dev/mcp and it will see two tools:
verify_email — check one address: deliverable, the reason, the risk score and the domain's mail records.check_domain — the mail setup of a domain: its mail exchangers, SPF, DMARC and age. DNS lookups only, no address needed.The key goes in the X-API-Key header, or as Authorization: Bearer <key>. A verification goes through the same path as POST /api/verify — the same rate limit, the same daily allowance and the same accounting. An MCP call is not a cheaper way into the service.
curl -X POST https://cleanmail.dev/mcp \
-H "Content-Type: application/json" \
-H "X-API-Key: $CLEANMAIL_API_KEY" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"my-agent","version":"1.0.0"}}}'
curl -X POST https://cleanmail.dev/mcp \
-H "Content-Type: application/json" \
-H "X-API-Key: $CLEANMAIL_API_KEY" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
The full manual for agents is agents.md, and it has the same three calls written out in full.
There is an official TypeScript SDK and command line client for this API. It has no runtime dependencies, its types are generated from the OpenAPI description above, and its test suite checks the live API against the SDK in both directions - so a stale SDK cannot ship.
npm install cleanmail-sdk
cleanmail-sdk on npm · skyradical/CleanMail-SDK on GitHub
import { CleanMailClient } from 'cleanmail-sdk';
const cleanmail = new CleanMailClient({ apiKey: process.env.CLEANMAIL_API_KEY });
const result = await cleanmail.verifyEmail({ email: 'user@example.com' });
console.log(result.deliverable); // true | false
console.log(result.reason); // valid | invalid | accepted | risky | unknown | spam_trap | blocked
console.log(result.mxRecord); // the mail exchanger, or null
console.log(result.riskLevel); // low | medium | high
The same client ships as a command line tool. It covers verification, batches, webhooks and your account.
npx cleanmail verify user@example.com
npx cleanmail demo user@example.com # free check, no key needed
npx cleanmail health
Every error carries an error message you can show a human, and most of them carry a code you can check in your own code.
Retry-After header, so it is worth waiting rather than retrying in a loop.
The account routes (/auth/*) are for the signed-in customer, not for your code, and they use the session token in the X-Session-Token header. They answer 401 when there is no session, 400 when the password or the confirmation code is wrong, and 429 when a limit such as the hourly key resend is used up.
| Plan | Single verify | Batch | Verifications/day | Price |
|---|---|---|---|---|
| Free | 1 req/s, burst 3 | 5 req/s, burst 20 | 50 | $0/mo |
| Starter | 2 req/s, burst 5 | 10 req/s, burst 50 | 300 | $9/mo |
| Pro | 3 req/s, burst 10 | 25 req/s, burst 100 | 1,500 | $39/mo |
| Business | 20 req/s, burst 50 | 50 req/s, burst 200 | 5,000 | $99/mo |
| Enterprise | 20 req/s, burst 50 | 50 req/s, burst 200 | 20,000 | $199/mo |
How the limits are enforced. The rate limiter counts per API key and keeps
its state in each worker process, so the effective allowance is four times the table. The
daily quota is different: it is counted in the database, so it is exact, it is the same for
every worker, and it survives a restart. A request over the daily quota is refused with
429 DAILY_LIMIT_EXCEEDED; a bad key is 403 INVALID_KEY. There is
no monthly cap.
429 RATE_LIMIT_DOMAINS, refused before any mail server is contacted./api/verify/quick or the demo endpoint.const response = await fetch('https://cleanmail.dev/api/verify', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'your_api_key'
},
body: JSON.stringify({
email: 'user@example.com'
})
});
const result = await response.json();
console.log(result);
// { success: true, email: 'user@example.com', deliverable: true,
// reason: 'valid', riskLevel: 'low', ... }
import requests
response = requests.post(
'https://cleanmail.dev/api/verify',
headers={'X-API-Key': 'your_api_key'},
json={'email': 'user@example.com'}
)
result = response.json()
print(result)
curl -X POST https://cleanmail.dev/api/verify \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key" \
-d '{"email": "user@example.com"}'
$ch = curl_init('https://cleanmail.dev/api/verify');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-API-Key: your_api_key'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'email' => 'user@example.com'
]));
$response = curl_exec($ch);
$result = json_decode($response, true);
Contact us at CleanMail.service@gmail.com for technical support or sales inquiries.