API guide
Validate email addresses with Rust
The ValidatedMails API evaluates syntax, routing, and mailbox reachability. Responses include a four-state status, a numeric score, and atrace_id for traceability.
Overview
Send an email address to /validate and receive a structured verdict and metadata for logging and downstream workflows.
Use status for four-state verdict routing, is_valid as a boolean convenience, and trace_id to correlate 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_TOKENRust example (GET)
Use reqwest with explicit timeouts and deserialize into a typed struct.
use reqwest::Client;
use serde::Deserialize;
use std::time::Duration;
#[derive(Debug, Deserialize)]
struct ValidationResponse {
status: String,
is_valid: bool,
score: i32,
trace_id: String,
}
async fn validate_email_get(
client: &Client,
base_url: &str,
token: &str,
email: &str,
) -> Result<ValidationResponse, String> {
let response = client
.get(format!("{}/validate/", base_url))
.query(&[("email", email), ("token", token)])
.send()
.await
.map_err(|err| {
if err.is_timeout() {
format!("request timed out: {}", err)
} else {
format!("network error: {}", err)
}
})?;
if !response.status().is_success() {
let status = response.status();
let body = response.text().await.unwrap_or_default();
return Err(format!("unexpected status {}: {}", status, body.trim()));
}
response
.json::<ValidationResponse>()
.await
.map_err(|err| format!("invalid json: {}", err))
}
#[tokio::main]
async fn main() {
let client = Client::builder()
.timeout(Duration::from_secs(5))
.build()
.expect("client");
let result = validate_email_get(
&client,
"https://api.validatedmails.com",
"YOUR_API_TOKEN",
"ada@acme.com",
)
.await;
match result {
Ok(payload) => {
println!("status: {}", payload.status);
println!("is_valid: {}", payload.is_valid);
println!("score: {}", payload.score);
println!("trace_id: {}", payload.trace_id);
match payload.status.as_str() {
"valid" => println!("Accept signup"),
"invalid" => println!("Reject signup"),
_ => println!("Risky or unknown: apply your review or confirmation policy"),
}
}
Err(err) => {
eprintln!("request failed: {}", err);
}
}
}Rust example (POST)
Send the email address in a JSON body using serde_json. The response schema matches the GET variant.
use reqwest::Client;
use serde::Deserialize;
use serde_json::json;
use std::time::Duration;
#[derive(Debug, Deserialize)]
struct ValidationResponse {
status: String,
is_valid: bool,
score: i32,
trace_id: String,
}
async fn validate_email_post(
client: &Client,
base_url: &str,
token: &str,
email: &str,
) -> Result<ValidationResponse, String> {
let response = client
.post(format!("{}/validate", base_url))
.query(&[("token", token)])
.json(&json!({ "email": email }))
.send()
.await
.map_err(|err| {
if err.is_timeout() {
format!("request timed out: {}", err)
} else {
format!("network error: {}", err)
}
})?;
if !response.status().is_success() {
let status = response.status();
let body = response.text().await.unwrap_or_default();
return Err(format!("unexpected status {}: {}", status, body.trim()));
}
response
.json::<ValidationResponse>()
.await
.map_err(|err| format!("invalid json: {}", err))
}
#[tokio::main]
async fn main() {
let client = Client::builder()
.timeout(Duration::from_secs(5))
.build()
.expect("client");
let result = validate_email_post(
&client,
"https://api.validatedmails.com",
"YOUR_API_TOKEN",
"ada@acme.com",
)
.await;
match result {
Ok(payload) => {
println!("status: {}", payload.status);
println!("is_valid: {}", payload.is_valid);
println!("score: {}", payload.score);
println!("trace_id: {}", payload.trace_id);
}
Err(err) => {
eprintln!("request failed: {}", err);
}
}
}Response usage
Treat valid, risky, invalid, and unknown as normal states and branch explicitly.
match result.status.as_str() {
"valid" => {
// Accept signup or release the record to onboarding.
}
"invalid" => {
// Reject to prevent hard bounces.
}
_ => {
// For risky or unknown: request confirmation or queue for review.
}
}Integration patterns
Server request handler
- Validate on submission before creating or updating the record.
- Accept
validand blockinvalidimmediately. - Route
unknownto confirmation or manual review.
Background worker / batch job
- 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 results for audits. - Segment by
statusto drive follow-up actions.