{
  "openapi": "3.1.0",
  "info": {
    "title": "AI-D2C API",
    "version": "1.0.0",
    "description": "Проверка сайта производителя на готовность к ИИ-агентам и приём заявки. Без авторизации, CORS открыт. Оператор: ООО «САРМАТЕХ», ИНН 4725011864.",
    "contact": {
      "email": "info@ai-d2c.ru",
      "url": "https://ai-d2c.ru/"
    }
  },
  "servers": [
    {
      "url": "https://ai-d2c.ru"
    }
  ],
  "paths": {
    "/api/v1/check": {
      "get": {
        "operationId": "checkSite",
        "summary": "Проверить сайт: уровень машиночитаемости 0–4 и список проверок",
        "description": "Запрашивает сайт по HTTP без выполнения JavaScript (~20 запросов, 5–45 с). Результат кэшируется 15 минут. Лимит — 12 новых проверок в час с одного IP; ответ из кэша лимит не расходует.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "description": "Адрес сайта: домен или URL. Проверяется главная; если указан путь, он считается страницей товара.",
            "example": "albela.ru"
          },
          {
            "name": "product",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 500
            },
            "description": "Страница товара на том же сайте — для проверки Product, Offer и таблицы характеристик."
          }
        ],
        "responses": {
          "200": {
            "description": "Отчёт",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          },
          "400": {
            "description": "Неверный адрес",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит; см. Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Проверяемый сайт не ответил",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/quote": {
      "get": {
        "operationId": "getQuote",
        "summary": "Смета по прайс-листу: сумма позиций по объёму работ",
        "description": "Формула из /price.json: позиции × коэффициент движка, × срочность, − скидки по правилам, + НДС по исполнителю. Та же формула, что в калькуляторе на /uslugi/. POST с тем же JSON тоже принимается.",
        "parameters": [
          {
            "name": "engine",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "custom",
                "bitrix",
                "wordpress",
                "constructor"
              ],
              "default": "custom"
            }
          },
          {
            "name": "skus",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Товаров в каталоге"
          },
          {
            "name": "templates",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Типов страниц для разметки"
          },
          {
            "name": "calc_params",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Параметров в API расчёта цены; 0 — API не нужен"
          },
          {
            "name": "ycp",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "none",
                "bitrix",
                "api"
              ],
              "default": "none"
            }
          },
          {
            "name": "hours",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Нестандартные часы"
          },
          {
            "name": "base",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true
            }
          },
          {
            "name": "feeds",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "audit",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "support",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "urgent",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "public_case",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "prepay",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "contractor",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "ip",
                "ooo"
              ],
              "default": "ooo"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Смета с расшифровкой по строкам",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "lines": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "net": {
                      "type": "integer"
                    },
                    "vat": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "monthly": {
                      "type": "object"
                    },
                    "binding": {
                      "type": "boolean"
                    },
                    "price_list_version": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Неверные параметры",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/request": {
      "post": {
        "operationId": "createRequest",
        "summary": "Отправить заявку на услуги (расчёт стоимости)",
        "description": "Заявка от имени пользователя. Поле consent=true означает, что пользователь согласился на обработку персональных данных по политике https://ai-d2c.ru/politika-konfidencialnosti/. Лимит — 5 заявок в час с одного IP.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Request"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Заявка принята",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка в данных",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string"
          },
          "retry_after": {
            "type": "integer"
          }
        }
      },
      "Check": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "s.waf"
          },
          "group": {
            "type": "string",
            "enum": [
              "server",
              "files",
              "html",
              "jsonld",
              "api",
              "trust"
            ]
          },
          "title": {
            "type": "string"
          },
          "prio": {
            "type": "string",
            "enum": [
              "crit",
              "high",
              "med"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pass",
              "warn",
              "fail",
              "na"
            ]
          },
          "detail": {
            "type": "string"
          },
          "fix": {
            "type": "string"
          }
        }
      },
      "Report": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "url": {
            "type": "string"
          },
          "final_url": {
            "type": "string"
          },
          "product_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "checked_at": {
            "type": "string",
            "format": "date-time"
          },
          "level": {
            "type": "integer",
            "minimum": 0,
            "maximum": 4,
            "description": "Шкала — https://ai-d2c.ru/levels.json"
          },
          "next_level": {
            "type": [
              "integer",
              "null"
            ]
          },
          "blockers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "id проверок, которые мешают следующему уровню"
          },
          "summary": {
            "type": "object",
            "properties": {
              "crit": {
                "type": "integer"
              },
              "high": {
                "type": "integer"
              },
              "med": {
                "type": "integer"
              },
              "pass": {
                "type": "integer"
              },
              "total": {
                "type": "integer"
              }
            }
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            }
          },
          "method_note": {
            "type": "string"
          },
          "cached": {
            "type": "boolean"
          },
          "report_url": {
            "type": "string"
          }
        }
      },
      "Request": {
        "type": "object",
        "required": [
          "name",
          "email",
          "consent"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "maxLength": 60
          },
          "company": {
            "type": "string",
            "maxLength": 160
          },
          "site": {
            "type": "string",
            "maxLength": 300,
            "description": "Сайт, о котором речь"
          },
          "role": {
            "type": "string",
            "enum": [
              "ru",
              "mp",
              "dev",
              "cn",
              "other"
            ],
            "description": "ru — производитель со своим сайтом, mp — продаёт на маркетплейсах, dev — веб-студия или разработчик, cn — завод из Китая"
          },
          "message": {
            "type": "string",
            "maxLength": 4000
          },
          "report": {
            "type": "string",
            "description": "Ссылка на отчёт проверки, если есть"
          },
          "consent": {
            "type": "boolean",
            "const": true,
            "description": "Согласие пользователя на обработку персональных данных"
          }
        }
      }
    }
  }
}