πŸ“š CleanMail API Documentation

Complete guide to integrating CleanMail's email verification API into your application.

πŸ” Authentication

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"}'
πŸ’‘ Finding your API Key: Sign in to your dashboard at cleanmail.dev/app.html to view your API key.

πŸ—‚οΈ Every endpoint

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.

Account and session

Verification

MethodPathNeedsWhat 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

Free demo (no API key)

MethodPathNeedsWhat 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

Batch jobs

MethodPathNeedsWhat it does
POST /api/demo/verify None (public) Verify one address without an API key

Webhooks

MethodPathNeedsWhat 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

Billing

MethodPathNeedsWhat 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

Account usage

MethodPathNeedsWhat 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

Service information

MethodPathNeedsWhat it does
GET /api/usage API key Current usage for the API key

API key check

MethodPathNeedsWhat it does
GET /api/features None (public) The features this deployment supports

Service

MethodPathNeedsWhat it does
GET /api/key/{key} None (public) Check whether an API key is valid

Other

MethodPathNeedsWhat it does
GET /health None (public) Liveness check
MethodPathNeedsWhat 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
πŸ’‘ The full text: every endpoint with its request fields and its answers is published as llms-full.txt and openapi.json. This index is generated from that same specification, so it cannot fall behind the service.

βœ… Verify Email

Verify an email address to check if it's valid, deliverable, and not a spam trap or disposable.

POST /api/verify

Request Body

email required string - Email address to verify

Example Request

{
  "email": "user@example.com"
}

Example Response

{
  "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"
}

Response Fields

deliverable boolean - true when the mail server accepted the recipient
reason string - valid, invalid, accepted, disposable, spam_trap, blocked, risky, busy, unknown or error
existenceConfirmed boolean - true when the answer settles whether the mailbox exists
exchanger string - the mail server that answered
valid and invalid are facts about the mailbox. disposable means the domain is on the disposable-domain list and spam_trap means the address is a known probe - both are answers, so both are charged. risky means the mailbox exists but the signals around it are poor. blocked means the domain is on the service's block list, so no mail server was contacted. Nothing was checked and nothing is charged.
accepted means the mail server took the recipient but would not tell us whether the mailbox exists - either the domain accepts every mailbox, or the provider answers 250 for every recipient, which Yahoo and AOL do on purpose. existenceConfirmed is false for accepted, busy and unknown: in those cases nobody said whether the mailbox is there.
busy means the mail server asked us to come back later (421/450/451/452) and nobody answered about the mailbox. The response carries retryAfterSeconds and a Retry-After header - ask again after that long. A busy or unknown check is not charged: you only pay for answers.
Every check also carries the headers an integrator needs: 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.
riskLevel string - "low", "medium", or "high"
riskScore number - 0 to 100
mxRecord string - the mail exchanger hostname, or null
isDisposable boolean - disposable email domain
isRoleAccount boolean - role account such as info@ or support@ (Starter and up)
isFreeProvider boolean - Gmail, Yahoo, Outlook and similar
isSpamTrap boolean - known spam trap domain
isGreylisted boolean - the server greylisted the message (Pro and up)
isCatchall boolean - the domain accepts every address (Pro and up)
dailyUsage number - verifications used today
dailyLimit number - verifications allowed today

πŸ”” Webhooks

Receive real-time notifications when email verifications complete.

Why Use Webhooks?

Webhooks enable asynchronous processing. Submit verification requests and receive results at your callback URL when processing completesβ€”perfect for high-volume applications.

How It Works

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": [ ... ]
}

Webhook Payload

{
  "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"
    }
  ]
}
πŸ’‘ Events: a finished batch arrives as 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.
πŸ’‘ A webhook fires for an inline batch: send the batch to 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.
πŸ’‘ Registrations are kept in the database: every worker process reads the same registry, so a 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}.
πŸ’‘ Your callback URL must be reachable from the internet: the callback is delivered by CleanMail, from our own network, so 127.0.0.1 means our server and not your machine. Register a public HTTPS URL that answers with a 2xx status.
πŸ’‘ Private and loopback addresses are refused: registering a callback that points at 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.
πŸ’‘ A failed delivery is retried: a network error, a timeout, 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.
πŸ’‘ The results are kept even if the callback fails: the 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.
πŸ’‘ Best Practice: Respond to webhooks with 200 OK immediately, then process asynchronously to avoid timeouts.

πŸ“‹ Batch Verification

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.

Batch vs Single Verification

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 Batch

POST /api/batch/upload

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"

CSV Format

Create a CSV with a single column of email addresses, one per line:

user@example.com
john.doe@company.com
sales@business.org

Check Batch Status

GET /api/batch/status/:jobId
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.

Get Batch History

GET /api/batch/history

Returns your recent batch jobs (last 20).

Download Results

GET /api/batch/download/:jobId
curl "https://cleanmail.dev/api/batch/download/abc123?key=your_api_key"

Cancel Batch Job

POST /api/batch/cancel/:jobId
curl -X POST https://cleanmail.dev/api/batch/cancel/abc123 \
  -H "X-API-Key: your_api_key"

Delete Batch Job

DELETE /api/batch/jobs/:jobId

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.

Batch Results CSV

When complete, download the CSV with these columns:

ColumnDescription
emailThe email address
deliverabletrue/false - the mail server accepted the recipient
reasonWhy valid or invalid
risk_levellow/medium/high
is_spamtrapSpam trap detected
is_disposableDisposable email domain
is_role_accountRole account (info@, support@)
is_free_providerGmail, Yahoo, Outlook, etc.
is_catchallCatch-all domain
has_dmarcDMARC record present
dmarc_policynone/quarantine/reject
has_spfSPF record present
spf_strictStrict SPF enforcement
domain_age_daysAge of domain in days
mx_recordMX server hostname
risk_score0-100 risk score
πŸ’‘ Tip: Use the Batch Upload Page for a visual interface to upload CSV files and monitor processing in real-time.

πŸ§ͺ Demo Endpoint

Try CleanMail without an API key! The demo endpoint is rate-limited but lets you test the service.

POST /api/demo/verify
curl -X POST https://cleanmail.dev/api/demo/verify \
  -H "Content-Type: application/json" \
  -d '{"email": "test@example.com"}'
⚠️ Limits: Demo endpoint is limited to 10 requests per minute per IP address, 100 per day per IP address, and 15 different email domains per day per IP address. Requests over a limit are rejected with HTTP 429. For production use, sign up for an API key.
🎁 Starter is free until further notice. New accounts get 300 verifications/day with no credit card. Need the Pro plan (1,500/day)? See the pricing and upgrade from your account.

πŸ’³ Billing & Subscription

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.

Check your subscription

GET /api/billing/subscription

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.

Manage your subscription

GET /api/billing/portal

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.

πŸ’‘ What the status means: 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.

🧩 OpenAPI & Postman

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.

GET /openapi.json

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.

πŸ’‘ Using the description: it covers verification, quick verification, batch, webhooks, usage and the account endpoints - the entire public API. Anything that reads OpenAPI 3.1 (Postman, Swagger UI, Bruno, Cursor, Continue, a code generator) can import it directly.

Try it here

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.

πŸ”Œ MCP

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:

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.

🧰 SDK & CLI

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

Using the client

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

Using the command line

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
πŸ’‘ Which should I use? The OpenAPI description if you are generating a client in another language, the Postman collection if you just want to try requests by hand, and the SDK if you are writing TypeScript or JavaScript.

❌ Error Codes

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.

400 Bad Request - MISSING_EMAIL, INVALID_JSON, INVALID_INPUT, INVALID_URL, PRIVATE_URL, BATCH_TOO_LARGE, INVALID_CODE or REASON_REQUIRED: the request was not one the service could act on. PRIVATE_URL means the callback URL points at a loopback, private or link-local host, which is refused. REASON_REQUIRED means an admin asked to block an account without saying why.
401 Unauthorized - MISSING_API_KEY: no API key was sent
403 Forbidden - INVALID_KEY, KEY_BLOCKED, EMAIL_NOT_VERIFIED, ACCOUNT_BLOCKED, ENRICH_LIMIT_REACHED or BLOCKED_IP: the key is not valid, not allowed, the address on the account has not confirmed its code yet, the account has been blocked (the body carries the reason), the enrichment allowance is used up, or this client address is on the block list
404 Not Found - no API key, webhook or job matches the request. The billing portal answers 404 with the code NO_SUBSCRIPTION when the account has never had a subscription.
409 Conflict - JOB_ACTIVE, ALREADY_VERIFIED, JOB_FILE_MISSING, NOTHING_TO_RETRY or JOB_BUSY: the batch job is still running (cancel it first, then delete it), the account has already confirmed its address so there is no code to send, the upload for the job is no longer on the box, every address in the list has already been checked, or a worker is already working on the job.
413 Payload Too Large - PAYLOAD_TOO_LARGE: the request body is over the limit
429 Rate Limited - RATE_LIMITED, RATE_LIMIT, RATE_LIMIT_DAILY, RATE_LIMIT_DOMAINS, DAILY_LIMIT_EXCEEDED or TOO_MANY_ATTEMPTS: too many requests, the daily quota is used up, the free validator has reached its limit of 15 different email domains for this IP address, this API key has reached its limit of different email domains for the day, or too many wrong codes were entered
500 Server Error - VERIFICATION_ERROR, ENRICH_ERROR or JOB_FILE_WRITE_FAILED: try again later
502 Bad Gateway - BILLING_PORTAL_FAILED or EMAIL_FAILED: the billing provider did not answer, or a verification code could not be handed to the mail server. Your plan is not affected.
503 Service Unavailable - BILLING_PORTAL_UNAVAILABLE, HASH_KEY_UNAVAILABLE, SERVICE_MAINTENANCE or FREE_VALIDATOR_PAUSED: the billing provider is not configured on the server, the demo service cannot hash the address, the whole service is paused for maintenance, or the free validator is paused on its own. Nothing was charged and nothing was stored. A paused answer carries a 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.

πŸ“¦ Plans & Limits

Free
$0
  • 50 verifications/day
  • MX and SMTP verification
  • Disposable detection
  • Risk scoring
Starter
$9/mo
  • 300 verifications/day
  • Everything on Free
  • Role account detection
Pro
$39/mo
  • 1,500 verifications/day
  • Everything on Starter
  • Catch-all detection
  • Greylist detection
Business
$99/mo
  • 5,000 verifications/day
  • Everything on Pro
  • Priority support
  • Higher rate limits
Enterprise
$199/mo
  • 20,000 verifications/day
  • Everything on Business
  • Same rate limits as Business

Rate limits

PlanSingle verifyBatchVerifications/dayPrice
Free1 req/s, burst 35 req/s, burst 2050$0/mo
Starter2 req/s, burst 510 req/s, burst 50300$9/mo
Pro3 req/s, burst 1025 req/s, burst 1001,500$39/mo
Business20 req/s, burst 5050 req/s, burst 2005,000$99/mo
Enterprise20 req/s, burst 5050 req/s, burst 20020,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.

Other limits

View full pricing details β†’

πŸ’» Code Examples

JavaScript / Node.js

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', ... }

Python

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

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"}'

PHP

$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);

πŸ“ž Need Help?

Contact us at CleanMail.service@gmail.com for technical support or sales inquiries.

Check our FAQ β†’