SPF record parser API

Reads one SPF record as text with the SPF check's parser (RFC 7208): version, mechanisms with qualifiers and values, modifiers, syntax errors and the all policy, and counts the terms that need DNS lookups. Includes are not followed; the SPF check on a domain does that.

POST https://api.lookproof.dev/v1/mail/spf-parse

Updated 2026-10-09

Examples use the Base (eip155:8453) network.

Input

A JSON body with content-type: application/json.

NameTypeRequiredLimitsDescription
recordstringYes1–4096 charactersThe SPF record text, starting with v=spf1.

Example request

curl -i -X POST https://api.lookproof.dev/v1/mail/spf-parse \
  -H 'content-type: application/json' \
  -d '{"record": "v=spf1 mx include:_spf.example.com ~all"}'
import asyncio
import os

from eth_account import Account
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact import register_exact_evm_client


async def main() -> None:
    signer = EthAccountSigner(Account.from_key(os.environ["EVM_PRIVATE_KEY"]))
    client = register_exact_evm_client(x402Client(), signer, networks="eip155:8453")
    async with x402HttpxClient(client) as http:
        response = await http.post('https://api.lookproof.dev/v1/mail/spf-parse', json={'record': 'v=spf1 mx include:_spf.example.com ~all'})
        response.raise_for_status()
        print(response.json())


asyncio.run(main())
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.EVM_PRIVATE_KEY);
const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const response = await fetchWithPayment("https://api.lookproof.dev/v1/mail/spf-parse", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"record": "v=spf1 mx include:_spf.example.com ~all"}),
});
console.log(await response.json());

curl: unpaid request — returns 402 with the price (PAYMENT-REQUIRED). The Python and JavaScript clients pay it and send the request again. Only ordinary wallets (EOA) can pay; smart-contract wallets get a 402 without charge. See payments.

Example response

{
  "checked_at": "2026-10-24T12:00:00Z",
  "data": {
    "all_qualifier": "~",
    "dns_lookup_terms": 2,
    "is_spf": true,
    "notes": [
      "Each include and redirect is counted once here; the records they point to can need more DNS lookups. The SPF check on a domain counts the whole tree."
    ],
    "record": "v=spf1 mx include:_spf.example.com ~all",
    "redirect": null,
    "syntax_errors": [],
    "terms": [
      {
        "kind": "mechanism",
        "name": "mx",
        "qualifier": null,
        "raw": "mx",
        "value": null
      },
      {
        "kind": "mechanism",
        "name": "include",
        "qualifier": null,
        "raw": "include:_spf.example.com",
        "value": "_spf.example.com"
      },
      {
        "kind": "mechanism",
        "name": "all",
        "qualifier": "~",
        "raw": "~all",
        "value": null
      }
    ]
  },
  "endpoint": "mail.spf_parse",
  "findings": [
    {
      "code": "SPF_SOFTFAIL_ALL",
      "evidence": {
        "count": 1,
        "items": [
          {
            "term": "~all"
          }
        ]
      },
      "explanation": "Receivers decide how to handle mail that does not match the policy.",
      "message": "The SPF policy ends with softfail (~all).",
      "recommendation": "Confirm that all legitimate senders are covered before changing the policy.",
      "severity": "info"
    }
  ],
  "meta": {
    "cache_hit": false,
    "duration_ms": 42,
    "fresh_until": "2026-10-24T12:05:00Z",
    "observed_at": "2026-10-24T12:00:00Z",
    "resolver": null,
    "source": "offline"
  },
  "request_id": "req_aaaaaaaaaaaaaaaaaaaaaaaaaa",
  "schema_version": "1.0",
  "status": "info"
}

Response fields

FieldMeaning
request_idUnique id of this request. Quote it when you contact support.
endpointThe endpoint id, for example mail.spf.
schema_versionVersion of the response format, currently 1.0.
checked_atWhen the check ran (ISO 8601, UTC).
statusok, info, warning or error from the worst finding, or unknown when the check was incomplete. unknown is not an error in the domain.
dataThe check's own data. Its fields are listed below.
findingsWhat was found: code, severity, message, explanation and evidence.
metaDuration, cache use, resolver and how long the result stays fresh.

Fields in data

FieldType
recordstring
is_spfboolean
termsarray of SpfTerm
syntax_errorsarray of SpfSyntaxIssue
all_qualifierone of +, -, ~, ? or null
redirectstring or null
dns_lookup_termsinteger
notesarray of string

Status codes

StatusCodeMeaningDo you pay?
200—The result is delivered, also when it has negative findings.Yes: charged once per payment; redelivery of the same payment is free
402—Payment is required, or the attached payment was refused. The body states the price.No
400bad_requestThe request is malformed.No
409payment_in_progress, payment_bound_to_other_requestThis payment is already being processed, or it is bound to a different request. No new payment is taken.No
413payload_too_largeThe body is larger than 64 KB.No
422invalid_inputThe input failed validation on a request that carries a payment; nothing is charged. Without a payment, invalid input gets a 402 whose error field names the problem.No
429rate_limitedToo many requests from this IP address or payer.No
502check_failedThe check could not be completed.No
503busy, unavailable, payments_unavailableThe service is busy or temporarily unavailable.No
504deadline_exceededThe check ran out of time.No

Errors use the common error body. See errors.

Findings this endpoint can return

SPF (9)