{
  "openapi": "3.1.0",
  "info": {
    "title": "BriefGuard API",
    "version": "3.0.0",
    "description": "Deterministic brief-to-evidence acceptance audits paid per call with x402 v2."
  },
  "servers": [
    { "url": "https://briefguard-audit-mx.carlosrsaenzl.chatgpt.site" }
  ],
  "paths": {
    "/api/preview": {
      "post": {
        "summary": "Run a free preview for up to five requirements",
        "requestBody": { "$ref": "#/components/requestBodies/AuditRequest" },
        "responses": {
          "200": { "description": "Acceptance audit preview" },
          "400": { "description": "Invalid input" },
          "413": { "description": "Request exceeds 64 KB" }
        }
      }
    },
    "/api/audit": {
      "get": {
        "summary": "Read the machine contract and payment terms",
        "responses": { "200": { "description": "Service contract" } }
      },
      "post": {
        "summary": "Run a full deterministic acceptance audit",
        "description": "Requires an exact 5.25 USDC x402 v2 payment on Base mainnet.",
        "requestBody": { "$ref": "#/components/requestBodies/AuditRequest" },
        "responses": {
          "200": { "description": "Full acceptance audit" },
          "402": {
            "description": "x402 payment required",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded x402 v2 PaymentRequired payload",
                "schema": { "type": "string" }
              }
            }
          },
          "400": { "description": "Invalid input" },
          "413": { "description": "Request exceeds 64 KB" }
        }
      }
    }
  },
  "components": {
    "requestBodies": {
      "AuditRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/AuditInput" },
            "example": {
              "title": "Launch-ready API",
              "brief": "- Must expose GET /health\n- Response time under 500 ms",
              "evidence": [
                { "requirementId": "R1", "statement": "GET /health returns 200", "source": "test:health" }
              ]
            }
          }
        }
      }
    },
    "schemas": {
      "AuditInput": {
        "type": "object",
        "properties": {
          "title": { "type": "string", "maxLength": 160 },
          "brief": { "type": "string" },
          "requirements": {
            "type": "array",
            "maxItems": 80,
            "items": {
              "oneOf": [
                { "type": "string" },
                {
                  "type": "object",
                  "required": ["text"],
                  "properties": {
                    "id": { "type": "string" },
                    "text": { "type": "string" },
                    "severity": { "type": "string", "enum": ["must", "should"] }
                  }
                }
              ]
            }
          },
          "evidence": {
            "type": "array",
            "maxItems": 160,
            "items": {
              "oneOf": [
                { "type": "string" },
                {
                  "type": "object",
                  "required": ["statement"],
                  "properties": {
                    "requirementId": { "type": "string" },
                    "statement": { "type": "string" },
                    "source": { "type": "string" }
                  }
                }
              ]
            }
          }
        },
        "anyOf": [
          { "required": ["brief"] },
          { "required": ["requirements"] }
        ]
      }
    }
  },
  "x-x402": {
    "version": 2,
    "scheme": "exact",
    "network": "eip155:8453",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "amount": "5250000",
    "payTo": "0x0B4d8e84803B7eEbD7B1134234DAd3a545198726"
  }
}
