{
  "openapi": "3.1.0",
  "info": {
    "title": "SourceMint API",
    "version": "1.2.0",
    "description": "Extract public web evidence, verify individual claims, or audit an answer against all of its cited sources. Paid per successful request with x402 USDC on Base.",
    "x-guidance": "Use POST /api/extract for $0.001, POST /api/verify-claim for $0.01, or POST /api/audit-citations for $0.05. Unpaid requests return an x402 v2 challenge on Base. Retry the identical request with PAYMENT-SIGNATURE after signing. Results include source hashes and use transparent lexical analysis rather than asserting guaranteed factual truth.",
    "contact": { "name": "SourceMint", "url": "https://sourcemint-api.nap6281.chatgpt.site" }
  },
  "servers": [{ "url": "https://sourcemint-api.nap6281.chatgpt.site" }],
  "paths": {
    "/api/demo/audit-citations": {
      "post": {
        "operationId": "demoCitationAudit",
        "summary": "Test the citation-audit response contract with a fixed input",
        "description": "Free integration demo. It accepts only the documented Example Domain input and returns illustrative output; it does not perform a live retrieval.",
        "tags": ["Demo"],
        "security": [],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["answer", "urls"], "properties": { "answer": { "const": "Example Domain is intended for illustrative examples and may be used without prior coordination." }, "urls": { "const": ["https://example.com"] } } } } } },
        "responses": { "200": { "description": "Fixed illustrative citation audit" }, "400": { "description": "Input differs from the fixed demo request" } }
      }
    },
    "/api/catalog": {
      "get": {
        "operationId": "listSourceMintProducts",
        "summary": "List SourceMint products, prices, inputs, and purchase URLs",
        "description": "Free machine-readable catalog. No payment, account, or API key required.",
        "tags": ["Discovery"],
        "security": [],
        "responses": { "200": { "description": "Current product catalog" } }
      }
    },
    "/api/audit-citations": {
      "post": {
        "operationId": "auditAnswerCitations",
        "summary": "Audit an answer against its cited sources",
        "description": "Checks up to 50 substantive sentences against 1-10 cited public URLs. Returns claim-level evidence, coverage metrics, source hashes, and a bundle hash.",
        "tags": ["Evidence verification"],
        "x-payment-info": { "price": { "mode": "fixed", "currency": "USD", "amount": "0.050000" }, "protocols": [{ "x402": {} }] },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["answer", "urls"],
                "additionalProperties": false,
                "properties": {
                  "answer": { "type": "string", "minLength": 20, "maxLength": 10000 },
                  "urls": { "type": "array", "minItems": 1, "maxItems": 10, "items": { "type": "string", "format": "uri" } }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Claim-level citation coverage and proof bundle", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CitationAudit" } } }, "headers": { "PAYMENT-RESPONSE": { "schema": { "type": "string" } } } },
          "400": { "description": "Invalid input or unavailable source" },
          "402": { "description": "Payment Required", "headers": { "PAYMENT-REQUIRED": { "required": true, "schema": { "type": "string" } } } }
        }
      }
    },
    "/api/verify-claim": {
      "post": {
        "operationId": "verifyClaimAgainstSources",
        "summary": "Retrieve source-hashed evidence for a claim",
        "description": "Ranks passages from 1–5 public sources by transparent lexical overlap and flags negation conflicts. Returns source hashes and a bundle hash. This retrieves evidence; it does not guarantee factual truth.",
        "tags": ["Evidence verification"],
        "x-payment-info": { "price": { "mode": "fixed", "currency": "USD", "amount": "0.010000" }, "protocols": [{ "x402": {} }] },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["claim", "urls"],
                "additionalProperties": false,
                "properties": {
                  "claim": { "type": "string", "minLength": 5, "maxLength": 500 },
                  "urls": { "type": "array", "minItems": 1, "maxItems": 5, "items": { "type": "string", "format": "uri" } }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ranked evidence and proof bundle",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ClaimEvidence" } } },
            "headers": { "PAYMENT-RESPONSE": { "schema": { "type": "string" } } }
          },
          "400": { "description": "Invalid input or unavailable source" },
          "402": { "description": "Payment Required", "headers": { "PAYMENT-REQUIRED": { "required": true, "schema": { "type": "string" } } } }
        }
      }
    },
    "/api/extract": {
      "post": {
        "operationId": "extractPublicWebEvidence",
        "summary": "Extract verifiable evidence from a public URL",
        "description": "Fetches one public HTML page and returns normalized Markdown, outbound citations, retrieval time, source hash, and document metrics. The unpaid response is an x402 v2 challenge for $0.001 USDC on Base.",
        "tags": ["Web evidence"],
        "x-payment-info": {
          "price": { "mode": "fixed", "currency": "USD", "amount": "0.001000" },
          "protocols": [{ "x402": {} }]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["url"],
                "additionalProperties": false,
                "properties": { "url": { "type": "string", "format": "uri", "description": "A public HTTP or HTTPS HTML page" } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Extracted evidence after payment settlement",
            "headers": { "PAYMENT-RESPONSE": { "schema": { "type": "string" }, "description": "Base64-encoded x402 settlement receipt" } },
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Evidence" } } }
          },
          "400": { "description": "Invalid, unsafe, oversized, unavailable, or non-HTML source" },
          "402": {
            "description": "Payment required",
            "headers": { "PAYMENT-REQUIRED": { "required": true, "schema": { "type": "string" }, "description": "Base64-encoded x402 v2 payment requirements" } }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CitationAudit": {
        "type": "object",
        "required": ["summary", "claims", "sources", "proof", "method"],
        "properties": {
          "summary": { "type": "object", "properties": { "claims": { "type": "integer" }, "supported": { "type": "integer" }, "partial": { "type": "integer" }, "unsupported": { "type": "integer" }, "coverage": { "type": "number", "minimum": 0, "maximum": 1 } } },
          "claims": { "type": "array", "items": { "type": "object" } },
          "sources": { "type": "array", "items": { "type": "object" } },
          "proof": { "type": "object", "properties": { "bundleSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, "evaluatedAt": { "type": "string", "format": "date-time" } } },
          "method": { "type": "string" }
        }
      },
      "ClaimEvidence": {
        "type": "object",
        "required": ["claim", "verdict", "confidence", "method", "sources", "proof"],
        "properties": {
          "claim": { "type": "string" },
          "verdict": { "type": "string", "enum": ["consistent", "conflicting", "mixed", "insufficient"] },
          "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
          "method": { "type": "string" },
          "sources": { "type": "array", "items": { "type": "object" } },
          "proof": { "type": "object", "properties": { "bundleSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, "sourceCount": { "type": "integer" }, "evaluatedAt": { "type": "string", "format": "date-time" } } }
        }
      },
      "Evidence": {
        "type": "object",
        "required": ["source", "document", "citations", "metrics"],
        "properties": {
          "source": { "type": "object", "properties": { "url": { "type": "string" }, "retrievedAt": { "type": "string", "format": "date-time" }, "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" } } },
          "document": { "type": "object", "properties": { "title": { "type": "string" }, "description": { "type": "string" }, "markdown": { "type": "string" } } },
          "citations": { "type": "array", "items": { "type": "object", "properties": { "text": { "type": "string" }, "url": { "type": "string", "format": "uri" } } } },
          "metrics": { "type": "object", "properties": { "bytes": { "type": "integer" }, "words": { "type": "integer" }, "links": { "type": "integer" } } }
        }
      }
    }
  }
}
