API guide
Validate email addresses with Go
The ValidatedMails API evaluates syntax, DNS routing, and mailbox reachability signals. Responses return a four-state status, a numeric score, and atrace_id for correlation and audits.
Overview
Submit an email address to /validate. The API returns a four-state verdict, a numeric confidence score, and metadata for traceability.
Use status for verdict routing, is_valid for boolean checks, andtrace_id to join logs and support cases.
Quickstart
Make a single GET request to /validate with query parameters.
GET https://api.validatedmails.com/validate/?email=ada@acme.com&token=YOUR_API_TOKENUse POST with a JSON body when you prefer payload-style requests. Both styles return the same response payload.
Go example (GET)
Build the request explicitly, set timeouts, and decode JSON into a typed struct.
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
)
type ValidationResponse struct {
Status string `json:"status"`
IsValid bool `json:"is_valid"`
Score int `json:"score"`
TraceID string `json:"trace_id"`
}
func validateEmailGet(
ctx context.Context,
client *http.Client,
baseURL string,
token string,
email string,
) (ValidationResponse, error) {
endpoint, err := url.Parse(baseURL + "/validate/")
if err != nil {
return ValidationResponse{}, err
}
query := endpoint.Query()
query.Set("email", email)
query.Set("token", token)
endpoint.RawQuery = query.Encode()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
if err != nil {
return ValidationResponse{}, err
}
req.Header.Set("Accept", "application/json")
resp, err := client.Do(req)
if err != nil {
return ValidationResponse{}, err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
body, _ := io.ReadAll(resp.Body)
return ValidationResponse{}, fmt.Errorf("unexpected status %d: %s", resp.StatusCode, strings.TrimSpace(string(body)))
}
var payload ValidationResponse
if err := json.NewDecoder(resp.Body).Decode(&payload); err != nil {
return ValidationResponse{}, err
}
return payload, nil
}
func main() {
client := &http.Client{Timeout: 5 * time.Second}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
result, err := validateEmailGet(ctx, client, "https://api.validatedmails.com", "YOUR_API_TOKEN", "ada@acme.com")
if err != nil {
panic(err)
}
fmt.Println("status:", result.Status)
fmt.Println("is_valid:", result.IsValid)
fmt.Println("score:", result.Score)
fmt.Println("trace_id:", result.TraceID)
switch result.Status {
case "valid":
fmt.Println("Accept signup")
case "invalid":
fmt.Println("Reject signup")
default:
fmt.Println("Risky or unknown: apply your review or confirmation policy")
}
}Go example (POST)
Send a JSON body with the email address. The response schema is identical to the GET version.
package main
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
)
type ValidationResponse struct {
Status string `json:"status"`
IsValid bool `json:"is_valid"`
Score int `json:"score"`
TraceID string `json:"trace_id"`
}
func validateEmailPost(
ctx context.Context,
client *http.Client,
baseURL string,
token string,
email string,
) (ValidationResponse, error) {
payload, err := json.Marshal(map[string]string{"email": email})
if err != nil {
return ValidationResponse{}, err
}
endpoint := fmt.Sprintf("%s/validate?token=%s", baseURL, url.QueryEscape(token))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewReader(payload))
if err != nil {
return ValidationResponse{}, err
}
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
return ValidationResponse{}, err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
body, _ := io.ReadAll(resp.Body)
return ValidationResponse{}, fmt.Errorf("unexpected status %d: %s", resp.StatusCode, strings.TrimSpace(string(body)))
}
var payloadResp ValidationResponse
if err := json.NewDecoder(resp.Body).Decode(&payloadResp); err != nil {
return ValidationResponse{}, err
}
return payloadResp, nil
}
func main() {
client := &http.Client{Timeout: 5 * time.Second}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
result, err := validateEmailPost(ctx, client, "https://api.validatedmails.com", "YOUR_API_TOKEN", "ada@acme.com")
if err != nil {
panic(err)
}
fmt.Println("status:", result.Status)
fmt.Println("is_valid:", result.IsValid)
fmt.Println("score:", result.Score)
fmt.Println("trace_id:", result.TraceID)
}Response usage
Treat valid, risky, invalid, and unknown as normal states and branch explicitly.
switch result.Status {
case "valid":
// Accept signup or release the record to onboarding.
case "invalid":
// Reject to prevent hard bounces.
default:
// For risky or unknown: request confirmation or queue for review.
}Integration patterns
Server-side signup handler
- Validate on submission before creating the account.
- Accept
validand blockinvalidimmediately. - Route
unknownto confirmation or manual review.
Background job / batch flow
- Use
POST /validate/batchfor queued lists and worker jobs. - Submit full batches where possible and keep explicit client timeouts.
- Run parallel batch workers to reach your target throughput.
- Use Bulk validation jobs for very large CSV imports and full-list processing.
- Retry HTTP
429, HTTP5xx, network errors, and client timeouts with bounded backoff. HonorRetry-Afterwhen present. - Persist
trace_idwith the result for audits. - Segment by
statusto drive follow-up actions.