APIVoid logo

SPF Validator API Reference

Validate the SPF record of a domain: check the record syntax, lookup count and common issues, and verify if an IP is authorized to send emails for the domain.

Service details and pricing: SPF Validator API

POSThttps://api.apivoid.com/v2/spf-validator
5 credits per successful requestPOST · JSON

Request example

Query the endpoint via an HTTPS POST request (replace YOUR_API_KEY_HERE with your API key):

curl
curl -X POST "https://api.apivoid.com/v2/spf-validator" \
     -H "Content-Type: application/json" \
     -H "X-API-Key: YOUR_API_KEY_HERE" \
     -d '{"host": "gmail.com"}'

The same request in PHP:

php
$host = 'gmail.com';

$apiKey = 'YOUR_API_KEY_HERE';

$curl = curl_init('https://api.apivoid.com/v2/spf-validator');
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'X-API-Key: ' . $apiKey]);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(['host' => $host]));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

if ($httpCode === 200) {
    $responseData = json_decode($response, true);
    print_r($responseData);
} else {
    print_r('An error occurred: '.$response);
}

Request parameters

Required

hoststringRequired

Host to submit, e.g. gmail.com.

Optional

ipteststring

IPv4 or IPv6 address to test: the response tells you whether it is authorized to send email for the domain.

Response example

A successful request returns HTTP 200 with a JSON body:

json · 200
{
    "host": "gmail.com",
    "has_spf_record": true,
    "dns_lookups_num": 4,
    "spf_record": "v=spf1 redirect=_spf.google.com",
    "spf_records_list": [
        {
            "record": "v=spf1 redirect=_spf.google.com",
            "origin": "gmail.com",
            "chars_num": 31,
            "use_macro": false,
            "domains": [
                "_spf.google.com"
            ]
        },
        {
            "record": "v=spf1 include:_netblocks.google.com include:_netblocks2.google.com include:_netblocks3.google.com ~all",
            "origin": "_spf.google.com",
            "chars_num": 103,
            "use_macro": false,
            "domains": [
                "_netblocks.google.com",
                "_netblocks2.google.com",
                "_netblocks3.google.com"
            ]
        },
        {
            "record": "v=spf1 ip4:35.190.247.0/24 ip4:64.233.160.0/19 ip4:66.102.0.0/20 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:74.125.0.0/16 ip4:108.177.8.0/21 ip4:173.194.0.0/16 ip4:209.85.128.0/17 ip4:216.58.192.0/19 ip4:216.239.32.0/19 ~all",
            "authorized_ips": {
                "ipv4": [
                    "35.190.247.0/24",
                    "64.233.160.0/19",
                    "66.102.0.0/20",
                    "66.249.80.0/20",
                    "72.14.192.0/18",
                    "74.125.0.0/16",
                    "108.177.8.0/21",
                    "173.194.0.0/16",
                    "209.85.128.0/17",
                    "216.58.192.0/19",
                    "216.239.32.0/19"
                ]
            },
            "origin": "_netblocks.google.com",
            "chars_num": 223,
            "use_macro": false
        },
        {
            "record": "v=spf1 ip6:2001:4860:4000::/36 ip6:2404:6800:4000::/36 ip6:2607:f8b0:4000::/36 ip6:2800:3f0:4000::/36 ip6:2a00:1450:4000::/36 ip6:2c0f:fb50:4000::/36 ~all",
            "authorized_ips": {
                "ipv6": [
                    "2001:4860:4000::/36",
                    "2404:6800:4000::/36",
                    "2607:f8b0:4000::/36",
                    "2800:3f0:4000::/36",
                    "2a00:1450:4000::/36",
                    "2c0f:fb50:4000::/36"
                ]
            },
            "origin": "_netblocks2.google.com",
            "chars_num": 154,
            "use_macro": false
        },
        {
            "record": "v=spf1 ip4:172.217.0.0/19 ip4:172.217.32.0/20 ip4:172.217.128.0/19 ip4:172.217.160.0/20 ip4:172.217.192.0/19 ip4:172.253.56.0/21 ip4:172.253.112.0/20 ip4:108.177.96.0/19 ip4:35.191.0.0/16 ip4:130.211.0.0/22 ~all",
            "authorized_ips": {
                "ipv4": [
                    "172.217.0.0/19",
                    "172.217.32.0/20",
                    "172.217.128.0/19",
                    "172.217.160.0/20",
                    "172.217.192.0/19",
                    "172.253.56.0/21",
                    "172.253.112.0/20",
                    "108.177.96.0/19",
                    "35.191.0.0/16",
                    "130.211.0.0/22"
                ]
            },
            "origin": "_netblocks3.google.com",
            "chars_num": 211,
            "use_macro": false
        }
    ],
    "domains_extracted": [
        "_spf.google.com",
        "_netblocks.google.com",
        "_netblocks2.google.com",
        "_netblocks3.google.com"
    ],
    "authorized_ips": {
        "ipv4": [
            "35.190.247.0/24",
            "64.233.160.0/19",
            "66.102.0.0/20",
            "66.249.80.0/20",
            "72.14.192.0/18",
            "74.125.0.0/16",
            "108.177.8.0/21",
            "173.194.0.0/16",
            "209.85.128.0/17",
            "216.58.192.0/19",
            "216.239.32.0/19",
            "172.217.0.0/19",
            "172.217.32.0/20",
            "172.217.128.0/19",
            "172.217.160.0/20",
            "172.217.192.0/19",
            "172.253.56.0/21",
            "172.253.112.0/20",
            "108.177.96.0/19",
            "35.191.0.0/16",
            "130.211.0.0/22"
        ],
        "ipv6": [
            "2001:4860:4000::/36",
            "2404:6800:4000::/36",
            "2607:f8b0:4000::/36",
            "2800:3f0:4000::/36",
            "2a00:1450:4000::/36",
            "2c0f:fb50:4000::/36"
        ]
    },
    "issues_found": [],
    "spf_valid": true,
    "has_issues": false,
    "macros_found": false,
    "ip_pass": true,
    "elapsed_ms": 58
}

Response fields

The fields returned in the JSON response:

hoststring

Host submitted for the SPF check.

has_spf_recordboolean

Returns true if TXT SPF1 record is found.

dns_lookups_numinteger

Number of DNS lookups performed.

spf_recordstring

TXT SPF1 record, e.g. v=spf1 redirect=_spf.google.com.

spf_records_listarray

Array with details of each recursively-analyzed SPF record.

spf_records_list[n] → recordstring

The SPF record analyzed.

spf_records_list[n] → originstring

Domain where this SPF record was found (followed via include or redirect).

spf_records_list[n] → chars_numinteger

Number of characters in the SPF record.

spf_records_list[n] → use_macroboolean

Returns true if this SPF record uses macros.

spf_records_list[n] → domainsarray

Domains referenced by this SPF record via include and redirect.

spf_records_list[n] → authorized_ips → ipv4array

IPv4 addresses and ranges authorized by this SPF record.

spf_records_list[n] → authorized_ips → ipv6array

IPv6 addresses and ranges authorized by this SPF record.

domains_extractedarray

Array of domains extracted from include and redirect modifier.

authorized_ipsobject

Authorized sender addresses, grouped into ipv4 and ipv6 arrays.

authorized_ips → ipv4array

All IPv4 addresses and ranges authorized to send email for the domain.

authorized_ips → ipv6array

All IPv6 addresses and ranges authorized to send email for the domain.

issues_foundarray

Array of issues found, the "code" field can be SPF_NOT_FOUND, MULTIPLE_SPF_RECORDS, PTR_DEPRECATED, UPPERCASE_CHARACTERS, PLUS_ALL_FOUND, RECORD_TERMINATION_MISSING, DATA_AFTER_ALL, DATA_AFTER_REDIRECT, MULTIPLE_FALLBACKS, TOO_MANY_DNS_LOOKUPS, MULTIPLE_SPFV1_ON_SAME_RECORD, DUPLICATE_INCLUDE.

spf_validboolean

Returns true if the SPF1 record is valid.

has_issuesboolean

Returns true if we found issues on the SPF record.

macros_foundboolean

Returns true if macros were found in any of the analyzed SPF records.

ip_passboolean

Returns true if the IP submitted via "iptest" is authorized (ignore this field if you didn't set "iptest").

elapsed_msinteger

Time taken to process the request, in milliseconds.