Code examples

PHP

<?php
$ch = curl_init('https://email-validation-api.net/api/v1/validate');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer ' . getenv('EMAILVAL_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['email' => 'user@example.com']),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);

if ($data['valid'] && $data['confidence'] === 'verified') {
    echo "Email confirmed existing.";
} elseif ($data['valid']) {
    echo "Probably valid (SMTP not confirmable).";
} else {
    echo "Invalid: {$data['reason']}";
}

Python

import os, requests

r = requests.post(
    "https://email-validation-api.net/api/v1/validate",
    headers={"Authorization": f"Bearer {os.environ['EMAILVAL_API_KEY']}"},
    json={"email": "user@example.com"},
    timeout=10,
)
r.raise_for_status()
data = r.json()

if data["valid"] and data["confidence"] == "verified":
    print("Confirmed")
elif data["valid"]:
    print("Probably valid (SMTP not confirmable)")
else:
    print(f"Invalid: {data['reason']}")

Node.js (native fetch)

const res = await fetch('https://email-validation-api.net/api/v1/validate', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.EMAILVAL_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ email: 'user@example.com' }),
});
const data = await res.json();

if (data.valid && data.confidence === 'verified') {
  console.log('Confirmed');
} else if (data.valid) {
  console.log('Probably valid');
} else {
  console.log(`Invalid: ${data.reason}`);
}

Ruby

require 'net/http'
require 'json'

uri = URI('https://email-validation-api.net/api/v1/validate')
res = Net::HTTP.post(uri,
  { email: 'user@example.com' }.to_json,
  'Authorization' => "Bearer #{ENV['EMAILVAL_API_KEY']}",
  'Content-Type'  => 'application/json',
)
data = JSON.parse(res.body)
puts data['valid'] && data['confidence'] == 'verified' ? 'Confirmed' : "Probably: #{data['reason']}"

Go

package main

import (
    "bytes"
    "encoding/json"
    "net/http"
    "os"
)

func main() {
    body, _ := json.Marshal(map[string]string{"email": "user@example.com"})
    req, _ := http.NewRequest("POST",
        "https://email-validation-api.net/api/v1/validate", bytes.NewReader(body))
    req.Header.Set("Authorization", "Bearer "+os.Getenv("EMAILVAL_API_KEY"))
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()

    var data map[string]any
    json.NewDecoder(resp.Body).Decode(&data)
    // ... your logic
}

Typical use cases

Use case Endpoint Behavior
Signup form POST /api/v1/validate Single email, low latency
Contact sync (≤200 emails) POST /api/v1/validate-bulk One call, all results in ~20s
Large list cleaning (≤10k) POST /api/v1/validate-async Async + optional webhook

Full validation (syntax, MX, SMTP, disposable, role-based, typo) runs on every call. Same email re-validated within an hour is served from our cache in under 10 ms.