{
  "openapi": "3.1.1",
  "info": {
    "title": "E-mail Infrastructure Explorer API",
    "version": "1.0.0",
    "summary": "MX, SPF lookups, DMARC, DKIM, MTA-STS, TLS-RPT and BIMI for a domain, scored with fixes.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://emailinfrastructureexplorer.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "MX, SPF lookups, DMARC, DKIM, MTA-STS, TLS-RPT and BIMI for a domain, scored with fixes.",
        "description": "Checks how a domain receives and protects e-mail: MX hosts with priorities and addresses, SPF with a recursive DNS-lookup count across include: chains, DMARC policy and reporting, DKIM keys at ten common selectors, MTA-STS record and policy file, TLS-RPT and BIMI. Produces a transparent 100-point score and concrete DNS fixes. Works live or on pasted zone records.\n\nMethodology:\n- DNS: MX (+ A/AAAA of each exchange), TXT at the domain, _dmarc, <selector>._domainkey for default, google, selector1, selector2, k1, s1, s2, mail, dkim, mx, _mta-sts, _smtp._tls and default._bimi.\n- SPF (RFC 7208): include: and redirect= are followed recursively; include, a, mx, ptr, exists and redirect each cost one DNS lookup, more than 10 in total is a permerror; more than 2 void lookups is also an error.\n- DMARC (RFC 7489) policy, pct and rua. DKIM (RFC 6376): key type and RSA modulus length decoded from p=; empty p= means revoked. Real selectors are chosen by the sender and cannot be enumerated, so \"none found\" is not proof that DKIM is absent.\n- MTA-STS (RFC 8461): TXT v=STSv1 plus the policy at https://mta-sts.<domain>/.well-known/mta-sts.txt; each MX must match a policy mx: pattern. TLS-RPT (RFC 8460) v=TLSRPTv1 with rua. BIMI needs DMARC quarantine/reject at 100 %.\n- Score (100): MX 10, SPF 20, DMARC 25, DKIM 15, MTA-STS 15, TLS-RPT 10, BIMI 5. Domains with a null MX (no inbound mail) are scored only on SPF and DMARC, scaled to 100.",
        "tags": [
          "infrastructure"
        ],
        "x-mcp-tool": "email_infrastructure_explorer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailInfrastructureExplorerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Pasted records for a typical business domain",
                  "value": {
                    "mode": "paste",
                    "domain": "example.org",
                    "records": "; pasted DNS for example.org\n@                      MX   10 mx1.example.net.\n@                      MX   20 mx2.example.net.\nmx1.example.net.    A    192.0.2.10\nmx2.example.net.    A    192.0.2.20\n@                      TXT  \"v=spf1 include:_spf.example.net include:sendgrid.net ip4:198.51.100.0/24 ~all\"\n_spf.example.net.   TXT  \"v=spf1 ip4:192.0.2.0/24 include:_spf2.example.net -all\"\n_spf2.example.net.  TXT  \"v=spf1 a mx -all\"\n_dmarc                 TXT  \"v=DMARC1; p=quarantine; pct=100; rua=mailto:dmarc@example.org\"\nselector1._domainkey   TXT  \"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvO65ahmEjafCxJBT+BnCuE+pM97kMp7njI4Na2g3vJ3AIqbUS2lTQVRlUng5T7BKOAHVmKUnj2fWM+iRt5mQAZ649dKjdQwOPULKmoVMjGMH8SB3P6CYaxJrVgS+PGVtEFgcj8UADfED2ylfiZgAPw7Fx3PQxyfWbenvdEsLyjSyl/2fr/stYzeGvaRDjKd91UoPqZEBC3fyw5Eloyq5L/U2yCSJypPpFe04kC6i4OcIlx6bJUkJWMaodPyFd3x1wuS9jklXaF+yyZhBMIdQzNCyf20QM4lf/SjmyzMsyYs5ILkH4548cgWHuM+wGdGHf5GwI6dTFv0a90bL3hlLdQIDAQAB\"\n_mta-sts               TXT  \"v=STSv1; id=20261001T000000\"\n_smtp._tls             TXT  \"v=TLSRPTv1; rua=mailto:tlsrpt@example.org\"",
                    "mtaStsPolicy": "version: STSv1\nmode: testing\nmx: mx1.example.net\nmx: *.example.net\nmax_age: 604800"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailInfrastructureExplorerResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "EmailInfrastructureExplorerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "Mode",
            "type": "string",
            "enum": [
              "live",
              "paste"
            ],
            "default": "live"
          },
          "domain": {
            "title": "Domain",
            "type": "string",
            "maxLength": 253
          },
          "records": {
            "title": "DNS records (paste mode)",
            "description": "Zone-file lines: name [ttl] [IN] TYPE value. Use @ for the domain, relative names like _dmarc or selector1._domainkey, and a trailing dot for other domains (e.g. include targets).",
            "type": "string",
            "maxLength": 60000
          },
          "mtaStsPolicy": {
            "title": "MTA-STS policy file (paste mode, optional)",
            "type": "string",
            "maxLength": 10000
          }
        },
        "required": [
          "domain"
        ]
      },
      "EmailInfrastructureExplorerResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "domain",
              "mode",
              "score",
              "grade",
              "scoreItems",
              "mx",
              "nullMx",
              "spf",
              "dmarc",
              "dkim",
              "mtaSts",
              "tlsRpt",
              "bimi",
              "findings",
              "fixes"
            ],
            "properties": {
              "domain": {
                "type": "string"
              },
              "mode": {
                "type": "string",
                "enum": [
                  "live",
                  "paste"
                ]
              },
              "score": {
                "type": "integer"
              },
              "grade": {
                "type": "string"
              },
              "scoreItems": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "area",
                    "points",
                    "max",
                    "applicable",
                    "detail"
                  ],
                  "properties": {
                    "area": {
                      "type": "string"
                    },
                    "points": {
                      "type": "number"
                    },
                    "max": {
                      "type": "number"
                    },
                    "applicable": {
                      "type": "boolean"
                    },
                    "detail": {
                      "type": "string"
                    }
                  }
                }
              },
              "mx": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "priority",
                    "exchange",
                    "addresses"
                  ],
                  "properties": {
                    "priority": {
                      "type": "integer"
                    },
                    "exchange": {
                      "type": "string"
                    },
                    "addresses": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "nullMx": {
                "type": "boolean"
              },
              "spf": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "record",
                  "lookups",
                  "voidLookups",
                  "includes"
                ],
                "properties": {
                  "record": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "lookups": {
                    "type": "integer"
                  },
                  "voidLookups": {
                    "type": "integer"
                  },
                  "includes": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "domain",
                        "depth",
                        "record",
                        "lookups"
                      ],
                      "properties": {
                        "domain": {
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "record": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "lookups": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              },
              "dmarc": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "record",
                  "policy"
                ],
                "properties": {
                  "record": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "policy": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "dkim": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "selector",
                    "record",
                    "keyType",
                    "bits",
                    "revoked"
                  ],
                  "properties": {
                    "selector": {
                      "type": "string"
                    },
                    "record": {
                      "type": "string"
                    },
                    "keyType": {
                      "type": "string"
                    },
                    "bits": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "revoked": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "mtaSts": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "record",
                  "policyFetched",
                  "mode",
                  "mx",
                  "maxAge"
                ],
                "properties": {
                  "record": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "policyFetched": {
                    "type": "boolean"
                  },
                  "mode": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "mx": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "maxAge": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              },
              "tlsRpt": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "bimi": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "findings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "severity",
                    "area",
                    "finding"
                  ],
                  "properties": {
                    "severity": {
                      "type": "string",
                      "enum": [
                        "high",
                        "medium",
                        "low",
                        "info"
                      ]
                    },
                    "area": {
                      "type": "string"
                    },
                    "finding": {
                      "type": "string"
                    }
                  }
                }
              },
              "fixes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}