{
  "openapi": "3.1.0",
  "info": {
    "title": "SKEPTIC Text Forensics API",
    "version": "3.0.0",
    "summary": "Deterministic text forensics: hidden Unicode, secrets/PII, plagiarism fingerprints, stylometry, readability, prompt-injection heuristics, redaction, forensic diff.",
    "description": "The same engines as the SKEPTIC browser app, served stateless. Request bodies are processed in memory and discarded: no storage, no logging, no telemetry. Every tool is deterministic — the same input always yields the same output.",
    "license": { "name": "MIT" }
  },
  "servers": [{ "url": "/", "description": "same-origin (Vercel)" }],
  "paths": {
    "/api/v1/scan": {
      "get": {
        "summary": "Service manifest (self-description for agents)",
        "operationId": "manifest",
        "responses": {
          "200": {
            "description": "Tool list, request shape, limits, privacy statement",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      },
      "post": {
        "summary": "Run a forensics tool on text",
        "operationId": "scan",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ScanRequest" },
              "examples": {
                "dossier": {
                  "summary": "Full audit of one text",
                  "value": { "tool": "dossier", "text": "AKIAIOSFODNN7EXAMPLE found in logs" }
                },
                "redact": {
                  "summary": "Sanitize including PII",
                  "value": { "tool": "redact", "text": "jane@corp.com used card 4539 1488 0343 6467", "pii": true }
                },
                "diff": {
                  "summary": "Forensic diff of two versions",
                  "value": { "tool": "diff", "a": "approved budget: 1000", "b": "approved budget: 10000" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Engine result, tool-shaped",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ScanResponse" } } }
          },
          "400": { "description": "Body is not valid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "404": { "description": "Unknown tool", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "413": { "description": "Body too large", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "422": { "description": "Missing/invalid text fields", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ScanRequest": {
        "type": "object",
        "properties": {
          "tool": { "type": "string", "enum": ["dossier","hidden","leaks","prose","signals","redact","copies","diff","voices"], "default": "dossier" },
          "text": { "type": "string", "maxLength": 300000, "description": "input for single-text tools" },
          "a": { "type": "string", "maxLength": 300000, "description": "first text for copies/diff" },
          "b": { "type": "string", "maxLength": 300000, "description": "second text for copies/diff" },
          "texts": { "type": "array", "minItems": 2, "maxItems": 8, "description": "voices only", "items": { "type": "object", "properties": { "name": { "type": "string" }, "text": { "type": "string" } }, "required": ["text"] } },
          "pii": { "type": "boolean", "default": false, "description": "redact tool: also mask emails/phones/IPs" }
        }
      },
      "ScanResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "const": true },
          "meta": { "type": "object", "properties": { "tool": { "type": "string" }, "version": { "type": "string" }, "ms": { "type": "number" }, "privacy": { "type": "string" } } },
          "result": { "type": "object", "description": "tool-shaped engine result; deterministic" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "const": false },
          "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } } }
        }
      }
    }
  }
}
