{
  "openapi": "3.1.0",
  "info": {
    "title": "mono. AI Search Audit API",
    "version": "1.0.0",
    "description": "Free deterministic AEO audit of a public URL: 24 checks, a score from 0 to 100, and a top-3 fix list. The `b2a-readiness` profile adds a separate B2A readiness report (OpenAPI, structured price, x402 signals) without changing the AEO score. Rate limit: 5 requests per 10 minutes and 40 per day per IP; responses include `Retry-After`. The paid endpoint returns the same audit plus the full technical checklist for $1.00 USDC on Base via x402 v2 (`PAYMENT-REQUIRED` / `PAYMENT-SIGNATURE`); it needs no account. The paid B2A readiness report is ordered separately: https://getmono.site/agents/b2a-readiness-audit/",
    "contact": {
      "name": "mono.",
      "url": "https://getmono.site/",
      "email": "hello@getmono.site"
    }
  },
  "servers": [
    {
      "url": "https://getmono.site",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "audit",
      "description": "AEO / Web3 Trust / B2A readiness scanner"
    }
  ],
  "paths": {
    "/api/ai-search/audit": {
      "post": {
        "operationId": "runAiSearchAudit",
        "summary": "Run the free AI search audit for one URL",
        "description": "Fetches the URL's home page, robots.txt, llms.txt and sitemap.xml, then scores 24 deterministic checks. The endpoint is anonymous and rate-limited by IP. For profile `b2a-readiness` it also fetches `/openapi.json`, `/swagger.json`, `/api/openapi.json` and `/.well-known/openapi.json` on the same origin, and returns a separate `b2a` report.",
        "tags": ["audit"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit completed. A site that could not be read is still 200 with `readable: false`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON body or URL.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Request body larger than 10,000 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded for this IP.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until the next request is allowed.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "The target site could not be read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "The audit feature is disabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/ai-search/audit/paid": {
      "x-x402": {
        "version": 2,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "price": "$1.00",
        "discovery": "GET"
      },
      "get": {
        "operationId": "discoverPaidAudit",
        "summary": "x402 challenge for the paid audit (discovery)",
        "description": "Free discovery for agents and scanners: returns 402 with a base64 `PAYMENT-REQUIRED` header carrying an x402 v2 PaymentRequired object. The challenge performs no scan and accepts no payment; the same payment requirements are used by the paid POST.",
        "tags": ["audit"],
        "responses": {
          "402": {
            "description": "Payment required. The base64 `PAYMENT-REQUIRED` header carries the x402 v2 PaymentRequired challenge.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded PaymentRequired object (x402 v2).",
                "schema": { "type": "string" }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests from this IP.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until the next request is allowed.",
                "schema": { "type": "integer" }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "x402 payments are not configured on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "runPaidAiSearchAudit",
        "summary": "Paid audit: full 24-check JSON and B2A readiness report",
        "description": "Same deterministic scanner as the free endpoint, but the response includes the full technical checklist (`checks`) and is paid per call with x402 v2: $1.00 USDC on Base mainnet. No account, no subscription. Send `PAYMENT-SIGNATURE` (base64 PaymentPayload) after receiving 402; the server verifies it, runs the scan, and settles only after a successful 2xx response. Profile `b2a-readiness` adds the B2A report.",
        "tags": ["audit"],
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "description": "Base64-encoded x402 v2 PaymentPayload. Omit it to receive the 402 challenge.",
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Paid audit completed. `checks` is populated. The `PAYMENT-RESPONSE` header carries the settlement receipt.",
            "headers": {
              "PAYMENT-RESPONSE": {
                "description": "Base64-encoded SettlementResponse (x402 v2).",
                "schema": { "type": "string" }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON body or URL. The payment is not settled for an unsuccessful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required, or the attached payment is invalid. The base64 `PAYMENT-REQUIRED` header carries the x402 v2 challenge.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded PaymentRequired object (x402 v2).",
                "schema": { "type": "string" }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            }
          },
          "413": {
            "description": "Request body larger than 10,000 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests from this IP.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until the next request is allowed.",
                "schema": { "type": "integer" }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "The target site could not be read. The payment is not settled for an unsuccessful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "x402 payments are not configured on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AuditRequest": {
        "type": "object",
        "required": ["url"],
        "properties": {
          "url": {
            "type": "string",
            "description": "Public http(s) URL to audit.",
            "minLength": 3,
            "maxLength": 500,
            "examples": ["https://example.com"]
          },
          "profile": {
            "type": "string",
            "description": "Report profile. Omitted means `aeo`.",
            "enum": ["aeo", "web3-trust", "b2a-readiness"],
            "default": "aeo"
          }
        },
        "additionalProperties": false
      },
      "AuditResponse": {
        "type": "object",
        "required": [
          "ok",
          "version",
          "readable",
          "score",
          "band",
          "categories",
          "checks",
          "topIssues",
          "meta",
          "checkedAt",
          "url"
        ],
        "properties": {
          "ok": { "const": true },
          "version": { "type": "string", "examples": ["aeo-readiness-v1"] },
          "readable": { "type": "boolean" },
          "score": {
            "type": ["integer", "null"],
            "minimum": 0,
            "maximum": 100,
            "description": "AEO score; null when the site was not readable."
          },
          "band": {
            "type": ["string", "null"],
            "enum": ["critical", "watch", "stable", "strong", null]
          },
          "categories": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/CategoryResult" }
          },
          "checks": {
            "type": "array",
            "description": "Empty for guests: the technical checklist is a paid layer.",
            "items": { "$ref": "#/components/schemas/CheckResult" }
          },
          "topIssues": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/TopIssue" }
          },
          "meta": { "$ref": "#/components/schemas/AuditMeta" },
          "checkedAt": { "type": "string", "format": "date-time" },
          "url": {
            "type": "object",
            "required": ["requested", "final"],
            "properties": {
              "requested": { "type": "string", "format": "uri" },
              "final": { "type": "string", "format": "uri" }
            }
          },
          "access": {
            "type": "string",
            "enum": ["admin", "guest"]
          },
          "b2a": {
            "description": "B2A readiness report; only for the `b2a-readiness` profile.",
            "oneOf": [
              { "$ref": "#/components/schemas/B2aReport" },
              { "type": "null" }
            ]
          }
        }
      },
      "CheckResult": {
        "type": "object",
        "required": ["id", "category", "weight", "points", "status", "evidence"],
        "properties": {
          "id": { "type": "string" },
          "category": {
            "type": "string",
            "enum": ["discovery", "llms", "schema", "structure", "meta", "trust", "technical"]
          },
          "weight": { "type": "integer" },
          "points": { "type": "integer" },
          "status": {
            "type": "string",
            "enum": ["pass", "partial", "fail", "unavailable"]
          },
          "evidence": { "type": "string" }
        }
      },
      "CategoryResult": {
        "type": "object",
        "required": ["id", "weight", "points"],
        "properties": {
          "id": { "type": "string" },
          "weight": { "type": "integer" },
          "points": { "type": "integer" }
        }
      },
      "TopIssue": {
        "type": "object",
        "required": ["id", "points", "severity"],
        "properties": {
          "id": { "type": "string" },
          "points": { "type": "integer" },
          "severity": {
            "type": "string",
            "enum": ["high", "medium", "low"]
          }
        }
      },
      "AuditMeta": {
        "type": "object",
        "required": ["httpStatus", "jsRendered", "truncated"],
        "properties": {
          "httpStatus": { "type": "integer" },
          "jsRendered": { "type": "boolean" },
          "truncated": { "type": "boolean" },
          "cached": { "type": "boolean" },
          "cap": {
            "type": "integer",
            "description": "Score ceiling when crawler access is closed or the page is noindex."
          }
        }
      },
      "B2aReport": {
        "type": "object",
        "required": ["version", "score", "band", "checks", "topIssues", "meta"],
        "properties": {
          "version": { "const": "b2a-readiness-v1" },
          "score": {
            "type": ["integer", "null"],
            "minimum": 0,
            "maximum": 100
          },
          "band": {
            "type": ["string", "null"],
            "enum": ["critical", "watch", "stable", "strong", null]
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["id", "weight", "points", "status", "evidence"],
              "properties": {
                "id": {
                  "type": "string",
                  "enum": [
                    "b2a_api_spec",
                    "b2a_api_json",
                    "b2a_price_structured",
                    "b2a_price_visible",
                    "b2a_x402"
                  ]
                },
                "weight": { "type": "integer" },
                "points": { "type": "integer" },
                "status": {
                  "type": "string",
                  "enum": ["pass", "partial", "fail", "unavailable"]
                },
                "evidence": { "type": "string" }
              }
            }
          },
          "topIssues": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["id", "points", "severity"],
              "properties": {
                "id": { "type": "string" },
                "points": { "type": "integer" },
                "severity": {
                  "type": "string",
                  "enum": ["high", "medium", "low"]
                }
              }
            }
          },
          "meta": {
            "type": "object",
            "required": ["checkedAt", "sources", "truncated"],
            "properties": {
              "checkedAt": { "type": "string", "format": "date-time" },
              "sources": {
                "type": "array",
                "items": { "type": "string", "format": "uri" }
              },
              "truncated": { "type": "boolean" }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["ok", "error"],
        "properties": {
          "ok": { "const": false },
          "error": { "type": "string" }
        }
      },
      "PaymentRequirements": {
        "type": "object",
        "required": ["scheme", "network", "amount", "asset", "payTo"],
        "properties": {
          "scheme": { "type": "string", "examples": ["exact"] },
          "network": { "type": "string", "examples": ["eip155:8453"] },
          "amount": {
            "type": "string",
            "description": "Amount in atomic token units (USDC has 6 decimals).",
            "examples": ["1000000"]
          },
          "asset": {
            "type": "string",
            "description": "Token contract address. Base mainnet USDC is 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913.",
            "examples": ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"]
          },
          "payTo": {
            "type": "string",
            "description": "Recipient address. The live value comes from the deployment's X402_PAY_TO environment variable.",
            "examples": ["0x0000000000000000000000000000000000000000"]
          },
          "maxTimeoutSeconds": { "type": "integer", "minimum": 1 },
          "extra": { "type": "object" }
        }
      },
      "PaymentRequired": {
        "type": "object",
        "required": ["x402Version", "accepts"],
        "properties": {
          "x402Version": { "const": 2 },
          "error": { "type": "string" },
          "resource": {
            "type": "object",
            "properties": {
              "url": { "type": "string", "format": "uri" },
              "description": { "type": "string" },
              "mimeType": { "type": "string" },
              "serviceName": { "type": "string" },
              "tags": {
                "type": "array",
                "items": { "type": "string" }
              }
            }
          },
          "accepts": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/PaymentRequirements" }
          },
          "extensions": { "type": "object" }
        }
      },
      "SettlementResponse": {
        "type": "object",
        "required": ["success", "transaction", "network"],
        "properties": {
          "success": { "type": "boolean" },
          "transaction": {
            "type": "string",
            "description": "Settlement transaction hash; empty string when no transaction was broadcast."
          },
          "network": { "type": "string" },
          "payer": { "type": "string" },
          "amount": { "type": "string" },
          "errorReason": { "type": "string" },
          "errorMessage": { "type": "string" }
        }
      }
    }
  }
}
