{
  "openapi": "3.1.0",
  "info": {
    "title": "Pro-System API для ИИ-агентов",
    "version": "1.0.0",
    "summary": "Поиск оборудования и услуг, цены, контакты и заявка на звонок — Pro-System, Алматы",
    "description": "JSON API сайта https://pro-system.kz: данные те же, что на страницах. Чтение — GET без ключа, CORS открыт; заявка — POST (вход OAuth 2.1 необязателен: свой лимит на клиента — https://pro-system.kz/auth.md). Человеческое описание, лимиты и MCP-сервер — https://pro-system.kz/dlya-ii/. / Public JSON API of Pro-System (security systems installer in Almaty): search products and services, prices, contacts, callback requests.",
    "contact": {
      "name": "Pro-System",
      "url": "https://pro-system.kz/dlya-ii/"
    }
  },
  "servers": [
    {
      "url": "https://pro-system.kz",
      "description": "Боевой сайт"
    }
  ],
  "security": [],
  "externalDocs": {
    "description": "Для ИИ-ассистентов и разработчиков",
    "url": "https://pro-system.kz/dlya-ii/"
  },
  "tags": [
    {
      "name": "catalog",
      "description": "Поиск товаров и услуг / Product and service search"
    },
    {
      "name": "services",
      "description": "Услуги: цена «от», комплекты, состав работ / Services"
    },
    {
      "name": "company",
      "description": "Оглавление, контакты, состояние API / Index, contacts, status"
    },
    {
      "name": "leads",
      "description": "Заявка на обратный звонок / Callback request"
    }
  ],
  "paths": {
    "/api/index.php": {
      "get": {
        "summary": "Оглавление API",
        "description": "Эндпоинты, OpenAPI, каталог API (RFC 9727), MCP-сервер. Тот же ответ — по адресу /api/.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiIndex"
                },
                "examples": {
                  "index": {
                    "summary": "Оглавление API",
                    "value": {
                      "ok": true,
                      "name": "Pro-System API для ИИ-агентов",
                      "docs": "https://pro-system.kz/dlya-ii/",
                      "openapi": "https://pro-system.kz/openapi.json",
                      "api_catalog": "https://pro-system.kz/.well-known/api-catalog",
                      "mcp": "https://pro-system.kz/mcp/",
                      "endpoints": [
                        {
                          "method": "GET",
                          "url": "https://pro-system.kz/api/search.php?q={query}",
                          "description": "Поиск товаров и услуг: название, артикул, бренд, цена, наличие, ссылка"
                        },
                        {
                          "method": "GET",
                          "url": "https://pro-system.kz/api/service.php?slug={slug}",
                          "description": "Услуга: цена «от», комплекты, состав работ, вопросы и ответы"
                        },
                        {
                          "method": "GET",
                          "url": "https://pro-system.kz/api/services.php",
                          "description": "Все услуги со стартовыми ценами"
                        }
                      ],
                      "data_generated_at": "2026-10-10T13:11:46"
                    },
                    "x-captured-from": "https://pro-system.kz/api/",
                    "x-captured-at": "2026-10-10T15:43:26"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Данные каталога временно недоступны (data_unavailable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "getApiIndex",
        "tags": [
          "company"
        ]
      }
    },
    "/api/search.php": {
      "get": {
        "summary": "Поиск товаров и услуг",
        "description": "Все слова запроса должны найтись в названии, артикуле, модели, бренде, категории или тегах (у услуг — в названии, описании и составе работ): с начала слова или по основе («домофона» — «домофон…»), код модели — и внутри слитного написания. Служебные слова («для», «цена», «купить», «Алматы»…) не учитываются, если есть другие. Если со всеми словами ничего нет — ответ с match: partial и совпадениями по части слов. Нужен q или фильтр category/brand.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Что искать",
            "examples": {
              "brand": {
                "value": "hikvision"
              },
              "pbx": {
                "value": "мини-АТС"
              }
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "accessory",
                "cable",
                "camera",
                "domofon",
                "nvr",
                "signal",
                "skud",
                "switch",
                "telephony"
              ]
            }
          },
          {
            "name": "brand",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Слаг или название бренда"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "product",
                "service"
              ],
              "default": "all"
            },
            "description": "Другое значение — 400 unknown_type"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            },
            "description": "Меньше 1 — 1, больше 50 — 50"
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                },
                "examples": {
                  "search_hikvision": {
                    "summary": "Поиск «hikvision» (снято с боевого)",
                    "value": {
                      "ok": true,
                      "query": "hikvision",
                      "filters": {
                        "category": null,
                        "brand": null,
                        "type": "all"
                      },
                      "match": "all",
                      "total": 165,
                      "count": 3,
                      "results": [
                        {
                          "type": "product",
                          "sku": "303624080",
                          "name": "Видеорегистратор 16 каналов · Hikvision DS-7616NXI-K2/Vpro",
                          "model": "Hikvision DS-7616NXI-K2/Vpro",
                          "brand": "Hikvision",
                          "category": "nvr",
                          "category_label": "Видеорегистратор · NVR",
                          "price": 229326,
                          "currency": "KZT",
                          "price_label": "229 326 ₸",
                          "price_date": "2026-10-05",
                          "availability": "in_stock",
                          "availability_text": "обычно в наличии",
                          "url": "https://pro-system.kz/product/303624080/",
                          "image": "https://pro-system.kz/assets/img/p_303624080.webp"
                        },
                        {
                          "type": "product",
                          "sku": "303623287",
                          "name": "Видеорегистратор 8 каналов · Hikvision DS-7608NXI-K2/8P(E)",
                          "model": "Hikvision DS-7608NXI-K2/8P(E)",
                          "brand": "Hikvision",
                          "category": "nvr",
                          "category_label": "Видеорегистратор · NVR",
                          "price": 228691,
                          "currency": "KZT",
                          "price_label": "228 691 ₸",
                          "price_date": "2026-10-05",
                          "availability": "in_stock",
                          "availability_text": "обычно в наличии",
                          "url": "https://pro-system.kz/product/303623287/",
                          "image": "https://pro-system.kz/assets/img/p_303623287_1.webp"
                        },
                        {
                          "type": "product",
                          "sku": "305305834",
                          "name": "Вызывная панель Wi-Fi · Hikvision DS-KV6133-WME1/Surface",
                          "model": "Hikvision DS-KV6133-WME1/Surface",
                          "brand": "Hikvision",
                          "category": "domofon",
                          "category_label": "Домофон · вызывная панель",
                          "price": 91500,
                          "currency": "KZT",
                          "price_label": "91 500 ₸",
                          "price_date": "2026-10-05",
                          "availability": "in_stock",
                          "availability_text": "обычно в наличии",
                          "url": "https://pro-system.kz/product/305305834/",
                          "image": "https://pro-system.kz/assets/img/p_305305834_d01967e8.webp"
                        }
                      ],
                      "notes": {
                        "prices": "Цены оборудования — розничные из прайсов официальных дистрибьюторов на дату price_date; «цена по запросу» — цены нет, ноль и скидки не подставлять. Цены услуг — стартовые «от», точная смета после бесплатного выезда.",
                        "availability": "availability_text — та же формулировка, что на карточке: «обычно в наличии» — остаток подтверждён поставщиком, «под заказ, срок подтвердим» и «наличие уточним сегодня» — не выдавать за наличие.",
                        "service_prices": "price_label — стартовая цена «от» или «смета по объекту» (цены нет — не подставлять чужую). Точная смета — после бесплатного выезда инженера.",
                        "honesty_rules": "https://pro-system.kz/honesty_rules.json"
                      },
                      "data_generated_at": "2026-10-10T13:11:46"
                    },
                    "x-captured-from": "https://pro-system.kz/api/search.php?q=hikvision&limit=3",
                    "x-captured-at": "2026-10-10T15:43:26"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Нет запроса; неизвестные категория, бренд или type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Данные каталога временно недоступны (data_unavailable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "searchCatalog",
        "tags": [
          "catalog"
        ]
      }
    },
    "/api/service.php": {
      "get": {
        "summary": "Услуга: цена «от», комплекты, состав работ, FAQ",
        "description": "Слаги — в /api/services.php.",
        "parameters": [
          {
            "name": "slug",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "videonablyudenie",
                "ustanovka-kamer",
                "skud",
                "domofony",
                "signalizaciya",
                "ats-telefoniya",
                "ustanovka-mini-ats",
                "remont-mini-ats",
                "telefoniya-dlya-call-centra",
                "signalizaciya-dlya-kvartiry",
                "signalizaciya-dlya-ofisa",
                "signalizaciya-dlya-doma",
                "sks-lokalnye-seti",
                "wifi-mesh",
                "videonablyudenie-dlya-doma",
                "videonablyudenie-dlya-biznesa",
                "videonablyudenie-dlya-sklada",
                "videonablyudenie-dlya-magazina",
                "videonablyudenie-dlya-kafe",
                "obsluzhivanie",
                "remont-kamer-videonablyudeniya",
                "proektirovanie",
                "elektromontazh",
                "zaryadnye-stancii",
                "chasofikaciya",
                "rechevoe-opoveshchenie",
                "proektirovanie-soue",
                "fluke-test-audit-sks",
                "pultovaya-ohrana",
                "krossy-zakazchika",
                "servery-i-oborudovanie",
                "videoanalitika",
                "raspoznavanie-nomerov",
                "raspoznavanie-lic"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceResponse"
                },
                "examples": {
                  "service_videonablyudenie": {
                    "summary": "Услуга «Видеонаблюдение под ключ»",
                    "value": {
                      "ok": true,
                      "service": {
                        "slug": "videonablyudenie",
                        "name": "Видеонаблюдение в Алматы под ключ: установка, настройка, обслуживание",
                        "short_name": "Видеонаблюдение под ключ",
                        "url": "https://pro-system.kz/uslugi/videonablyudenie/",
                        "price_from": 149000,
                        "price_unit": "₸",
                        "price_label": "от 149 000 ₸",
                        "currency": "KZT",
                        "montage_from": "монтаж от 300 ₸/метр",
                        "summary": "Система видеонаблюдения нужна не для того, чтобы камеры висели, а для того, чтобы в нужный момент нашлась запись — читаемая, с нужного ракурса и не затёртая через три дня. Разница между такой системой и просто камерами на стене видна ровно один раз: когда что-то случилось. Проектируем, ставим и обслуживаем видеонаблюдение в Алматы — для частных домов, офисов, магазинов, складов, подъездов и производств. Подбираем оборудование под задачу, а не под прайс: иногда правильный ответ — четыре камеры и регистратор, а иногда одна камера в нужной точке.",
                        "includes": [
                          "Выезжаем на объект, смотрим точки установки, трассы, освещение и питание",
                          "Считаем зоны обзора: что должно попадать в кадр и с какой детализацией",
                          "Подбираем камеры, регистратор и диск под задачу и под нужную глубину архива"
                        ],
                        "steps": [
                          "Звонок и вопросы. Что за объект, что важно видеть, есть ли уже камеры и сеть.",
                          "Выезд и замер. Инженер смотрит объект, считает трассы и зоны обзора. Бесплатно.",
                          "Смета. Расчёт в течение 30 минут после замера, с разбивкой на оборудование, монтаж и работы вне монтажа."
                        ],
                        "price_factors": [
                          "Сколько камер и где именно они стоят",
                          "Длина трасс — монтаж считается по метру, а не по камере",
                          "Уличные или внутренние, нужна ли работа при минусовых температурах"
                        ],
                        "for_whom": [
                          "Частный дом и двор — периметр, калитка, въезд. От 289 000 ₸ под ключ.",
                          "Офис и бизнес — вход, кабинеты, серверная, требования закона. От 349 000 ₸.",
                          "Магазин — касса, торговый зал, вход, склад. От 289 000 ₸."
                        ],
                        "packages": [
                          {
                            "id": "dom",
                            "name": "Дом под ключ — 4 камеры",
                            "for": "частный дом · двор · дача",
                            "price_from": 289000,
                            "price_label": "от 289 000 ₸",
                            "items": [
                              "4 камеры с ночной съёмкой",
                              "регистратор + диск, архив 30 дней",
                              "уведомления: человек / машина"
                            ],
                            "url": "https://pro-system.kz/ceny/#pack-dom"
                          },
                          {
                            "id": "biznes",
                            "name": "Бизнес — офис/магазин до 8 камер",
                            "for": "офис · магазин · склад",
                            "price_from": 449000,
                            "price_label": "от 449 000 ₸",
                            "items": [
                              "до 8 камер: зал, касса, вход, периметр",
                              "архив 30 суток (для объектов, где это требуется)",
                              "распознавание номеров на въезде"
                            ],
                            "url": "https://pro-system.kz/ceny/#pack-biznes"
                          }
                        ],
                        "extra_prices": [],
                        "sub_services": [],
                        "faq": [
                          {
                            "q": "Сколько стоят готовые комплекты видеонаблюдения под ключ в Алматы?",
                            "a": "Готовые комплекты под ключ: «Дом под ключ — 4 камеры» — от 289 000 ₸, «Бизнес — офис/магазин до 8 камер» — от 449 000 ₸. Точная смета — после бесплатного выезда."
                          },
                          {
                            "q": "Сколько камер нужно?",
                            "a": "Зависит не от площади, а от числа точек, которые надо видеть: входы, въезд, кассы, слепые углы. Для частного дома чаще всего это четыре точки, для магазина — от четырёх до восьми. Точное число называем после осмотра, а не по телефону."
                          },
                          {
                            "q": "Сколько это стоит?",
                            "a": "Комплект под ключ — от 149 000 ₸, монтаж отдельно — от 300 ₸ за метр трассы. Есть готовые пакеты: дом на четыре камеры от 289 000 ₸, офис или магазин до восьми камер от 449 000 ₸. Полный прайс — на странице цен."
                          }
                        ],
                        "price_pages": [
                          {
                            "title": "Цена установки камер",
                            "url": "https://pro-system.kz/ceny/ustanovka-kamer/"
                          },
                          {
                            "title": "Видеонаблюдение в подъезде: цены для КСК и ОСИ",
                            "url": "https://pro-system.kz/ceny/videonablyudenie-v-podezde/"
                          }
                        ],
                        "related_services": [
                          {
                            "slug": "ustanovka-kamer",
                            "name": "Установка и монтаж камер видеонаблюдения в Алматы",
                            "url": "https://pro-system.kz/uslugi/ustanovka-kamer/"
                          },
                          {
                            "slug": "skud",
                            "name": "СКУД в Алматы: турникеты, шлагбаумы, контроль доступа",
                            "url": "https://pro-system.kz/uslugi/skud/"
                          },
                          {
                            "slug": "domofony",
                            "name": "Установка домофонов и видеодомофонов в Алматы: квартира, дом, подъезд",
                            "url": "https://pro-system.kz/uslugi/domofony/"
                          }
                        ],
                        "request": {
                          "form": "https://pro-system.kz/uslugi/videonablyudenie/#zayavka",
                          "api": "https://pro-system.kz/api/lead.php",
                          "api_field_service": "videonablyudenie",
                          "promise": "смета за 30 минут, выезд инженера бесплатно"
                        }
                      },
                      "notes": {
                        "prices": "price_label — стартовая цена «от» или «смета по объекту» (цены нет — не подставлять чужую). Точная смета — после бесплатного выезда инженера."
                      },
                      "data_generated_at": "2026-10-10T13:11:46"
                    },
                    "x-captured-from": "https://pro-system.kz/api/service.php?slug=videonablyudenie",
                    "x-captured-at": "2026-10-10T15:43:26"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Нет параметра slug",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Такой услуги нет",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Данные каталога временно недоступны (data_unavailable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "getService",
        "tags": [
          "services"
        ]
      }
    },
    "/api/services.php": {
      "get": {
        "summary": "Все услуги",
        "description": "Слаг, название, цена «от», ссылка.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServicesResponse"
                },
                "examples": {
                  "services": {
                    "summary": "Список услуг (первые 3 из 29)",
                    "value": {
                      "ok": true,
                      "count": 29,
                      "services": [
                        {
                          "type": "service",
                          "slug": "videonablyudenie",
                          "name": "Видеонаблюдение в Алматы под ключ: установка, настройка, обслуживание",
                          "short_name": "Видеонаблюдение под ключ",
                          "price_from": 149000,
                          "price_unit": "₸",
                          "price_label": "от 149 000 ₸",
                          "url": "https://pro-system.kz/uslugi/videonablyudenie/",
                          "details": "https://pro-system.kz/api/service.php?slug=videonablyudenie"
                        },
                        {
                          "type": "service",
                          "slug": "ustanovka-kamer",
                          "name": "Установка и монтаж камер видеонаблюдения в Алматы",
                          "short_name": "Монтаж камер",
                          "price_from": 300,
                          "price_unit": "₸/метр",
                          "price_label": "от 300 ₸/метр",
                          "url": "https://pro-system.kz/uslugi/ustanovka-kamer/",
                          "details": "https://pro-system.kz/api/service.php?slug=ustanovka-kamer"
                        },
                        {
                          "type": "service",
                          "slug": "skud",
                          "name": "СКУД в Алматы: турникеты, шлагбаумы, контроль доступа",
                          "short_name": "СКУД и контроль доступа",
                          "price_from": 90000,
                          "price_unit": "₸",
                          "price_label": "от 90 000 ₸",
                          "url": "https://pro-system.kz/uslugi/skud/",
                          "details": "https://pro-system.kz/api/service.php?slug=skud"
                        }
                      ],
                      "notes": {
                        "prices": "price_label — стартовая цена «от» или «смета по объекту» (цены нет — не подставлять чужую). Точная смета — после бесплатного выезда инженера."
                      },
                      "data_generated_at": "2026-10-10T13:11:46"
                    },
                    "x-captured-from": "https://pro-system.kz/api/services.php",
                    "x-captured-at": "2026-10-10T15:43:26"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Данные каталога временно недоступны (data_unavailable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "listServices",
        "tags": [
          "services"
        ]
      }
    },
    "/api/contacts.php": {
      "get": {
        "summary": "Контакты",
        "description": "Телефон, WhatsApp, адрес, часы, реквизиты, карты.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactsResponse"
                },
                "examples": {
                  "contacts": {
                    "summary": "Контакты",
                    "value": {
                      "ok": true,
                      "contacts": {
                        "company": "Pro-System",
                        "legal_entity": "ИП Долгополов",
                        "iin": "920721301604",
                        "phone": "+77073387276",
                        "phone_display": "+7 707 338 72 76",
                        "whatsapp": "https://wa.me/77073387276",
                        "address": "г. Алматы, мкр. Коктем-2, 14",
                        "city": "Алматы",
                        "area_served": [
                          "Алматы",
                          "Алматинская область"
                        ],
                        "hours": "Ежедневно 08:00–20:00",
                        "hours_schema": "Mo-Su 08:00-20:00",
                        "free": [
                          "выезд инженера",
                          "замер и смета"
                        ],
                        "estimate": "смета за 30 минут",
                        "pages": {
                          "contacts": "https://pro-system.kz/kontakty/",
                          "about": "https://pro-system.kz/o-kompanii/",
                          "requisites": "https://pro-system.kz/o-kompanii/#rekvizity",
                          "privacy": "https://pro-system.kz/privacy/",
                          "warranty_returns": "https://pro-system.kz/vozvrat/",
                          "for_ai": "https://pro-system.kz/dlya-ii/"
                        },
                        "maps": [
                          {
                            "label": "Google",
                            "url": "https://g.page/r/Cei60gb7QozVEBM"
                          },
                          {
                            "label": "Яндекс",
                            "url": "https://yandex.ru/profile/102866794087?intent=reviews"
                          },
                          {
                            "label": "2ГИС",
                            "url": "https://2gis.kz/almaty/firm/70000001117305653/tab/reviews"
                          }
                        ],
                        "lead_channels": {
                          "site_form": "https://pro-system.kz/kontakty/#lead",
                          "agent_api": "https://pro-system.kz/api/lead.php",
                          "mcp": "https://pro-system.kz/mcp/"
                        }
                      },
                      "data_generated_at": "2026-10-10T13:11:46"
                    },
                    "x-captured-from": "https://pro-system.kz/api/contacts.php",
                    "x-captured-at": "2026-10-10T15:43:26"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Данные каталога временно недоступны (data_unavailable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "getContacts",
        "tags": [
          "company"
        ]
      }
    },
    "/api/health.php": {
      "get": {
        "summary": "Состояние и даты цен",
        "description": "Принимаются ли заявки от агентов, даты прайсов.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "examples": {
                  "health": {
                    "summary": "Состояние и даты цен",
                    "value": {
                      "ok": true,
                      "status": "ok",
                      "time": "2026-10-10T15:43:29+05:00",
                      "prices": {
                        "currency": "KZT",
                        "equipment_updated": "2026-10-05",
                        "equipment_updated_by_source": {
                          "barlau": "2026-10-05",
                          "alstyle": "2026-10-05",
                          "keeper": "2026-10-05"
                        },
                        "equipment_valid_until": "2026-11-04",
                        "equipment_stale_sources": [],
                        "equipment_stale": false,
                        "works_updated": "2026-08-14"
                      },
                      "data": {
                        "generated_at": "2026-10-10T13:11:46",
                        "build_id": "1791619906",
                        "products": 875,
                        "services": 29
                      },
                      "agent_leads": {
                        "enabled": true,
                        "accepting": true,
                        "rate_limit_key": "remote_addr",
                        "limits": {
                          "per_ip_per_hour": 3,
                          "per_day_total": 20
                        }
                      }
                    },
                    "x-captured-from": "https://pro-system.kz/api/health.php",
                    "x-captured-at": "2026-10-10T15:43:26"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Данные каталога временно недоступны (data_unavailable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "getHealth",
        "tags": [
          "company"
        ]
      }
    },
    "/api/lead.php": {
      "post": {
        "operationId": "requestCallback",
        "tags": [
          "leads"
        ],
        "summary": "Заявка на обратный звонок (ИИ-агент)",
        "parameters": [
          {
            "name": "dry_run",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "true",
                "0",
                "false"
              ]
            },
            "description": "То же, что поле dry_run в теле: 1/true — проверить и ничего не отправлять. Нераспознанное значение — 400, заявка не отправляется"
          }
        ],
        "description": "Только по явной просьбе человека. Доставка — как у формы сайта, метка «ИИ-агент». Лимиты: 3 в час с одного IP (dry_run тоже считается), 20 в сутки всего (обнуляется в полночь по Алматы). Повтор того же телефона и услуги за 30 минут возвращает прежний номер; пока такая же заявка отправляется — 409 in_progress. CORS для POST не открыт; запрос из браузера со сторонней страницы — 403. Вход OAuth 2.1 необязателен: с заголовком Authorization: Bearer (scope requests:write) у заявки свой лимит — 5 в час и 10 в сутки на клиента (dry_run тоже считается в часовом), со всех клиентов одного IP — 10 в час, — и метка «ИИ-агент (зарегистрирован)». Негодный или просроченный токен — 401 с WWW-Authenticate (resource_metadata=https://pro-system.kz/.well-known/oauth-protected-resource/api/lead.php); без заголовка — прежние лимиты. Как получить токен — https://pro-system.kz/auth.md.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadRequest"
              },
              "examples": {
                "dry_run": {
                  "summary": "Проверка без отправки",
                  "value": {
                    "name": "Айгерим",
                    "phone": "+7 707 123 45 67",
                    "service": "videonablyudenie",
                    "comment": "Частный дом, 4 камеры, звонить после 18:00",
                    "consent": true,
                    "dry_run": true
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/LeadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Заявка принята (или проверена при dry_run)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadResponse"
                },
                "examples": {
                  "lead_dry_run": {
                    "summary": "dry_run: проверка без отправки",
                    "value": {
                      "ok": true,
                      "dry_run": true,
                      "status": "validated",
                      "lead_id": null,
                      "message": "Проверка пройдена: заявка корректна и была бы принята. Ничего не отправлено.",
                      "would_deliver_to": [
                        "telegram",
                        "sheets"
                      ],
                      "normalized": {
                        "name": "Проверка Агент",
                        "phone": "+7 (707) 000-00-00",
                        "service": "videonablyudenie",
                        "comment_length": 30
                      },
                      "limits": {
                        "per_ip_per_hour": 3,
                        "used_this_hour": 1,
                        "per_day_total": 20
                      },
                      "next": "Перезвоним в рабочее время (ежедневно 08:00–20:00). Срочно — позвоните +7 707 338 72 76 или напишите в WhatsApp."
                    },
                    "x-captured-from": "https://pro-system.kz/api/lead.php",
                    "x-captured-at": "2026-10-10T15:43:30"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка в полях (validation_failed, поле fields) или тело не JSON-объект (invalid_json)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Токен в Authorization: Bearer негоден, просрочен, отозван или выдан для другого ресурса (invalid_token, invalid_request). Без заголовка Authorization 401 не бывает",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer resource_metadata=\"https://pro-system.kz/.well-known/oauth-protected-resource/api/lead.php\", scope=\"requests:write\", error=\"invalid_token\"",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Запрос со сторонней страницы в браузере (Origin, Sec-Fetch-Site) или у токена нет права requests:write (insufficient_scope)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Не POST",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Такая же заявка ещё отправляется (in_progress) — повторить через Retry-After секунд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Через сколько секунд повторить",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "413": {
            "description": "Слишком большой запрос",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит: rate_limited (час, с одного IP) или daily_limit_reached (сутки; Retry-After — до полуночи по Алматы)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "lead_rate_limited": {
                    "summary": "Превышен лимит: 3 заявки в час с одного адреса",
                    "value": {
                      "ok": false,
                      "error": "rate_limited",
                      "message": "С одного IP-адреса принимаем не больше 3 заявок в час (проверки dry_run тоже считаются). Повторите позже или пусть человек позвонит +7 707 338 72 76 или напишет в WhatsApp: https://wa.me/77073387276.",
                      "retry_after_seconds": 3598,
                      "contacts": {
                        "phone": "+7 707 338 72 76",
                        "whatsapp": "https://wa.me/77073387276",
                        "page": "https://pro-system.kz/kontakty/"
                      }
                    },
                    "x-captured-from": "https://pro-system.kz/api/lead.php",
                    "x-captured-at": "2026-10-10T15:43:32"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Через сколько секунд повторить",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "502": {
            "description": "Заявка сохранена, уведомление менеджеру не ушло (delivery_failed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Приём заявок от агентов выключен (agent_leads_disabled), заявки с токеном на паузе (registered_leads_paused), вход для агентов недоступен (auth_unavailable), доставка не настроена (delivery_unavailable) или хранилище недоступно (storage_unavailable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {},
          {
            "oauth2": [
              "requests:write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "ok",
          "error",
          "message"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string",
            "description": "Код ошибки"
          },
          "message": {
            "type": "string",
            "description": "Что случилось и что делать — по-русски"
          },
          "fields": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Ошибки по полям заявки"
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "brands": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "services": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "retry_after_seconds": {
            "type": "integer"
          },
          "contacts": {
            "$ref": "#/components/schemas/ContactsShort"
          },
          "lead_id": {
            "type": "string",
            "description": "Номер заявки: сохранена, но не доставлена (502 delivery_failed) или ещё отправляется (409 in_progress)"
          }
        }
      },
      "ContactsShort": {
        "type": "object",
        "properties": {
          "phone": {
            "type": "string"
          },
          "whatsapp": {
            "type": "string",
            "format": "uri"
          },
          "page": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Product": {
        "type": "object",
        "required": [
          "type",
          "sku",
          "name",
          "brand",
          "price_label",
          "availability",
          "url"
        ],
        "properties": {
          "type": {
            "type": "string",
            "const": "product"
          },
          "sku": {
            "type": "string",
            "description": "Артикул на сайте"
          },
          "name": {
            "type": "string",
            "description": "Название, как в H1 карточки"
          },
          "model": {
            "type": "string"
          },
          "brand": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "accessory",
              "cable",
              "camera",
              "domofon",
              "nvr",
              "signal",
              "skud",
              "switch",
              "telephony"
            ]
          },
          "category_label": {
            "type": "string"
          },
          "price": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Розничная цена в тенге; null — цены нет («цена по запросу»)"
          },
          "currency": {
            "type": "string",
            "const": "KZT"
          },
          "price_label": {
            "type": "string",
            "description": "Цена так, как на сайте: «225 740 ₸» или «цена по запросу»"
          },
          "price_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Дата прайса поставщика"
          },
          "availability": {
            "type": "string",
            "enum": [
              "in_stock",
              "backorder",
              "unknown"
            ]
          },
          "availability_text": {
            "type": "string",
            "description": "Формулировка сайта: «обычно в наличии», «под заказ, срок подтвердим», «наличие уточним сегодня»"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "image": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "ServiceShort": {
        "type": "object",
        "required": [
          "type",
          "slug",
          "name",
          "price_label",
          "url"
        ],
        "properties": {
          "type": {
            "type": "string",
            "const": "service"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "short_name": {
            "type": "string"
          },
          "price_from": {
            "type": [
              "integer",
              "null"
            ]
          },
          "price_unit": {
            "type": "string"
          },
          "price_label": {
            "type": "string",
            "description": "«от 149 000 ₸», «от 300 ₸/метр» или «смета по объекту»; в скобках бывает, к чему относится цена (например, «договор ТО»)"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "details": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Package": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "for": {
            "type": "string"
          },
          "price_from": {
            "type": "integer"
          },
          "price_label": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "ServiceFull": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "price_label",
          "url",
          "includes",
          "faq"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "short_name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "price_from": {
            "type": [
              "integer",
              "null"
            ]
          },
          "price_unit": {
            "type": "string"
          },
          "price_label": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "montage_from": {
            "type": [
              "string",
              "null"
            ]
          },
          "summary": {
            "type": "string"
          },
          "includes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Состав работ"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "price_factors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "for_whom": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "packages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Package"
            },
            "description": "Готовые комплекты"
          },
          "extra_prices": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "sub_services": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "faq": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "q": {
                  "type": "string"
                },
                "a": {
                  "type": "string"
                }
              }
            }
          },
          "price_pages": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "related_services": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "request": {
            "type": "object"
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "required": [
          "ok",
          "query",
          "total",
          "count",
          "results"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "query": {
            "type": "string"
          },
          "filters": {
            "type": "object"
          },
          "match": {
            "type": "string",
            "enum": [
              "all",
              "partial"
            ],
            "description": "all — найдены все слова запроса; partial — со всеми словами ничего, показаны совпадения по части"
          },
          "match_note": {
            "type": "string"
          },
          "total": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/Product"
                },
                {
                  "$ref": "#/components/schemas/ServiceShort"
                }
              ]
            }
          },
          "notes": {
            "type": "object"
          },
          "data_generated_at": {
            "type": "string"
          }
        }
      },
      "ServiceResponse": {
        "type": "object",
        "required": [
          "ok",
          "service"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "service": {
            "$ref": "#/components/schemas/ServiceFull"
          },
          "notes": {
            "type": "object"
          },
          "data_generated_at": {
            "type": "string"
          }
        }
      },
      "ServicesResponse": {
        "type": "object",
        "required": [
          "ok",
          "count",
          "services"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "count": {
            "type": "integer"
          },
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceShort"
            }
          },
          "notes": {
            "type": "object"
          },
          "data_generated_at": {
            "type": "string"
          }
        }
      },
      "ApiIndex": {
        "type": "object",
        "required": [
          "ok",
          "endpoints"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "name": {
            "type": "string"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          },
          "openapi": {
            "type": "string",
            "format": "uri"
          },
          "api_catalog": {
            "type": "string",
            "format": "uri"
          },
          "mcp": {
            "type": "string",
            "format": "uri"
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "method": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                }
              }
            }
          },
          "data_generated_at": {
            "type": "string"
          }
        }
      },
      "ContactsResponse": {
        "type": "object",
        "required": [
          "ok",
          "contacts"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "contacts": {
            "type": "object"
          },
          "data_generated_at": {
            "type": "string"
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "required": [
          "ok",
          "status"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "degraded"
            ]
          },
          "time": {
            "type": "string"
          },
          "prices": {
            "type": "object"
          },
          "data": {
            "type": "object"
          },
          "agent_leads": {
            "type": "object"
          }
        }
      },
      "LeadRequest": {
        "type": "object",
        "required": [
          "name",
          "phone"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 100
          },
          "phone": {
            "type": "string",
            "description": "Телефон Казахстана: +7 7XX XXX XX XX",
            "examples": [
              "+7 707 123 45 67"
            ]
          },
          "service": {
            "type": "string",
            "enum": [
              "videonablyudenie",
              "ustanovka-kamer",
              "skud",
              "domofony",
              "signalizaciya",
              "ats-telefoniya",
              "ustanovka-mini-ats",
              "remont-mini-ats",
              "telefoniya-dlya-call-centra",
              "signalizaciya-dlya-kvartiry",
              "signalizaciya-dlya-ofisa",
              "signalizaciya-dlya-doma",
              "sks-lokalnye-seti",
              "wifi-mesh",
              "videonablyudenie-dlya-doma",
              "videonablyudenie-dlya-biznesa",
              "videonablyudenie-dlya-sklada",
              "videonablyudenie-dlya-magazina",
              "videonablyudenie-dlya-kafe",
              "obsluzhivanie",
              "remont-kamer-videonablyudeniya",
              "proektirovanie",
              "elektromontazh",
              "zaryadnye-stancii",
              "chasofikaciya",
              "rechevoe-opoveshchenie",
              "proektirovanie-soue",
              "fluke-test-audit-sks",
              "pultovaya-ohrana",
              "krossy-zakazchika",
              "servery-i-oborudovanie",
              "videoanalitika",
              "raspoznavanie-nomerov",
              "raspoznavanie-lic"
            ],
            "description": "Слаг услуги (необязательно)"
          },
          "comment": {
            "type": "string",
            "maxLength": 500
          },
          "consent": {
            "type": "boolean",
            "description": "Человек согласен, чтобы с ним связались (политика /privacy/)"
          },
          "dry_run": {
            "type": "boolean",
            "description": "true — проверить и ничего не отправлять (расходует тот же часовой лимит). Значение, кроме true/false (1/0), — 400, заявка не отправляется"
          }
        },
        "additionalProperties": true
      },
      "LeadResponse": {
        "type": "object",
        "required": [
          "ok",
          "status"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "already_received",
              "validated"
            ]
          },
          "lead_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Номер заявки AG-ГГММДД-NN; null при dry_run"
          },
          "dry_run": {
            "type": "boolean"
          },
          "dedup": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "next": {
            "type": "string",
            "description": "Что будет дальше"
          },
          "would_deliver_to": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "normalized": {
            "type": "object"
          },
          "limits": {
            "type": "object"
          },
          "contacts": {
            "$ref": "#/components/schemas/ContactsShort"
          },
          "client": {
            "type": "object",
            "description": "Только при dry_run с токеном OAuth: клиент, его метка и подтверждён ли вход человеком"
          }
        }
      }
    },
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "description": "Необязательный вход для ИИ-агентов (OAuth 2.1): только для POST /api/lead.php и MCP-инструмента request_callback — свой лимит на клиента. Метаданные сервера авторизации (RFC 8414): https://pro-system.kz/.well-known/oauth-authorization-server; ресурса (RFC 9728): https://pro-system.kz/.well-known/oauth-protected-resource/api/lead.php; регистрация клиента (RFC 7591): https://pro-system.kz/oauth/register; описание — https://pro-system.kz/auth.md.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://pro-system.kz/oauth/authorize",
            "tokenUrl": "https://pro-system.kz/oauth/token",
            "refreshUrl": "https://pro-system.kz/oauth/token",
            "scopes": {
              "requests:write": "Отправлять заявку на обратный звонок от имени человека"
            }
          },
          "clientCredentials": {
            "tokenUrl": "https://pro-system.kz/oauth/token",
            "scopes": {
              "requests:write": "Отправлять заявку на обратный звонок от имени человека"
            }
          }
        }
      }
    }
  }
}
