Skip to content

SDK

The official SDK is published on npm as tryverifyemail. You can also skip the SDK and call the REST API directly.

Zero dependencies. Runs on Node.js 18+, Bun, Deno and edge runtimes such as Cloudflare Workers. Ships ESM, CommonJS and type definitions.

Terminal window
npm install tryverifyemail
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").

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.

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

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.

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.

No SDK needed: any HTTP client works. Each example below verifies one address and waits up to 25 seconds for the verdict.

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

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.