{
  "openapi": "3.1.0",
  "info": {
    "title": "SourceScore VERITAS API",
    "summary": "Signed, sourced, citable claim verification for LLM developers building grounded retrieval systems.",
    "description": "VERITAS v0.1 is a sourced AI/ML claim catalog with stable JSON records. Every current claim cites primary evidence; 368 of 384 claims have two or more sources and 16 have one primary source. Records include SourceScore-issued HMAC integrity metadata, which is not publicly independently verifiable because no shared secret is published.\n\nThe public API is free with no auth, signup, or account-level meter. Standard network abuse protection may apply. Proposed higher-volume tiers are demand collection only; no paid checkout, billing, API-key provisioning, dashboard, or SLA is live.\n\nAll endpoints are CORS-enabled (`Access-Control-Allow-Origin: *`). Cite as: `SourceScore Claim <id>, sourcescore.org`. Data licensed CC-BY 4.0.",
    "version": "0.1.0",
    "contact": {
      "name": "SourceScore VERITAS",
      "url": "https://sourcescore.org/contact/"
    },
    "license": {
      "name": "CC-BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    },
    "x-acepilot-archetype": "api-only + saas-b2b"
  },
  "servers": [
    {
      "url": "https://sourcescore.org",
      "description": "Production (Cloudflare Pages + Pages Functions)"
    }
  ],
  "externalDocs": {
    "description": "Verification methodology v0.1 — full rubric + signing model + tier reference",
    "url": "https://sourcescore.org/api/v1/methodology.json"
  },
  "tags": [
    { "name": "Claims", "description": "Per-claim envelopes + catalog endpoints." },
    { "name": "Search", "description": "Keyword search across the catalog." },
    { "name": "Verify", "description": "Natural-language claim verification." },
    { "name": "Methodology", "description": "How claims are sourced + signed." }
  ],
  "paths": {
    "/api/v1/claims.json": {
      "get": {
        "tags": ["Claims"],
        "summary": "Full claim catalog (light per-claim summaries)",
        "description": "Returns every verified claim with subject/predicate/object/statement/confidence + signature prefix + link to per-claim envelope. Suited for client-side filtering, building local indexes, or feeding LLM context windows with the full catalog.",
        "operationId": "getClaimsCatalog",
        "responses": {
          "200": {
            "description": "Catalog wrapper.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ClaimsCatalog" }
              }
            }
          }
        }
      }
    },
    "/api/v1/claims/{id}.json": {
      "get": {
        "tags": ["Claims"],
        "summary": "Per-claim envelope with SourceScore-issued integrity metadata",
        "description": "Returns the full record for a claim: subject, predicate, object, cited evidence, SourceScore-issued integrity metadata, and a ready-to-paste citation.",
        "operationId": "getClaimById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "16-hex-char claim id (lowercase). Pattern: `[0-9a-f]{16}`.",
            "schema": { "type": "string", "example": "ad17e76a8baad7a1", "pattern": "^[0-9a-f]{16}$" }
          }
        ],
        "responses": {
          "200": {
            "description": "Claim envelope with cited evidence and SourceScore-issued HMAC metadata; the tag is not publicly independently verifiable.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ClaimEnvelope" }
              }
            }
          },
          "404": { "description": "Claim id not found in catalog." }
        }
      }
    },
    "/api/v1/methodology.json": {
      "get": {
        "tags": ["Methodology"],
        "summary": "Verification methodology + pricing tiers",
        "description": "Returns methodology metadata: signing algorithm, signed-by identity, citation format, license, pricing tiers (free/indie/startup/scale), endpoint index.",
        "operationId": "getMethodology",
        "responses": {
          "200": {
            "description": "Methodology document.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Methodology" } } }
          }
        }
      }
    },
    "/api/v1/search": {
      "get": {
        "tags": ["Search"],
        "summary": "Keyword search across claims",
        "description": "Returns claims matching the query using keyword-overlap scoring across subject, object, statement, predicate, and tags.",
        "operationId": "searchClaims",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Query string. 2-500 chars.",
            "schema": { "type": "string", "minLength": 2, "maxLength": 500, "example": "llama" }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Max results. 1-50. Default 20.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 50, "default": 20 }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SearchResponse" }
              }
            }
          },
          "400": { "description": "Invalid query parameter." }
        }
      }
    },
    "/api/v1/verify": {
      "post": {
        "tags": ["Verify"],
        "summary": "Match a natural-language claim against the catalog",
        "description": "Submit a natural-language claim string. When Workers AI and Vectorize are available, the endpoint ranks semantic similarity; otherwise it falls back to keyword overlap. `bestMatch` is a candidate catalog record, not entailment or a truth verdict. Compare the returned statement and cited evidence with the input.",
        "operationId": "verifyClaim",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/VerifyRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification result.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/VerifyResponse" }
              }
            }
          },
          "400": { "description": "Body invalid or `claim` missing/out-of-bounds." },
          "405": { "description": "Method Not Allowed (POST only)." },
          "503": { "description": "Catalog index temporarily unavailable." }
        }
      }
    },
    "/api/v1/openapi.json": {
      "get": {
        "tags": ["Methodology"],
        "summary": "This document",
        "description": "OpenAPI 3.1 spec for the VERITAS-Reborn API.",
        "operationId": "getOpenAPI",
        "responses": {
          "200": {
            "description": "OpenAPI spec.",
            "content": { "application/json": {} }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ClaimsCatalog": {
        "type": "object",
        "required": ["apiVersion", "methodology", "generated", "count", "claims"],
        "properties": {
          "apiVersion": { "type": "string", "enum": ["v1"] },
          "methodology": { "type": "string", "format": "uri" },
          "generated": { "type": "string", "format": "date-time" },
          "count": { "type": "integer", "example": 384 },
          "claims": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/ClaimSummary" }
          }
        }
      },
      "ClaimSummary": {
        "type": "object",
        "required": ["id", "vertical", "subject", "predicate", "object", "statement", "confidence", "signatureShort", "detailUrl"],
        "properties": {
          "id": { "type": "string", "pattern": "^[0-9a-f]{16}$", "example": "ad17e76a8baad7a1" },
          "vertical": { "type": "string", "enum": ["ai-ml"] },
          "subject": { "type": "string", "example": "Llama 3.1" },
          "predicate": { "type": "string", "example": "released_on" },
          "object": { "type": "string", "example": "2024-07-23" },
          "statement": { "type": "string", "example": "Llama 3.1 released on: 2024-07-23." },
          "confidence": { "type": "number", "minimum": 0.7, "maximum": 1.0 },
          "signatureShort": { "type": "string", "description": "Illustrative eight-character prefix; refetch the canonical record for the current value.", "example": "a1b2c3d4" },
          "detailUrl": { "type": "string", "format": "uri" }
        }
      },
      "ClaimEnvelope": {
        "type": "object",
        "required": ["apiVersion", "methodology", "canonical", "claim", "signature", "citedAs"],
        "properties": {
          "apiVersion": { "type": "string", "enum": ["v1"] },
          "methodology": { "type": "string", "format": "uri" },
          "canonical": { "type": "string", "format": "uri" },
          "claim": { "$ref": "#/components/schemas/Claim" },
          "signature": { "$ref": "#/components/schemas/Signature" },
          "citedAs": { "type": "string" }
        }
      },
      "Claim": {
        "type": "object",
        "required": ["id", "vertical", "subject", "predicate", "object", "statement", "confidence", "sources", "publishedAt", "lastVerified", "methodologyVersion", "tags"],
        "properties": {
          "id": { "type": "string", "pattern": "^[0-9a-f]{16}$" },
          "vertical": { "type": "string", "enum": ["ai-ml"] },
          "subject": { "type": "string" },
          "predicate": { "type": "string" },
          "object": { "type": "string" },
          "statement": { "type": "string" },
          "confidence": { "type": "number", "minimum": 0.7, "maximum": 1.0 },
          "sources": {
            "type": "array",
            "minItems": 1,
            "items": { "$ref": "#/components/schemas/ClaimSource" }
          },
          "publishedAt": { "type": "string", "format": "date-time" },
          "lastVerified": { "type": "string", "format": "date" },
          "methodologyVersion": { "type": "string", "example": "veritas-v0.1" },
          "tags": { "type": "array", "items": { "type": "string" } }
        }
      },
      "ClaimSource": {
        "type": "object",
        "required": ["url", "title", "publisher", "accessedDate", "type"],
        "properties": {
          "url": { "type": "string", "format": "uri" },
          "title": { "type": "string" },
          "publisher": { "type": "string" },
          "publishedDate": { "type": "string", "format": "date" },
          "accessedDate": { "type": "string", "format": "date" },
          "type": {
            "type": "string",
            "enum": [
              "preprint",
              "peer-reviewed",
              "official-blog",
              "press-release",
              "docs",
              "model-card",
              "github-release",
              "benchmark"
            ]
          },
          "excerpt": { "type": "string", "maxLength": 200 }
        }
      },
      "Signature": {
        "type": "object",
        "description": "SourceScore-issued HMAC integrity metadata. The shared secret is not public, so consumers cannot independently recompute this tag.",
        "required": ["algorithm", "signedBy", "signedAt", "signature"],
        "properties": {
          "algorithm": { "type": "string", "enum": ["HMAC-SHA256"] },
          "signedBy": { "type": "string", "example": "did:web:sourcescore.org" },
          "signedAt": { "type": "string", "format": "date-time" },
          "signature": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
        }
      },
      "SearchResponse": {
        "type": "object",
        "required": ["apiVersion", "methodology", "query", "count", "results"],
        "properties": {
          "apiVersion": { "type": "string", "enum": ["v1"] },
          "methodology": { "type": "string", "format": "uri" },
          "query": { "type": "string" },
          "count": { "type": "integer" },
          "results": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/ClaimSummary" }
          }
        }
      },
      "VerifyRequest": {
        "type": "object",
        "required": ["claim"],
        "properties": {
          "claim": {
            "type": "string",
            "minLength": 5,
            "maxLength": 1000,
            "description": "Natural-language claim string to verify.",
            "example": "Llama 3.1 was released in July 2024"
          },
          "vertical": {
            "type": "string",
            "enum": ["ai-ml"],
            "description": "Optional vertical filter."
          },
          "minConfidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.85,
            "description": "Minimum legacy editorial-confidence value for a candidate record. This does not set a query-entailment or truth threshold."
          }
        }
      },
      "VerifyResponse": {
        "type": "object",
        "required": ["apiVersion", "methodology", "query", "minConfidence", "method", "note", "matches"],
        "properties": {
          "apiVersion": { "type": "string", "enum": ["v1"] },
          "methodology": { "type": "string", "format": "uri" },
          "query": { "type": "string" },
          "minConfidence": {
            "type": "number",
            "description": "Legacy editorial record-confidence threshold applied to bestMatch (default 0.85); not a truth threshold."
          },
          "method": {
            "type": "string",
            "enum": ["semantic", "keyword"],
            "description": "Ranking method used: \"semantic\" = Workers AI bge-m3 embedding + Vectorize cosine similarity (match floor 0.50); \"keyword\" = term-overlap fallback (match floor 0.30), used only when the semantic bindings are unavailable."
          },
          "note": {
            "type": "string",
            "description": "Warning that matches are retrieval candidates and must not be treated as entailment or truth verdicts."
          },
          "matches": {
            "type": "array",
            "description": "Top 5 ranked matches.",
            "items": {
              "type": "object",
              "required": ["claim", "matchScore", "rationale"],
              "properties": {
                "claim": { "$ref": "#/components/schemas/ClaimSummary" },
                "matchScore": { "type": "number", "minimum": 0, "maximum": 1 },
                "rationale": { "type": "string" }
              }
            }
          },
          "bestMatch": {
            "$ref": "#/components/schemas/ClaimSummary",
            "description": "Highest-scoring candidate if matchScore clears the method floor and the record's legacy editorial confidence clears minConfidence. It is not a truth verdict."
          },
          "notVerified": {
            "type": "boolean",
            "description": "True if no candidate record cleared the retrieval and editorial-confidence gates."
          },
          "signature": { "$ref": "#/components/schemas/Signature" }
        }
      },
      "Methodology": {
        "type": "object",
        "properties": {
          "apiVersion": { "type": "string", "enum": ["v1"] },
          "version": { "type": "string", "example": "veritas-v0.1" },
          "generated": { "type": "string", "format": "date-time" },
          "title": { "type": "string" },
          "summary": { "type": "string" },
          "signing": {
            "type": "object",
            "properties": {
              "algorithm": { "type": "string" },
              "signedBy": { "type": "string" },
              "verificationEndpoint": { "type": "string", "format": "uri" },
              "migrationNote": { "type": "string" }
            }
          },
          "citation": {
            "type": "object",
            "properties": {
              "license": { "type": "string" },
              "citationFormat": { "type": "string" }
            }
          },
          "commercialAvailability": {
            "type": "object",
            "properties": {
              "freeApi": { "type": "string", "enum": ["live_no_signup"] },
              "paidAccess": { "type": "string", "enum": ["proposal_only_not_purchasable"] },
              "details": { "type": "string", "format": "uri" }
            }
          },
          "tiers": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/Tier" }
          },
          "count": { "type": "integer" },
          "endpoints": {
            "type": "object",
            "additionalProperties": { "type": "string" }
          }
        }
      },
      "Tier": {
        "type": "object",
        "required": ["name", "monthlyEur", "includedClaims", "availability"],
        "properties": {
          "name": { "type": "string", "enum": ["free", "indie", "startup", "scale"] },
          "monthlyEur": { "type": "number" },
          "includedClaims": { "oneOf": [{ "type": "integer" }, { "type": "null" }] },
          "availability": { "type": "string", "enum": ["live_free", "proposal_only"] }
        }
      }
    }
  }
}
