{
  "openapi": "3.1.0",
  "info": {
    "title": "Cyber Guardian Scan developer API",
    "version": "1.0.0",
    "description": "Security review of code before it is released. A key signs in as your Cyber Guardian Scan account: same plan, scans and history as the website and Claude. Keys are sent in the Authorization header and never work in a browser or in a URL."
  },
  "servers": [{ "url": "https://cyberguardianscan.com" }],
  "security": [{ "apiKey": [] }],
  "paths": {
    "/api/v1/scan": {
      "post": {
        "summary": "Scan code (uses one scan; needs the scan scope)",
        "parameters": [
          { "name": "Idempotency-Key", "in": "header", "required": false, "schema": { "type": "string" }, "description": "Repeating the same key and body is never charged twice." }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["code"],
                "properties": {
                  "code": { "type": "string", "maxLength": 300000, "description": "The code, or a public link, package or install command. For several files, start each file with a line: // Source file: path" },
                  "scope": { "type": "string", "enum": ["mcp", "skill", "extension", "package", "dependency", "github_action"], "default": "mcp" },
                  "source_name": { "type": "string", "maxLength": 160, "description": "Your project name. Scans with the same name are compared with each other." }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Result. If review_complete is false, the full review could not finish and the scan was not charged.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ScanResult" } } } },
          "401": { "description": "The key is invalid, expired, revoked, lacks the scan scope, or was sent from a browser." },
          "429": { "description": "Rate limit or plan quota reached." }
        }
      }
    },
    "/api/v1/usage": {
      "get": {
        "summary": "Your plan and scans remaining (needs the read scope)",
        "responses": { "200": { "description": "Plan name, scans used and remaining." }, "401": { "description": "The key is not accepted." } }
      }
    },
    "/api/v1/scans": {
      "get": {
        "summary": "Your scan history (needs the read scope)",
        "parameters": [
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 50 } },
          { "name": "before", "in": "query", "schema": { "type": "string" } }
        ],
        "responses": { "200": { "description": "A page of your scans." }, "401": { "description": "The key is not accepted." } }
      }
    }
  },
  "components": {
    "securitySchemes": { "apiKey": { "type": "http", "scheme": "bearer", "description": "A key from the Developers page, starting with cgk_live_." } },
    "schemas": {
      "ScanResult": {
        "type": "object",
        "properties": {
          "decision_details": { "type": "object", "properties": { "decision": { "type": "string", "enum": ["install_ok", "install_with_caution", "fix_before_use", "do_not_install"] } } },
          "security_score": { "type": "integer", "minimum": 0, "maximum": 100, "description": "Higher is safer." },
          "threats": { "type": "array", "items": { "type": "object", "properties": { "family": { "type": "string" }, "severity": { "type": "string" }, "file_path": { "type": "string" }, "line_start": { "type": "integer" } } } },
          "compared_to_previous": { "type": "object", "description": "What is new and what was fixed since your previous scan of the same project name." },
          "review_complete": { "type": "boolean", "description": "False means the full review could not finish; the scan was not charged." }
        }
      }
    }
  }
}
