{
  "components": {
    "schemas": {
      "Check": {
        "properties": {
          "host": {
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "result": {
            "$ref": "#/components/schemas/Report"
          },
          "status": {
            "enum": [
              "queued",
              "running",
              "done",
              "failed"
            ],
            "type": "string"
          },
          "summary": {
            "$ref": "#/components/schemas/Summary"
          }
        },
        "type": "object"
      },
      "Finding": {
        "properties": {
          "action": {
            "properties": {
              "kind": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "note": {
                "type": "string"
              }
            },
            "type": "object"
          },
          "code": {
            "type": "string"
          },
          "severity": {
            "enum": [
              "bad",
              "warn",
              "ok",
              "gray"
            ],
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "Report": {
        "properties": {
          "checked_at": {
            "format": "date-time",
            "type": "string"
          },
          "findings": {
            "items": {
              "$ref": "#/components/schemas/Finding"
            },
            "type": "array"
          },
          "host": {
            "type": "string"
          },
          "services": {
            "items": {
              "properties": {
                "category": {
                  "type": "string"
                },
                "data": {
                  "type": "string"
                },
                "host": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "summary": {
            "$ref": "#/components/schemas/Summary"
          }
        },
        "type": "object"
      },
      "Site": {
        "properties": {
          "host": {
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "monitor": {
            "type": "boolean"
          },
          "plan": {
            "type": "string"
          },
          "public_key": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "Summary": {
        "properties": {
          "bad": {
            "type": "integer"
          },
          "gray": {
            "type": "integer"
          },
          "ok": {
            "type": "integer"
          },
          "warn": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "Verdict": {
        "properties": {
          "class": {
            "enum": [
              "human",
              "suspicious",
              "bot"
            ],
            "type": "string"
          },
          "ok": {
            "type": "boolean"
          },
          "reasons": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "score": {
            "type": "integer"
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "apiKey": {
        "description": "Ключ API аккаунта (cc_key_…) или access-токен OAuth",
        "scheme": "bearer",
        "type": "http"
      },
      "oauth": {
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://guard.catcapital.ru/oauth/authorize",
            "refreshUrl": "https://guard.catcapital.ru/oauth/token",
            "scopes": {
              "guard": "кабинет: сайты, отчёты, установка, статистика"
            },
            "tokenUrl": "https://guard.catcapital.ru/oauth/token"
          }
        },
        "type": "oauth2"
      },
      "siteSecret": {
        "description": "Секрет сайта (cc_secret_…) для проверки заявок",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "Проверка сайта на посторонние скрипты, утечки и требования 152-ФЗ, контроль изменений, защита форм от ботов, ловушки для утечек контактов.",
    "title": "Коткапитал Защита сайта",
    "version": "0.1.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/v1/checks": {
      "post": {
        "description": "Ставит проверку в очередь. Свежий отчёт (моложе часа) возвращается сразу со статусом done. Без ключа - до 10 проверок в час с адреса.",
        "operationId": "checkSite",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "host": {
                    "example": "catcapital.ru",
                    "type": "string"
                  }
                },
                "required": [
                  "host"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Check"
                }
              }
            },
            "description": "OK"
          }
        },
        "summary": "Проверить сайт"
      }
    },
    "/v1/checks/{id}": {
      "get": {
        "description": "Опрашивать раз в 2-3 секунды, пока status не станет done или failed.",
        "operationId": "getCheck",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Check"
                }
              }
            },
            "description": "OK"
          }
        },
        "summary": "Статус и отчёт проверки"
      }
    },
    "/v1/sites": {
      "get": {
        "operationId": "listSites",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Мои сайты"
      },
      "post": {
        "description": "Выдаёт ключи и запускает первую проверку.",
        "operationId": "addSite",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "host": {
                    "type": "string"
                  }
                },
                "required": [
                  "host"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Site"
                }
              }
            },
            "description": "OK"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Добавить сайт на контроль"
      }
    },
    "/v1/sites/{id}": {
      "get": {
        "operationId": "getSite",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Сайт и последняя проверка"
      }
    },
    "/v1/sites/{id}/checks": {
      "get": {
        "operationId": "siteChecks",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "История проверок"
      },
      "post": {
        "operationId": "runSiteCheck",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Check"
                }
              }
            },
            "description": "OK"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Проверить сайт сейчас"
      }
    },
    "/v1/sites/{id}/forms": {
      "get": {
        "description": "Параметр days (по умолчанию 7).",
        "operationId": "formStats",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Статистика проверок заявок"
      }
    },
    "/v1/sites/{id}/install": {
      "get": {
        "description": "Скрипт для страниц, инструкции для WordPress и Тильды, секрет для проверки заявок с сервера.",
        "operationId": "installSnippet",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Код установки защиты форм"
      }
    },
    "/v1/traps": {
      "get": {
        "operationId": "listTraps",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Номера-ловушки"
      }
    },
    "/v1/traps/events": {
      "get": {
        "description": "Звонки и SMS на номера-ловушки.",
        "operationId": "trapEvents",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "События ловушек"
      }
    },
    "/v1/verify": {
      "post": {
        "description": "Вызывается с сервера сайта перед сохранением заявки. Авторизация секретом сайта.",
        "operationId": "verifyLead",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "ip": {
                    "type": "string"
                  },
                  "token": {
                    "description": "значение скрытого поля cc_token",
                    "type": "string"
                  }
                },
                "required": [
                  "token"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Verdict"
                }
              }
            },
            "description": "OK"
          }
        },
        "security": [
          {
            "siteSecret": []
          }
        ],
        "summary": "Проверить заявку"
      }
    }
  },
  "servers": [
    {
      "url": "https://guard.catcapital.ru"
    }
  ]
}