SDK
The official SDK is published on npm as
tryverifyemail. You can also
skip the SDK and call the REST API directly.
Install
Section titled “Install”Zero dependencies. Runs on Node.js 18+, Bun, Deno and edge runtimes such as Cloudflare Workers. Ships ESM, CommonJS and type definitions.
npm install tryverifyemailQuick start
Section titled “Quick start”import { VerifyEmail } from "tryverifyemail";
const client = new VerifyEmail({ apiKey: process.env.VERIFYEMAIL_API_KEY });
const verification = await client.verify("jane@example.com");
if (verification.status === "completed") { console.log(verification.result.verdict); // "deliverable" | "undeliverable" | "risky" | "unknown"}apiKey defaults to the VERIFYEMAIL_API_KEY environment variable. CommonJS
works too: const { VerifyEmail } = require("tryverifyemail").
Methods
Section titled “Methods”| Method | API call | Returns |
|---|---|---|
verify(email, { timeout?, source?, idempotencyKey? }) |
POST /v1/email-verifications |
A completed or pending verification |
getVerification(id, { timeout? }) |
GET /v1/email-verifications/{id} |
A completed or pending verification |
listVerifications({ page?, pageSize? }) |
GET /v1/email-verifications |
One page of finished checks |
me() |
GET /v1/me |
Account, plan, credits and key |
bulk.create({ name? }) |
POST /v1/bulk-verifications |
The new job |
bulk.addItems(jobId, items) |
POST /v1/bulk-verifications/{jobId}/items |
Received / inserted counts |
bulk.commit(jobId) |
POST /v1/bulk-verifications/{jobId}/commit |
The job, now preparing |
bulk.get(jobId) |
GET /v1/bulk-verifications/{jobId} |
Progress and verdict tally |
bulk.listResults(jobId, { cursor?, limit? }) |
GET /v1/bulk-verifications/{jobId}/items |
One page of rows |
Responses are the API’s own JSON objects, typed. A completed verification is
{ id, status: "completed", result }, where result is
the result object.
Waiting for a verdict
Section titled “Waiting for a verdict”verify() waits up to timeout seconds (default 30) for the verdict. If the
mail server is slow it polls for you. If the check is still running when the
time is up, you get the pending verification back instead of an error:
const verification = await client.verify("jane@slow-domain.com", { timeout: 10 });
if (verification.status === "pending") { // The check keeps running on the server. Collect it later, at no extra cost. const later = await client.getVerification(verification.id, { timeout: 25 });}Errors
Section titled “Errors”Every failed call throws a VerifyEmailError with status, code and
message. A 429 is retried automatically after its Retry-After wait, up to
maxRetries times (default 2).
import { VerifyEmail, VerifyEmailError } from "tryverifyemail";
try { await client.verify("jane@example.com");} catch (error) { if (error instanceof VerifyEmailError && error.code === "insufficient_credits") { // Top up, then retry. }}code |
Status | When |
|---|---|---|
unauthorized |
401 |
The key is missing, revoked or unknown. |
insufficient_credits |
402 |
The balance is empty. Nothing was charged. |
account_frozen |
402 |
The account is frozen. |
rate_limited |
429 |
Still limited after the automatic retries. |
bad_request |
400 |
The request was malformed. |
network_error / timeout |
0 |
The API could not be reached or did not answer. |
An undeliverable verdict is not an error. See Errors for
every status the API returns.
Test keys
Section titled “Test keys”Use a test key (sk_test_…) while you
build. verify() returns a simulated result straight away, rotating through
every verdict, and uses no credits. Results carry test_mode: true.
Call the REST API directly
Section titled “Call the REST API directly”No SDK needed: any HTTP client works. Each example below verifies one address and waits up to 25 seconds for the verdict.
curl -X POST "https://api.tryverifyemail.com/v1/email-verifications?timeout=25" \ -H "Authorization: Bearer $VERIFYEMAIL_API_KEY" \ -H "Content-Type: application/json" \ -d '{"email":"jane@example.com"}'import os, requests
res = requests.post( "https://api.tryverifyemail.com/v1/email-verifications", params={"timeout": 25}, headers={"Authorization": f"Bearer {os.environ['VERIFYEMAIL_API_KEY']}"}, json={"email": "jane@example.com"},)body = res.json()if body["status"] == "completed": print(body["result"]["verdict"])$ch = curl_init('https://api.tryverifyemail.com/v1/email-verifications?timeout=25');curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . getenv('VERIFYEMAIL_API_KEY'), 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => json_encode(['email' => 'jane@example.com']),]);$body = json_decode(curl_exec($ch), true);if ($body['status'] === 'completed') { echo $body['result']['verdict'];}require "net/http"require "json"
uri = URI("https://api.tryverifyemail.com/v1/email-verifications?timeout=25")res = Net::HTTP.post( uri, { email: "jane@example.com" }.to_json, "Authorization" => "Bearer #{ENV['VERIFYEMAIL_API_KEY']}", "Content-Type" => "application/json",)body = JSON.parse(res.body)puts body["result"]["verdict"] if body["status"] == "completed"package main
import ( "bytes" "encoding/json" "fmt" "net/http" "os")
func main() { payload, _ := json.Marshal(map[string]string{"email": "jane@example.com"}) req, _ := http.NewRequest("POST", "https://api.tryverifyemail.com/v1/email-verifications?timeout=25", bytes.NewReader(payload)) req.Header.Set("Authorization", "Bearer "+os.Getenv("VERIFYEMAIL_API_KEY")) req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close()
var body struct { Status string `json:"status"` Result struct { Verdict string `json:"verdict"` } `json:"result"` } json.NewDecoder(res.Body).Decode(&body) fmt.Println(body.Status, body.Result.Verdict)}A 200 carries the verdict under result. A 202 means the check is still
running: poll GET /v1/email-verifications/{id} as shown in
Poll a pending verification. Errors are listed
in Errors.