Email verification API: real-time checks on a sign-up form (Node, Python, PHP)
Add a real-time email check to a sign-up form: one POST from your server, a decision on deliverable, timeouts that fail open, in Node, Python and PHP.
- By
- VerifyNGN team
- Reviewed by
- VerifyNGN team (fact-checked 2026-11-30)
- Published
A real-time email check on a sign-up form is one HTTP request from your server: send the address to the verification API, read the answer's deliverable field (yes, no, risky or unknown), and ask the person for another address only when it says no. Everything else, including a slow mail server, an error or a timeout, should let the sign-up through. Blocking a real customer costs more than one bad address.
This guide builds that check against the VerifyNGN API, with working code in Node.js, Python and PHP, and covers the parts most examples skip: where the key lives, how long to wait, and what to do with each error.
The call
curl -s https://api.verifyngn.com/v1/verify \
-H "Authorization: Bearer $VERIFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "ann.lee@acme.com"}'
- Endpoint:
POST https://api.verifyngn.com/v1/verifywith a JSON body{"email": "..."}. - Key:
Authorization: Bearer vk_live_..., created in the dashboard under API keys. A key can be limited to scopes; for a sign-up form, a key with only the checks scope is enough (it can call/v1/verify,/v1/verify/batch,/v1/findand/v1/feedback, but not lists or the account). - Optional fields:
max_age_days(0 to 90) sets how old a stored answer for the same address may be before it is checked again; without it, an answer up to 30 days old is reused.
The answer is a Result:
{
"email": "ann.lee@acme.com",
"status": "valid",
"reason": "accepted",
"score": 95,
"deliverable": "yes",
"explanation": "The mail server for acme.com confirmed this mailbox exists and does not accept made-up addresses.",
"did_you_mean": null,
"flags": {"role": false, "free": false, "disposable": false, "catch_all": false},
"domain": {"name": "acme.com", "provider": "microsoft", "mx": "acme-com.mail.protection.outlook.com", "accepts_all": false},
"smtp": {"code": 250, "enhanced": "2.1.5"},
"cached": false,
"checked_at": "2026-11-23T17:00:00Z",
"engine": "1.0"
}
For a form, three fields matter: deliverable (the decision), status (to word the message: invalid, disposable and so on) and did_you_mean (a typo fix such as gmial.com → gmail.com, never applied for you). Every field is in the field reference and every status and reason in Results.
Keep the key on the server
Call the API from your sign-up handler, not from the browser. Anything in front-end code can be read by any visitor, and a copied key spends your credits. The form posts to your server; your server calls VerifyNGN, decides, and answers the form.
What to do with each answer
deliverable | Typical cases | At sign-up |
|---|---|---|
yes | The mail server confirmed the mailbox | Accept |
no | No such mailbox, no mail server, a typo, a malformed or disposable address, or an address whose owner asked not to be checked (reason: "opted_out") | Ask for another address; offer did_you_mean when there is one (but see opted_out below) |
risky | A catch-all domain, a role inbox (info@), a full mailbox, a Microsoft 365 or Google domain that accepts every address | Accept; flag it for review if you like |
unknown | Greylisting, a timeout, a server that couldn't be reached | Accept; don't block a real person on an unknown |
One no is not about the address: reason: "opted_out" means its owner asked not to be checked, so nothing was checked. At sign-up that may be the owner, so let it through. The samples below do.
How long to wait
Some mail servers answer slowly, and greylisting asks the checker to come back later. When the mail server doesn't answer in time, the API returns 503 unavailable with Retry-After: 30 and refunds the credit; the check finishes on its own, so asking again later is usually answered from that result. A person filling in a form won't wait for any of that, so set your own timeout (the samples use 10 seconds) and accept the sign-up when it runs out. Your timeout doesn't stop the check: it finishes and is charged as usual (free if the answer is unknown). The confirmation email you send anyway is the final check.
Errors, and what the form should do
Errors are problem details (RFC 9457, application/problem+json) with a code for programs, a detail that says what to do, and a request_id.
| HTTP | code | Why | At sign-up |
|---|---|---|---|
| 400 | bad_request | The body isn't valid JSON | Fix your code |
| 401 | unauthorized | Missing or wrong key | Accept; alert yourself |
| 402 | insufficient_credits | The balance ran out | Accept; alert yourself and top up |
| 403 | forbidden | reason: "key_scope" (the key lacks the checks scope), email_unconfirmed (the account's email isn't confirmed yet) or account_suspended | Accept; fix the key or the account |
| 422 | validation_failed | The body is wrong (for example email isn't a string) | Fix your code |
| 429 | rate_limited | Over the per-key limit (120 requests a minute by default), or reason: "daily_quota"; Retry-After says how long to wait | Accept |
| 500 | server_error | Something failed on our side | Accept |
| 503 | unavailable | No answer in time; nothing was charged | Accept |
The rule for a form is simple: only a successful answer with deliverable: "no" (other than opted_out) blocks. Every error lets the person through, and you fix the cause on your side.
The code
Each sample is one function, checkSignupEmail(email), that returns whether to accept the address and, if not, a message and a suggestion. They use only what each language ships with (Python uses the common requests package) and read the key from the VERIFY_API_KEY environment variable.
Node.js
Node 20 or later, in an ES module; fetch is built in.
const API = "https://api.verifyngn.com/v1";
export async function checkSignupEmail(email) {
let res;
try {
res = await fetch(`${API}/verify`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.VERIFY_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ email }),
signal: AbortSignal.timeout(10_000), // a person is waiting: don't wait longer than this
});
} catch {
return { accept: true }; // a timeout or a network error: let them in
}
if (!res.ok) {
const problem = await res.json().catch(() => ({}));
console.warn("verification skipped:", res.status, problem.code, problem.detail);
return { accept: true }; // only a real "no" blocks
}
const r = await res.json().catch(() => null);
if (!r || r.deliverable !== "no" || r.reason === "opted_out") return { accept: true, result: r };
return {
accept: false,
suggestion: r.did_you_mean,
message: r.status === "disposable"
? "This looks like a temporary address. Please use a permanent one."
: r.did_you_mean
? `Did you mean ${r.did_you_mean}?`
: "This address can't receive email. Please check it.",
};
}
Python
Python 3.9 or later with requests (pip install requests).
import os
import requests
API = "https://api.verifyngn.com/v1"
def check_signup_email(email):
try:
res = requests.post(
f"{API}/verify",
headers={"Authorization": f"Bearer {os.environ.get('VERIFY_API_KEY', '')}"},
json={"email": email},
timeout=(3, 10), # connect, then read: a person is waiting
)
except requests.RequestException:
return {"accept": True} # a timeout or a network error: let them in
if not res.ok:
print("verification skipped:", res.status_code, res.text[:200])
return {"accept": True} # only a real "no" blocks
r = res.json()
if r["deliverable"] != "no" or r["reason"] == "opted_out":
return {"accept": True, "result": r}
if r["status"] == "disposable":
message = "This looks like a temporary address. Please use a permanent one."
elif r["did_you_mean"]:
message = f"Did you mean {r['did_you_mean']}?"
else:
message = "This address can't receive email. Please check it."
return {"accept": False, "suggestion": r["did_you_mean"], "message": message}
PHP
PHP 8 or later with the curl extension (on Debian or Ubuntu: apt install php-curl). Under PHP-FPM, environment variables are hidden by default (clear_env = yes): pass the key with env[VERIFY_API_KEY] in the pool configuration, or every check is silently skipped.
<?php
function checkSignupEmail(string $email): array
{
$ch = curl_init('https://api.verifyngn.com/v1/verify');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10, // a person is waiting: don't wait longer than this
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('VERIFY_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['email' => $email]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status !== 200) {
error_log("verification skipped: HTTP $status");
return ['accept' => true]; // a timeout or an error: only a real "no" blocks
}
$r = json_decode($body, true);
if (!is_array($r) || $r['deliverable'] !== 'no' || $r['reason'] === 'opted_out') {
return ['accept' => true, 'result' => $r];
}
if ($r['status'] === 'disposable') {
$message = 'This looks like a temporary address. Please use a permanent one.';
} elseif ($r['did_you_mean']) {
$message = "Did you mean {$r['did_you_mean']}?";
} else {
$message = "This address can't receive email. Please check it.";
}
return ['accept' => false, 'suggestion' => $r['did_you_mean'], 'message' => $message];
}
The API reference shows the same call in cURL, JavaScript and Python, plus the batch endpoint (up to 100 addresses in one request, answered in order) for imports.
Things that bite in production
- Double submits. A person who clicks twice sends two checks. Debounce the button, or remember the last answer for the address in the session.
- Checking on every keystroke. Check when the form is submitted (or when the field loses focus), not while the person types: each request is a check.
- The typo prompt. Show
did_you_meanas a question with a one-click "use this", and let the person keep what they typed. - Rate limits. 120 requests a minute per key by default; every authenticated answer carries
RateLimit-Limit,RateLimit-RemainingandRateLimit-Reset. A form rarely gets near it, but a bulk import through the same key can: use a separate key for imports. - Confirmation email. The API answers whether an address can receive mail, not whether the person typing it owns it. Keep double opt-in.
What it costs
- One credit per check. Unknown answers and malformed addresses are free, and so is a check that ends in
503. A check your own code stopped waiting for still runs and is charged like any other. - A reused answer (within
max_age_days) costs a credit like a fresh check. - 100 free credits when you confirm your email, then packs from $10 for 2,000 checks; credits don't expire.
- Without a card on file, a team can make 500 checks a day; with one, 10,000.
Already on ZeroBounce's API?
VerifyNGN also answers ZeroBounce's v2 endpoints with the same parameters and field names, so a form built on /v2/validate can switch by changing the host and the key. The switch guide has the details and the status map.
Try it first
Paste an address into the free email checker to see the status, the reason and the explanation you'll get from the API. The sign-up forms page has the whole flow on one page, and Errors every problem code.