{
  "openapi": "3.1.0",
  "info": {
    "title": "VStok Agency API",
    "version": "1.0.0",
    "description": "Read-only API for AI visibility metrics. Requires Agency plan API key (Bearer vstok_live_*)."
  },
  "servers": [{ "url": "https://api.vstok.net" }],
  "security": [{ "bearerAuth": [] }],
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check",
        "security": [],
        "responses": {
          "200": { "description": "Service healthy" }
        }
      }
    },
    "/api/v1/projects/{projectId}/overview": {
      "get": {
        "summary": "Project visibility overview",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "responses": {
          "200": { "description": "Overview metrics" },
          "401": { "description": "Unauthorized" },
          "402": { "description": "Plan limit" }
        }
      }
    },
    "/api/v1/projects/{projectId}/visibility-history": {
      "get": {
        "summary": "Visibility history time series",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          },
          {
            "name": "days",
            "in": "query",
            "schema": { "type": "integer", "default": 30 }
          }
        ],
        "responses": {
          "200": { "description": "History data" }
        }
      }
    },
    "/api/v1/projects/{projectId}/audits/latest": {
      "get": {
        "summary": "Latest audit results",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "responses": {
          "200": { "description": "Latest audit" }
        }
      }
    },
    "/api/mcp": {
      "post": {
        "summary": "MCP JSON-RPC tools/call",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "type": "object" }
            }
          }
        },
        "responses": {
          "200": { "description": "Tool result" }
        }
      }
    },
    "/r/{token}": {
      "get": {
        "summary": "Public HTML visibility report",
        "security": [],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "HTML report" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Agency API key: vstok_live_*"
      }
    }
  }
}
