Create a verification rule

Add an allow or block rule to the account’s verification engine.

Creates a rule that matches on an exact address, a domain, a top-level domain or an MX provider, and either force-allows or force-blocks matching addresses before any probe runs.

POST /v3/validate/rules

Body parameters

ParameterTypeRequiredDescription
rule_typestringRequiredMatch granularity: email, domain, tld or mx_provider.
valuestringRequiredThe address, domain, TLD or MX provider to match (1–320 chars). Lowercased and trimmed before storing.
actionstringRequiredblock short-circuits matching addresses to do_not_mail; allow forces them valid without a probe.
reasonstringOptionalWhy the rule exists (max 500 chars).

Responses

StatusDescription
201Created. The rule object: { id, rule_type, value, action, priority, reason, created_at }.
400Validation error — unknown rule_type or action, or an over-length value.
401Missing or invalid API key.

Code examples

cURL
curl -X POST https://api.wemail.io/v3/validate/rules \
  -H "Authorization: Bearer afn_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "rule_type": "domain", "value": "example.com", "action": "block", "reason": "Internal deny list" }'
Node.js
const res = await fetch("https://api.wemail.io/v3/validate/rules", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WEMAIL_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ "rule_type": "domain", "value": "example.com", "action": "block", "reason": "Internal deny list" }),
});
const data = await res.json();
Python
import os, requests

r = requests.post(
    "https://api.wemail.io/v3/validate/rules",
    headers={"Authorization": f"Bearer {os.environ['WEMAIL_API_KEY']}"},
    json={ "rule_type": "domain", "value": "example.com", "action": "block", "reason": "Internal deny list" },
)
data = r.json()