{
  "openapi": "3.0.3",
  "info": {
    "title": "Pingvera API",
    "version": "1.0.0",
    "description": "Публичный API мониторинга Pingvera (только чтение). Аутентификация — API-токен (создаётся в дашборде: Настройки → API-токены) в заголовке Authorization: Bearer pv_... Каждому эндпоинту нужен свой скоуп токена. Организация определяется токеном. Для LLM-ассистентов есть MCP-сервер: POST /mcp (JSON-RPC 2.0, тот же Bearer-токен, скоуп read:monitoring)."
  },
  "servers": [{"url": "https://app.pingvera.ru"}],
  "components": {
    "securitySchemes": {
      "apiToken": {"type": "http", "scheme": "bearer", "description": "API-токен pv_*; скоупы: read:metrics, read:hosts, read:monitoring"}
    }
  },
  "security": [{"apiToken": []}],
  "paths": {
    "/api/v1/monitors": {
      "get": {
        "summary": "Список проверок (мониторов)",
        "description": "Скоуп read:monitoring. Все проверки организации с типом, целью и текущим статусом.",
        "responses": {"200": {"description": "OK — {monitors: [...]}"}, "401": {"description": "нет/битый токен"}, "403": {"description": "нет скоупа read:monitoring"}}
      }
    },
    "/api/v1/incidents": {
      "get": {
        "summary": "События мониторинга (инциденты)",
        "description": "Скоуп read:monitoring. Открытые и закрытые события: что сломалось, когда, когда восстановилось.",
        "parameters": [{"name": "status", "in": "query", "schema": {"type": "string", "enum": ["open", "resolved"]}, "description": "фильтр статуса; пусто = все"}],
        "responses": {"200": {"description": "OK — {incidents: [...]}"}, "401": {"description": "нет/битый токен"}, "403": {"description": "нет скоупа"}}
      }
    },
    "/api/v1/hosts": {
      "get": {
        "summary": "Серверы с агентом",
        "description": "Скоуп read:hosts. Парк серверов: имя, ОС, онлайн/оффлайн, метаданные.",
        "responses": {"200": {"description": "OK — {hosts: [...]}"}, "401": {"description": "нет/битый токен"}, "403": {"description": "нет скоупа read:hosts"}}
      }
    },
    "/api/v1/metrics/query": {
      "get": {
        "summary": "Метрики сервера (временной ряд)",
        "description": "Скоуп read:metrics. Агрегированный ряд метрик хоста (avg по интервалам).",
        "parameters": [
          {"name": "host", "in": "query", "required": true, "schema": {"type": "string"}, "description": "public_id хоста (см. /api/v1/hosts)"},
          {"name": "from", "in": "query", "schema": {"type": "integer"}, "description": "unix-секунды, дефолт: час назад"},
          {"name": "to", "in": "query", "schema": {"type": "integer"}, "description": "unix-секунды, дефолт: сейчас"},
          {"name": "step", "in": "query", "schema": {"type": "integer"}, "description": "шаг агрегации, сек (дефолт 60)"},
          {"name": "metrics", "in": "query", "schema": {"type": "string"}, "description": "список через запятую: cpu_pct, mem_used_pct, disk_used_pct, net_in_bps, net_out_bps и др."}
        ],
        "responses": {"200": {"description": "OK — колоночный JSON {t: [...], cpu_pct: [...]}"}, "401": {"description": "нет/битый токен"}, "403": {"description": "нет скоупа read:metrics"}}
      }
    },
    "/mcp": {
      "post": {
        "summary": "MCP-сервер (Model Context Protocol)",
        "description": "Скоуп read:monitoring. JSON-RPC 2.0 (initialize / tools/list / tools/call). Инструменты: list_monitors, list_incidents, list_hosts, uptime_summary. Подключение в Claude Code: claude mcp add --transport http pingvera https://app.pingvera.ru/mcp --header \"Authorization: Bearer pv_...\"",
        "responses": {"200": {"description": "JSON-RPC ответ"}, "401": {"description": "нет/битый токен"}, "403": {"description": "нет скоупа read:monitoring"}}
      }
    }
  }
}