{"openapi":"3.0.3","info":{"title":"ChatFlow Developer API","description":"Официальный REST API шлюз ChatFlow для интеграции WhatsApp, Telegram (MTProto) и Instagram Direct. Полная автоматизация переписок, отправка медиа, управление инстансами и вебхуки реального времени.","version":"1.0.0","contact":{"name":"ChatFlow Support","url":"https://chatflow.kz","email":"support@chatflow.kz"}},"servers":[{"url":"https://docs.chatflow.kz/api/v1","description":"Production Gateway (Docs & Public API)"},{"url":"https://app.chatflow.kz/api/v1","description":"Direct Application API"}],"tags":[{"name":"WhatsApp","description":"Сессии, авторизация, сообщения, медиа, чаты и группы"},{"name":"Telegram","description":"Официальные персональные аккаунты MTProto, QR-авторизация, диалоги"},{"name":"Instagram","description":"Instagram Direct API, переписки, отправка сообщений и отметки прочтения"},{"name":"Webhooks","description":"Подписка на события входящих сообщений и смены статусов"},{"name":"System","description":"Проверка доступности и автоматические тесты"}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"API токен разработчика из профиля ChatFlow"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer авторизация токеном"}},"schemas":{"StandardSuccess":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"Operation completed successfully"},"data":{"type":"object"}}},"StandardError":{"type":"object","properties":{"success":{"type":"boolean","example":false},"error":{"type":"object","properties":{"code":{"type":"string","example":"INVALID_PARAMS"},"message":{"type":"string","example":"Required parameters are missing"}}}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"paths":{"/health":{"get":{"tags":["System"],"summary":"Проверка доступности API","description":"Возвращает текущее состояние работоспособности шлюза и временную метку.","security":[],"responses":{"200":{"description":"Сервис работает штатно","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"service":{"type":"string","example":"ChatFlow Developer API"},"status":{"type":"string","example":"healthy"}}}}}}}}},"/test-suite":{"get":{"tags":["System"],"summary":"Автоматический запуск тестов API","description":"Выполняет верификацию токена, опрос баз данных всех каналов и тест санитизатора White-Label.","responses":{"200":{"description":"Результаты прогона тестов"}}}},"/whatsapp/instances":{"get":{"tags":["WhatsApp"],"summary":"Список инстансов WhatsApp","description":"Возвращает все подключенные профили WhatsApp пользователя.","responses":{"200":{"description":"Массив инстансов"}}},"post":{"tags":["WhatsApp"],"summary":"Создать новый инстанс WhatsApp","description":"Создает новый профиль и возвращает уникальный instance_id.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","example":"Отдел продаж"}}}}}},"responses":{"201":{"description":"Инстанс успешно создан"}}}},"/whatsapp/instances/{instanceId}/status":{"get":{"tags":["WhatsApp"],"summary":"Статус подключения инстанса","parameters":[{"name":"instanceId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Текущий статус"}}}},"/whatsapp/instances/{instanceId}/qr":{"get":{"tags":["WhatsApp"],"summary":"Получить QR-код для авторизации","parameters":[{"name":"instanceId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Base64 QR код"}}}},"/whatsapp/instances/{instanceId}/pairing-code":{"post":{"tags":["WhatsApp"],"summary":"Авторизация по 8-значному коду (Pairing Code)","parameters":[{"name":"instanceId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["phone"],"properties":{"phone":{"type":"string","example":"77011234567"}}}}}},"responses":{"200":{"description":"Код сгенерирован"}}}},"/whatsapp/messages/text":{"post":{"tags":["WhatsApp"],"summary":"Отправить текстовое сообщение","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["instance_id","recipient","message"],"properties":{"instance_id":{"type":"string"},"recipient":{"type":"string","example":"77011234567"},"message":{"type":"string","example":"Здравствуйте!"}}}}}},"responses":{"200":{"description":"Сообщение поставлено в очередь / отправлено"}}}},"/whatsapp/messages/media":{"post":{"tags":["WhatsApp"],"summary":"Отправить файл, картинку или документ","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["instance_id","recipient","url"],"properties":{"instance_id":{"type":"string"},"recipient":{"type":"string","example":"77011234567"},"url":{"type":"string","example":"https://example.com/invoice.pdf"},"caption":{"type":"string"},"file_name":{"type":"string"},"media_type":{"type":"string","enum":["image","video","document","voice"]}}}}}},"responses":{"200":{"description":"Файл успешно отправлен"}}}},"/whatsapp/messages/voice":{"post":{"tags":["WhatsApp"],"summary":"Отправить голосовую заметку (PTT)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["instance_id","recipient","url"],"properties":{"instance_id":{"type":"string"},"recipient":{"type":"string","example":"77011234567"},"url":{"type":"string","example":"https://example.com/audio.mp3"}}}}}},"responses":{"200":{"description":"Голосовое сообщение отправлено"}}}},"/whatsapp/messages/location":{"post":{"tags":["WhatsApp"],"summary":"Отправить геопозицию (Location)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["instance_id","recipient","latitude","longitude"],"properties":{"instance_id":{"type":"string"},"recipient":{"type":"string","example":"77011234567"},"latitude":{"type":"number","example":43.238949},"longitude":{"type":"number","example":76.889709},"name":{"type":"string","example":"Главный филиал ChatFlow"},"address":{"type":"string","example":"ул. Достык 180"}}}}}},"responses":{"200":{"description":"Геолокация отправлена"}}}},"/whatsapp/messages/contact":{"post":{"tags":["WhatsApp"],"summary":"Отправить контакт (vCard)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["instance_id","recipient","contact_phone"],"properties":{"instance_id":{"type":"string"},"recipient":{"type":"string","example":"77011234567"},"contact_name":{"type":"string","example":"Менеджер Аскар"},"contact_phone":{"type":"string","example":"77021112233"},"vcard":{"type":"string"}}}}}},"responses":{"200":{"description":"Контакт успешно передан"}}}},"/whatsapp/chats":{"get":{"tags":["WhatsApp"],"summary":"Список диалогов WhatsApp","parameters":[{"name":"instance_id","in":"query","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","default":0}}],"responses":{"200":{"description":"Список активных чатов"}}}},"/whatsapp/chats/{chatId}/messages":{"get":{"tags":["WhatsApp"],"summary":"История сообщений диалога","parameters":[{"name":"chatId","in":"path","required":true,"schema":{"type":"string"}},{"name":"instance_id","in":"query","required":true,"schema":{"type":"string"}},{"name":"count","in":"query","required":false,"schema":{"type":"integer","default":50}}],"responses":{"200":{"description":"Массив сообщений"}}}},"/whatsapp/contacts/check":{"get":{"tags":["WhatsApp"],"summary":"Проверка номера на наличие WhatsApp","parameters":[{"name":"instance_id","in":"query","required":true,"schema":{"type":"string"}},{"name":"phone","in":"query","required":true,"schema":{"type":"string","example":"77011234567"}}],"responses":{"200":{"description":"Результат верификации номера"}}}},"/telegram/instances":{"get":{"tags":["Telegram"],"summary":"Список Telegram инстансов","responses":{"200":{"description":"Список инстансов"}}},"post":{"tags":["Telegram"],"summary":"Создать новый Telegram инстанс","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","example":"Менеджер Telegram"}}}}}},"responses":{"201":{"description":"Инстанс создан"}}}},"/telegram/auth/qr":{"get":{"tags":["Telegram"],"summary":"QR-код для официальной авторизации Telegram","parameters":[{"name":"instance_id","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"QR Data URL"}}}},"/telegram/messages/text":{"post":{"tags":["Telegram"],"summary":"Отправить сообщение в Telegram","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["instance_id","recipient","message"],"properties":{"instance_id":{"type":"string"},"recipient":{"type":"string","example":"username_or_id"},"message":{"type":"string","example":"Привет!"}}}}}},"responses":{"200":{"description":"Сообщение отправлено"}}}},"/telegram/messages/media":{"post":{"tags":["Telegram"],"summary":"Отправить файл или фото в Telegram","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["instance_id","recipient","url"],"properties":{"instance_id":{"type":"string"},"recipient":{"type":"string"},"url":{"type":"string"},"caption":{"type":"string"},"media_type":{"type":"string","enum":["document","photo","video","audio"]}}}}}},"responses":{"200":{"description":"Медиа доставлено"}}}},"/telegram/chats":{"get":{"tags":["Telegram"],"summary":"Список чатов Telegram","parameters":[{"name":"instance_id","in":"query","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50}}],"responses":{"200":{"description":"Диалоги"}}}},"/instagram/instances":{"get":{"tags":["Instagram"],"summary":"Список каналов Instagram","responses":{"200":{"description":"Список подключенных аккаунтов"}}}},"/instagram/instances/{instanceId}/chats":{"get":{"tags":["Instagram"],"summary":"Список диалогов Instagram Direct","parameters":[{"name":"instanceId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Переписки"}}}},"/instagram/instances/{instanceId}/send":{"post":{"tags":["Instagram"],"summary":"Отправить сообщение в Instagram Direct","parameters":[{"name":"instanceId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["recipient","message"],"properties":{"recipient":{"type":"string","example":"ig_conv_123"},"message":{"type":"string","example":"Спасибо за обращение!"}}}}}},"responses":{"200":{"description":"Сообщение отправлено"}}}},"/webhooks":{"get":{"tags":["Webhooks"],"summary":"Получить настройки вебхука","responses":{"200":{"description":"Текущий webhook URL"}}},"delete":{"tags":["Webhooks"],"summary":"Удалить вебхук","responses":{"200":{"description":"Вебхук удален"}}}},"/webhooks/set":{"post":{"tags":["Webhooks"],"summary":"Установить Webhook URL","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string","example":"https://my-domain.com/webhook"},"secret":{"type":"string"},"events":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"Вебхук зарегистрирован"}}}}}}