{
  "openapi": "3.1.0",
  "info": {
    "title": "402 Guard",
    "version": "0.2.0",
    "description": "Small, machine-readable safety and live domain-intelligence checks for autonomous agents.",
    "contact": {
      "url": "https://x402.momentbolt.com"
    },
    "x-guidance": "Choose /api/lint for x402 payment-policy validation or /api/domain-audit for current DNS and email-security posture. An unauthenticated POST returns the x402 payment challenge. Pay the advertised USDC amount on Base mainnet with a compatible x402 client, then retry with PAYMENT-SIGNATURE."
  },
  "servers": [
    {
      "url": "https://x402.momentbolt.com"
    }
  ],
  "paths": {
    "/api/lint": {
      "post": {
        "operationId": "lintX402PaymentRequirements",
        "summary": "Lint x402 payment requirements against caller policy",
        "description": "Checks version, network, Base USDC asset, recipient, price, timeout, EIP-712 domain, and duplicates. Payment uses x402 v2 exact settlement on Base mainnet.",
        "tags": [
          "payment safety"
        ],
        "security": [
          {
            "x402Payment": []
          }
        ],
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.001"
          },
          "network": "eip155:8453",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x580f3a792F06BCFa30c2b301c60e0F424768ebF7"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LintRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Paid lint report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LintReport"
                }
              }
            }
          },
          "400": {
            "description": "Payment verified but request JSON or lint input is invalid"
          },
          "402": {
            "description": "x402 payment required",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded x402 v2 payment requirements",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "Request exceeds 64 KiB"
          },
          "502": {
            "description": "Payment facilitator unavailable"
          }
        }
      }
    },
    "/api/domain-audit": {
      "post": {
        "operationId": "auditDomainSecurityPosture",
        "summary": "Audit live DNS and email-security posture for one domain",
        "description": "Queries a trusted DNS-over-HTTPS resolver for A, AAAA, MX, NS, TXT, CAA, and DMARC records, then grades SPF, DMARC, DNSSEC authentication, mail routing, and certificate-authority restrictions. Payment uses x402 v2 exact settlement on Base mainnet.",
        "tags": [
          "domain intelligence",
          "email security"
        ],
        "security": [
          {
            "x402Payment": []
          }
        ],
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.002"
          },
          "network": "eip155:8453",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x580f3a792F06BCFa30c2b301c60e0F424768ebF7"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainAuditRequest"
              },
              "examples": {
                "domain": {
                  "value": {
                    "domain": "example.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Paid point-in-time domain audit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainAuditReport"
                }
              }
            }
          },
          "400": {
            "description": "Payment verified but request JSON or domain is invalid"
          },
          "402": {
            "description": "x402 payment required",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded x402 v2 payment requirements",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "Request exceeds 4 KiB"
          },
          "502": {
            "description": "Payment facilitator or DNS resolver unavailable; a verified payment is not settled"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "x402Payment": {
        "type": "apiKey",
        "in": "header",
        "name": "PAYMENT-SIGNATURE",
        "description": "x402 v2 payment payload returned by a compatible client after reading the 402 challenge."
      }
    },
    "schemas": {
      "LintRequest": {
        "type": "object",
        "required": [
          "paymentRequired"
        ],
        "properties": {
          "paymentRequired": {
            "type": "object",
            "description": "x402 v2 PaymentRequired envelope",
            "additionalProperties": true
          },
          "policy": {
            "type": "object",
            "properties": {
              "allowedNetworks": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "allowedAssets": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "allowedPayTo": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "maxAmountUsd": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "maxTimeoutSeconds": {
                "type": "integer",
                "minimum": 1
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "LintReport": {
        "type": "object",
        "required": [
          "ok",
          "verdict",
          "riskScore",
          "issues",
          "summary"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "verdict": {
            "type": "string",
            "enum": [
              "pass",
              "review",
              "reject"
            ]
          },
          "riskScore": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "summary": {
            "type": "object"
          }
        },
        "additionalProperties": true
      },
      "DomainAuditRequest": {
        "type": "object",
        "required": [
          "domain"
        ],
        "properties": {
          "domain": {
            "type": "string",
            "minLength": 3,
            "maxLength": 253,
            "description": "ASCII or punycode domain name without a scheme, port, path, or query"
          }
        },
        "additionalProperties": false
      },
      "DomainAuditReport": {
        "type": "object",
        "required": [
          "ok",
          "domain",
          "grade",
          "score",
          "posture",
          "findings",
          "records"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "domain": {
            "type": "string"
          },
          "grade": {
            "type": "string",
            "enum": [
              "A",
              "B",
              "C",
              "D",
              "F"
            ]
          },
          "score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "posture": {
            "type": "object",
            "additionalProperties": true
          },
          "findings": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "severity",
                "code",
                "message"
              ],
              "additionalProperties": true
            }
          },
          "records": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      }
    }
  }
}
