senapati
Documentation index

SPF Check

SPF tells receivers which hosts may send mail for a domain. This check fetches the domain's v=spf1 record, follows every include and redirect the way a receiver does, counts the DNS lookups against the limit of ten, collects the networks the whole tree authorises, and reports what a receiver would reject or ignore. Pass an address as ip_test to learn whether it is authorised to send.

POST/api/spf-checkCosts 2 creditsAPI key

Validate a domain's SPF record (2 credits)

What is checked

  • One record. A domain must publish exactly one v=spf1 TXT record; two is a permerror for every receiver.
  • Syntax per RFC 7208: mechanisms, qualifiers, networks, CIDR lengths, and modifiers. Unknown mechanisms are an error, unknown modifiers only a note.
  • The lookup budget. Every include, redirect, a, mx, ptr and exists in the whole tree costs one DNS lookup; receivers stop at ten. dns_lookups_num is the total, void_lookups_num the ones that returned nothing (receivers tolerate two).
  • Policy. +all authorises the whole internet; ?all gives no verdict; a record with neither all nor redirect leaves unlisted hosts neutral; ptr is deprecated.
  • Includes that point at a domain with no SPF record, or back into the chain, are errors.

Testing an address

With ip_test the record is evaluated for that address following RFC 7208's check_host: mechanisms in order, include recursively, a and mx resolved, redirect last.

ip_resultip_authorizedMeaning
passtrueA mechanism matched with + (or no) qualifier
failfalseMatched a - mechanism, typically -all
softfailfalseMatched a ~ mechanism; receivers mark, not reject
neutralfalseMatched ? or nothing matched and the record has no all
nonefalseThe domain publishes no SPF record
permerrornullThe record is invalid or over the lookup limit
temperrornullA DNS lookup did not complete
unsupportednullEvaluation reached a macro or ptr term, which this check does not expand

Issue codes

codetypeMeans
SPF_NOT_FOUNDerrorNo v=spf1 record
MULTIPLE_SPF_RECORDSerrorMore than one v=spf1 record at a domain in the tree
TOO_MANY_DNS_LOOKUPSerrorOver ten lookups across the tree
TOO_MANY_VOID_LOOKUPSwarningMore than two lookups returned nothing
PLUS_ALL_FOUNDerror+all (or a bare all) authorises every host
NEUTRAL_ALL_FOUNDwarning?all gives unlisted hosts no verdict
RECORD_TERMINATION_MISSINGwarningNo all mechanism and no redirect
PTR_DEPRECATEDwarningThe ptr mechanism is deprecated
INCLUDE_WITHOUT_SPF_RECORDerrorAn include or redirect target has no SPF record
INCLUDE_LOOPerrorA domain includes itself through the chain
DUPLICATE_INCLUDEwarningThe same include appears twice
UNSUPPORTED_MACROinfoA term uses macros; the IP test stopped there
DNS_LOOKUP_FAILEDerrorA lookup timed out or the resolver failed; the report is partial

Further codes cover individual syntax faults (INVALID_IP4_NETWORK, INVALID_CIDR_LENGTH, UNKNOWN_MECHANISM, MULTIPLE_REDIRECT_MODIFIERS and the like). Every issue carries a message written for the person fixing the record.

Request

JSON body
FieldTypeDescription
domain*stringSending domain whose SPF record to check (e.g. example.com)
ip_teststring | nullIPv4 or IPv6 address to evaluate against the record: is it authorised to send mail for the domain?

Authenticate with API key. Send it as the X-API-Key header.

curl -X POST "https://api.senapati.io/api/spf-check" \
  -H "X-API-Key: $SENAPATI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domain":"google.com","ip_test":"209.85.220.41"}'

Response

Every success is wrapped in { "data": … } with a request_id; the fields below describe data. See Errors for the failure shape.

response: 200 OKSPFCheckData
{
"request_id": "req_3b9e51c0",
"timestamp": "2026-10-21T09:30:12.418203+00:00",
"data": {
"domain": "google.com",
"has_spf_record": true,
"spf_record": "v=spf1 include:_spf.google.com ~all",
"spf_records_count": 1,
"spf_records_list": [
{
"record": "v=spf1 include:_spf.google.com ~all",
"origin": "google.com",
"chars_num": 35,
"use_macro": false,
"domains": [
"_spf.google.com"
],
"authorized_ips": {
"ipv4": [],
"ipv6": []
}
},
{
"record": "v=spf1 ip4:74.125.0.0/16 ip4:209.85.128.0/17 ip6:2001:4860:4864::/56 ip6:2404:6800:4864::/56 ip6:2607:f8b0:4864::/56 ip6:2800:3f0:4864::/56 ip6:2a00:1450:4864::/56 ip6:2c0f:fb50:4864::/56 ~all",
"origin": "_spf.google.com",
"chars_num": 192,
"use_macro": false,
"domains": [],
"authorized_ips": {
"ipv4": [
"74.125.0.0/16",
"209.85.128.0/17"
],
"ipv6": [
"2001:4860:4864::/56",
"2404:6800:4864::/56",
"2607:f8b0:4864::/56",
"2800:3f0:4864::/56",
"2a00:1450:4864::/56",
"2c0f:fb50:4864::/56"
]
}
}
],
"domains_extracted": [
"_spf.google.com"
],
"authorized_ips": {
"ipv4": [
"209.85.128.0/17",
"74.125.0.0/16"
],
"ipv6": [
"2001:4860:4864::/56",
"2404:6800:4864::/56",
"2607:f8b0:4864::/56",
"2800:3f0:4864::/56",
"2a00:1450:4864::/56",
"2c0f:fb50:4864::/56"
]
},
"dns_lookups_num": 1,
"void_lookups_num": 0,
"macros_found": false,
"issues_found": [],
"has_issues": false,
"spf_valid": true,
"lookup_failed": false,
"ip_test": "209.85.220.41",
"ip_result": "pass",
"ip_authorized": true,
"elapsed_ms": 326
}
}

spf_records_list holds every record in the tree with the domain it was fetched from; authorized_ips is the union of their ip4 and ip6 networks.

data · SPFCheckData
FieldTypeDescription
domain*string
has_spf_record*booleanTrue when a v=spf1 TXT record exists
spf_record*string | nullThe domain's own SPF record
spf_records_count*integerHow many v=spf1 records the domain publishes; more than one is an error
spf_records_list*SPFRecordDetail[]Every record in the tree, the domain's own first
↳ record*stringThe record text
↳ origin*stringDomain the record was fetched from
↳ chars_num*integerLength of the record in characters
↳ use_macro*booleanTrue when the record uses SPF macros
↳ domains*string[]Domains this record references through include and redirect
↳ authorized_ips*AuthorizedIPsip4 and ip6 networks listed in this record
↳ ipv4string[]
↳ ipv6string[]
domains_extracted*string[]All domains reached through include and redirect, in order
authorized_ips*AuthorizedIPsAll ip4 and ip6 networks across the tree, sorted
↳ ipv4string[]
↳ ipv6string[]
dns_lookups_num*integerTerms that cost a DNS lookup across the whole tree; receivers stop at 10 and return permerror
void_lookups_num*integerLookups that returned nothing while expanding the tree and, with ip_test, while evaluating; receivers tolerate at most 2
macros_found*booleanTrue when any record uses macros
issues_found*AuthIssue[]
↳ code*stringStable machine-readable code, e.g. PLUS_ALL_FOUND
↳ type*"error" | "warning" | "info"error: receivers reject or ignore the record; warning: it works but is weaker than it should be; info: a note, not a defect
↳ message*stringWhat was found and why it matters
has_issues*boolean
spf_valid*booleanA record exists and nothing in it makes receivers return permerror
lookup_failed*booleanTrue when a DNS query did not complete; the report is partial
ip_test*string | nullThe address evaluated, if one was given
ip_result*"pass" | "fail" | "softfail" | "neutral" | "none" | "permerror" | "temperror" | "unsupported" | nullRFC 7208 result for ip_test; 'unsupported' when the record needs macro expansion or the ptr mechanism, which this check does not do
ip_authorized*boolean | nullTrue on pass; false on fail, softfail, neutral or none; null when no ip_test was given or the record could not be evaluated
elapsed_msintegerdefault 0

Errors

  • 401missing or invalid API key / token
  • 402not enough credits on the account
  • 422the request body or a parameter failed validation
  • 429plan rate limit exceeded

Nested objects

data.spf_records_list[] · SPFRecordDetail
FieldTypeDescription
record*stringThe record text
origin*stringDomain the record was fetched from
chars_num*integerLength of the record in characters
use_macro*booleanTrue when the record uses SPF macros
domains*string[]Domains this record references through include and redirect
authorized_ips*AuthorizedIPsip4 and ip6 networks listed in this record
↳ ipv4string[]
↳ ipv6string[]
data.issues_found[] · AuthIssue
FieldTypeDescription
code*stringStable machine-readable code, e.g. PLUS_ALL_FOUND
type*"error" | "warning" | "info"error: receivers reject or ignore the record; warning: it works but is weaker than it should be; info: a note, not a defect
message*stringWhat was found and why it matters

Notes

  • A report with lookup_failed: true rests on a DNS query that did not complete; retry it before acting on it.
  • Macros (%{i} and friends) are detected and reported but not expanded, and ptr is not evaluated: the IP test answers unsupported rather than guess.
  • Expansion stops after twenty lookups even for a record far over the limit, so a pathological chain cannot run away.