# Email verification

```http
POST https://api.qelka.com/v1/email
```

Verifies an email address and tells you whether mail to it will be delivered, with the reason. Costs 1 credit in either mode. Errors are not billed, and neither are checks that could not complete: a mailbox check that could not run, or DNS lookups that failed.

## Request

```json
{
  "email": "jane@example.com",
  "mode": "full",
  "fresh": false
}
```

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `email` | string | Yes | none | The address to verify, 1 to 320 characters. |
| `mode` | string | No | `full` | `full` runs every check, including the SMTP mailbox check. `fast` runs every check except the mailbox check. |
| `fresh` | boolean | No | `false` | `true` skips the 7-day result cache and runs the checks again. |

## Modes

| What | `full` | `fast` |
|---|---|---|
| Syntax, DNS, disposable, role and free provider lists, SPF and DMARC | Yes | Yes |
| SMTP mailbox check | Yes | No |
| Can return `deliverable` | Yes | No: the best a fast check can say is `unknown` with reason `smtp_not_checked` |
| Speed | Waits for the recipient's mail server, up to a few seconds | Does not contact the mail server |
| Credits | 1 | 1 |

Use `fast` where every second counts and you only need to catch typos, dead domains and disposable inboxes. Use `full` when you need to know that the mailbox exists.

## Response

```json
{
  "id": "lkp_01M84BQ0P685M4955R9BRN1V99",
  "object": "email",
  "input": "jane@example.com",
  "status": "deliverable",
  "reason": "accepted_email",
  "did_you_mean": null,
  "checks": {
    "syntax": true,
    "mx": true,
    "smtp": true,
    "catch_all": false,
    "disposable": false,
    "role": false,
    "free_provider": false
  },
  "domain": { "name": "example.com", "spf": true, "dmarc": true },
  "score": 100,
  "credits_used": 1,
  "cached": false
}
```

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this lookup: `lkp_` and 26 characters. |
| `object` | string | Always `email`. |
| `input` | string | The `email` value you sent. |
| `status` | string | `deliverable`, `undeliverable`, `risky` or `unknown`. See [statuses](#statuses). |
| `reason` | string | Why the status was given. See [reasons](#reasons). |
| `did_you_mean` | string or null | A suggested correction when the domain looks like a typo of a common one, such as `jane@gmail.com` for `jane@gmial.com`. Null when there is no suggestion. |
| `checks` | object | The result of each check. |
| `checks.syntax` | boolean | `true` when the address is well formed. |
| `checks.mx` | boolean or null | `true` when the domain has MX records naming mail servers. `false` when it has none, or publishes a null MX record. Null when it could not be checked, for example after a syntax failure or a DNS error. |
| `checks.smtp` | boolean or null | `true` when the mail server accepted the mailbox, `false` when it rejected it. Null when the mailbox check did not run or got no clear answer: `fast` mode, no mail server, greylisting, timeout, blocked check, unverifiable provider. |
| `checks.catch_all` | boolean or null | `true` when the domain accepts mail for any address, so a positive answer proves nothing about this mailbox. Null when it was not checked. |
| `checks.disposable` | boolean | `true` when the domain belongs to a disposable email service. |
| `checks.role` | boolean | `true` for role addresses that reach a function rather than a person, such as `info@`, `support@` or `sales@`. |
| `checks.free_provider` | boolean | `true` when the domain is a free consumer email provider. |
| `domain` | object | The domain of the address. |
| `domain.name` | string or null | The domain part of the address. Null when the address has no readable domain. |
| `domain.spf` | boolean or null | `true` when the domain publishes an SPF record (RFC 7208). Null when it was not checked. |
| `domain.dmarc` | boolean or null | `true` when the domain publishes a DMARC record (RFC 7489). Null when it was not checked. |
| `score` | integer | Quality score from 0 to 100, computed from the checks. See [Email quality score](/docs/email-score). |
| `credits_used` | integer | Credits debited for this call. `0` when the reason is `smtp_unavailable` or `dns_error`. |
| `cached` | boolean | `true` when the result was served from the 7-day cache. |

`domain.spf` and `domain.dmarc` report whether a record is published, not whether it is correct. [SPF, DKIM and DMARC explained](/docs/guides/spf-dkim-dmarc) shows how to check a record in depth.

## Statuses

| `status` | Meaning | What to do with it |
|---|---|---|
| `deliverable` | The mail server accepted this exact mailbox. | Accept. |
| `undeliverable` | Mail to this address will not be delivered: bad syntax, a domain that does not exist or cannot receive mail, or a mailbox the server rejected. | Reject, and show `did_you_mean` when there is one. |
| `risky` | The address may receive mail, but something makes it doubtful: a disposable inbox, a domain that accepts every address, or a full mailbox. | Decide by use case: see the reasons below. |
| `unknown` | The checks could not reach a conclusion. | Do not treat it as bad. Accept and confirm by other means, or check again later. |

`deliverable` always means the mail server accepted that exact mailbox. When a provider accepts every address or blocks checks, the answer is `unknown` with the reason `provider_unverifiable`, not a hopeful `deliverable`.

## Reasons

| `reason` | `status` | Meaning |
|---|---|---|
| `accepted_email` | `deliverable` | The mail server accepted the mailbox. |
| `invalid_syntax` | `undeliverable` | The address is not well formed. |
| `domain_not_found` | `undeliverable` | The domain does not exist in DNS. |
| `domain_no_mx` | `undeliverable` | The domain has no MX record. RFC 5321 lets senders fall back to the domain's address record in that case; the API treats such domains as unable to receive mail. |
| `domain_null_mx` | `undeliverable` | The domain publishes a null MX record (RFC 7505): it declares that it accepts no mail. |
| `mailbox_not_found` | `undeliverable` | The mail server said the mailbox does not exist. |
| `mailbox_full` | `risky` | The mail server said the mailbox is over its quota. Mail bounces until its owner makes room. |
| `mailbox_disabled` | `undeliverable` | The mail server said the mailbox is disabled. |
| `catch_all` | `risky` | The domain accepts every address, so this mailbox cannot be confirmed. |
| `disposable` | `risky` | The domain belongs to a disposable email service. |
| `smtp_not_checked` | `unknown` | `fast` mode: the mailbox check was skipped. |
| `smtp_unavailable` | `unknown` | The mailbox check could not run on our side. Not billed: `credits_used` is `0`. |
| `smtp_timeout` | `unknown` | The mail server did not answer in time. |
| `smtp_blocked` | `unknown` | The mail server refused to answer the check. |
| `greylisted` | `unknown` | The mail server asked to try again later, a technique called greylisting. |
| `provider_unverifiable` | `unknown` | The provider accepts every address or blocks checks, so the mailbox cannot be confirmed either way. |
| `dns_error` | `unknown` | DNS lookups for the domain failed, so it could not be checked. Not billed: `credits_used` is `0`. |

Role addresses keep the status their checks give them. Being a role address lowers the score, not the status.

## How the checks run

The checks run in this order:

1. **Syntax.** The address must be well formed.
2. **DNS.** The API looks up the MX records of the domain over DNS over HTTPS. A domain without MX records, or with a null MX record, is treated as unable to receive mail.
3. **Lists.** The domain is compared with a list of disposable email domains and a list of free providers; the part before the `@` with a list of role names.
4. **Domain authentication.** The API looks for an SPF record and a DMARC record.
5. **Mailbox (full mode only).** Our prober asks the mail server about the mailbox.

### The mailbox check never sends an email

The prober runs on a server we operate. It connects to the domain's mail server on port 25 and has the first half of a normal SMTP conversation:

```text
EHLO
MAIL FROM
RCPT TO
QUIT
```

It reads the server's answer to `RCPT TO`, the command that names the recipient, and leaves. It never sends `DATA`, so no message is ever delivered and the person behind the address sees nothing.

To detect catch-all domains, the prober also asks about a random address on the same domain. If the server accepts an address that cannot exist, it accepts everything, and the reason is `catch_all`.

Some servers answer the first attempt with a temporary refusal and expect a retry later. That is greylisting, reported as `unknown` with the reason `greylisted`. Check the address again later: results with a temporary reason are not cached, so the next request runs the mailbox check again.

## Examples

### Full verification

```bash
curl https://api.qelka.com/v1/email \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "jane@example.com"}'
```

```javascript
const response = await fetch('https://api.qelka.com/v1/email', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ email: 'jane@example.com' }),
  signal: AbortSignal.timeout(15000),
})
const result = await response.json()
```

The response is the one shown above. Give full-mode calls a client timeout of several seconds, as in this example: they wait for a mail server you do not control.

### Fast check of a disposable address

```bash
curl https://api.qelka.com/v1/email \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "jane.doe@mailinator.com", "mode": "fast"}'
```

```json
{
  "id": "lkp_01M84BQ2C93EV6ZQ1G69K3JAMG",
  "object": "email",
  "input": "jane.doe@mailinator.com",
  "status": "risky",
  "reason": "disposable",
  "did_you_mean": null,
  "checks": {
    "syntax": true,
    "mx": true,
    "smtp": null,
    "catch_all": null,
    "disposable": true,
    "role": false,
    "free_provider": false
  },
  "domain": { "name": "mailinator.com", "spf": true, "dmarc": true },
  "score": 50,
  "credits_used": 1,
  "cached": false
}
```

Values in the examples are illustrative.

## Errors

| Status | Type | When |
|---|---|---|
| 400 | [invalid_request](/docs/errors#invalid_request) | `email` is missing, empty or longer than 320 characters, `mode` is not `full` or `fast`, or the body has a field that is not listed above |
| 401 | [invalid_api_key](/docs/errors#invalid_api_key) | The key is missing, invalid or revoked |
| 402 | [insufficient_credits](/docs/errors#insufficient_credits) | Your balance is below 1 credit |
| 403 | [forbidden](/docs/errors#forbidden) | The key is restricted to other endpoints |
| 429 | [rate_limited](/docs/errors#rate_limited) | Too many requests; wait `Retry-After` seconds |
| 500 | [internal_error](/docs/errors#internal_error) | Unexpected error on our side; retry with backoff |

None of these responses is billed. An address that fails the checks is not an error: it returns `200` with a status and a reason.

## Related

- [Validate signup forms](/docs/guides/validate-signup-forms)
- [Clean an email list](/docs/guides/clean-an-email-list)
- [Block disposable email signups](/docs/guides/block-disposable-signups)
- Free tools: [email verifier](/tools/email-verifier), [disposable email checker](/tools/disposable-email-checker), [email syntax checker](/tools/email-syntax-checker), [MX lookup](/tools/mx-lookup)
