{
  "openapi": "3.0.3",
  "info": {
    "title": "Touch-API / Messengers API",
    "description": "Универсальный API для работы с мессенджерами.\n\nДля всех запросов используется единая инфраструктура, канал задаётся полем `source`.\n\nПоддерживаемые каналы: `whatsapp`, `telegram`, `viber-bot`, `sms`, `vk`, `max`, `instagram`, `fbm`, `waba`, `avito`.\n\nАутентификация: `token` + `login` (или идентификатор аккаунта).\n\nНомера телефонов передаются в международном формате E.164 без символов: `12345678901`.",
    "version": "1.0.0",
    "contact": {
      "name": "Support",
      "url": "https://touch-api.com"
    }
  },
  "servers": [
    {
      "url": "https://cloud.controller.touch-api.com/api",
      "description": "Основной API"
    },
    {
      "url": "https://controller.touch-api.com/api",
      "description": "Альтернативный API"
    }
  ],
  "tags": [
    {
      "name": "Accounts",
      "description": "Управление аккаунтами"
    },
    {
      "name": "Auth",
      "description": "Авторизация, QR-коды и вход по коду"
    },
    {
      "name": "Messaging",
      "description": "Отправка и получение сообщений"
    },
    {
      "name": "Webhooks",
      "description": "Настройка вебхуков"
    },
    {
      "name": "Configuration",
      "description": "Конфигурация аккаунтов"
    },
    {
      "name": "Presence",
      "description": "Статусы активности (печать, запись)"
    }
  ],
  "paths": {
    "/addAccount": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Добавить аккаунт",
        "description": "Подключение нового аккаунта. Для некоторых каналов требуются прокси.",
        "operationId": "addAccount",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "telegram",
                    "description": "Канал"
                  },
                  "token": {
                    "type": "string",
                    "example": "YOUR_TOKEN"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890",
                    "description": "Логин (обычно номер телефона)"
                  },
                  "proxyString": {
                    "type": "string",
                    "example": "socks5://user:pass@proxy.example.com:1080",
                    "description": "Прокси (если требуется)"
                  },
                  "webhookUrl": {
                    "type": "string",
                    "example": "https://example.com/webhook",
                    "description": "URL вебхука (опционально)"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "telegram",
                "token": "YOUR_TOKEN",
                "login": "71234567890",
                "proxyString": "socks5://user:pass@proxy.example.com:1080",
                "webhookUrl": "https://example.com/webhook"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/updateAccount": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Обновить аккаунт",
        "description": "Обновление параметров аккаунта: прокси, вебхуки, конфигурация. Для удаления вебхуков передайте пустой массив webhookUrls.",
        "operationId": "updateAccount",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "proxyString": {
                    "type": "string",
                    "example": "socks5://user:pass@proxy.example.com:1080"
                  },
                  "webhookUrl": {
                    "type": "string",
                    "example": "https://example.com/webhook"
                  },
                  "webhookUrls": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Массив вебхуков (заменяет список)"
                  },
                  "config": {
                    "$ref": "#/components/schemas/AccountConfig"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "proxyString": "socks5://user:pass@proxy.example.com:1080",
                "webhookUrl": "https://example.com/webhook"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/deleteAccount": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Удалить аккаунт",
        "description": "Полное удаление аккаунта.",
        "operationId": "deleteAccount",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getInfo": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Информация об аккаунте",
        "description": "Текущее состояние аккаунта, шаг авторизации, вебхуки и настройки.",
        "operationId": "getInfo",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getInfoByToken": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Информация обо всех аккаунтах токена",
        "description": "Возвращает список аккаунтов, привязанных к API-токену.",
        "operationId": "getInfoByToken",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "skipDetails": {
                    "type": "boolean",
                    "example": true,
                    "description": "true — запросить детали по каждому; false — только defaultState"
                  }
                },
                "required": [
                  "source",
                  "token"
                ]
              },
              "example": {
                "source": "whatsapp",
                "skipDetails": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/setState": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Запустить или остановить аккаунт",
        "description": "Включение/выключение аккаунта. Для QR-авторизации (telegram) используйте qrLogin=true.",
        "operationId": "setState",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "setState": {
                    "type": "boolean",
                    "example": true,
                    "description": "true — запустить, false — остановить"
                  },
                  "qrLogin": {
                    "type": "boolean",
                    "example": false,
                    "description": "Авторизация по QR (для telegram)"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "setState"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "setState": true,
                "qrLogin": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/forceStop": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Принудительная остановка",
        "description": "Резкая остановка работающего аккаунта, когда обычный setState=false не срабатывает.",
        "operationId": "forceStop",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/clearSession": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Очистить сессию",
        "description": "Сброс текущей сессии, после чего потребуется повторная авторизация.",
        "operationId": "clearSession",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getNewProxy": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Получить новый прокси",
        "description": "Запросить замену прокси-адреса для аккаунта.",
        "operationId": "getNewProxy",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getMe": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Информация о текущем подключении (telegram)",
        "description": "Возвращает username и phone подключённого Telegram-аккаунта.",
        "operationId": "getMe",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "telegram"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "telegram",
                "login": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getQr": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Получить данные для QR-кода",
        "description": "Возвращает строку для построения QR-кода авторизации. Актуально на шаге step=2.2. Код обновляется раз в ~10 секунд.",
        "operationId": "getQr",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/enablePhoneAuth": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Включить авторизацию по коду",
        "description": "Переводит аккаунт в режим входа по коду вместо QR (например для WhatsApp).",
        "operationId": "enablePhoneAuth",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "phone": {
                    "type": "string",
                    "example": "71234567890",
                    "description": "Номер, на который отправлять код"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "phone"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "phone": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/disablePhoneAuth": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Выключить авторизацию по коду",
        "description": "Возвращает аккаунт к авторизации через QR.",
        "operationId": "disablePhoneAuth",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getAuthCode": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Получить код для входа",
        "description": "Возвращает код, который нужно ввести в приложении (например WhatsApp Linked Devices).",
        "operationId": "getAuthCode",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/solveChallenge": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Подтвердить код (challenge)",
        "description": "Отправка кода для входа, полученного в SMS или мессенджере. Используется при ошибке Challenge required.",
        "operationId": "solveChallenge",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "telegram"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "code": {
                    "type": "string",
                    "example": "12345",
                    "description": "Код из сообщения"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "code"
                ]
              },
              "example": {
                "source": "telegram",
                "login": "71234567890",
                "code": "12345"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/twoFactorAuth": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Ввести 2FA-пароль",
        "description": "Отправка двухфакторного пароля Telegram при включённой 2FA.",
        "operationId": "twoFactorAuth",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "telegram"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "code": {
                    "type": "string",
                    "example": "your_2fa_password",
                    "description": "Пароль 2FA"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "telegram",
                "login": "71234567890",
                "code": "your_2fa_password"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/sendMessage": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Отправить сообщение",
        "description": "Отправка текста или вложений. Можно передать объект msg, либо плоские параметры msg_to/msg_text/...",
        "operationId": "sendMessage",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "msg": {
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/MsgObject"
                      }
                    ]
                  },
                  "msg_to": {
                    "type": "string",
                    "example": "71234567891",
                    "description": "Альтернатива msg: получатель"
                  },
                  "msg_text": {
                    "type": "string",
                    "example": "Привет!",
                    "description": "Альтернатива msg: текст"
                  },
                  "msg_content_type": {
                    "type": "string",
                    "example": "image",
                    "description": "Альтернатива msg: тип вложения"
                  },
                  "msg_content_src": {
                    "type": "string",
                    "example": "https://example.com/image.jpg",
                    "description": "Альтернатива msg: URL вложения"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "msg_to": "71234567891",
                "msg_text": "Привет!",
                "msg_content_type": "image",
                "msg_content_src": "https://example.com/image.jpg"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getChatMessages": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Получить историю сообщений",
        "description": "Возвращает массив сообщений из чата.",
        "operationId": "getChatMessages",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "to": {
                    "type": "string",
                    "example": "71234567891",
                    "description": "Контакт или группа"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "to"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "to": "71234567891"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getChatMessageByItem": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Получить конкретное сообщение",
        "description": "Возвращает сообщение по его item ID.",
        "operationId": "getChatMessageByItem",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "to": {
                    "type": "string",
                    "example": "71234567891"
                  },
                  "item": {
                    "type": "string",
                    "example": "3EB0C15F4D9A2B7C8E1F",
                    "description": "ID сообщения"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "item"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "to": "71234567891",
                "item": "3EB0C15F4D9A2B7C8E1F"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getUserInfo": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Данные о пользователе",
        "description": "Профиль контакта: имя, номер, аватар, бизнес-статус и т.д.",
        "operationId": "getUserInfo",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "to": {
                    "type": "string",
                    "example": "71234567891",
                    "description": "Контакт"
                  },
                  "allowContactCreation": {
                    "type": "boolean",
                    "example": true,
                    "description": "Создать контакт при отсутствии (telegram)"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "to"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "to": "71234567891",
                "allowContactCreation": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/sendTyping": {
      "post": {
        "tags": [
          "Presence"
        ],
        "summary": "Показать «печатает»",
        "description": "Отправляет собеседнику индикатор набора текста (~20 секунд).",
        "operationId": "sendTyping",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "to": {
                    "type": "string",
                    "example": "71234567891"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "to"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "to": "71234567891"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/resetTyping": {
      "post": {
        "tags": [
          "Presence"
        ],
        "summary": "Сбросить индикатор «печатает»",
        "description": "Досрочно сбрасывает отправленный индикатор набора текста.",
        "operationId": "resetTyping",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "to": {
                    "type": "string",
                    "example": "71234567891"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "to"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "to": "71234567891"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/sendRecording": {
      "post": {
        "tags": [
          "Presence"
        ],
        "summary": "Показать «запись голосового»",
        "description": "Отправляет индикатор записи аудиосообщения (~20 секунд).",
        "operationId": "sendRecording",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "to": {
                    "type": "string",
                    "example": "71234567891"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "to"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "to": "71234567891"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/addWebhook": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Добавить URL вебхука",
        "description": "Регистрирует новый URL для приёма входящих событий (сообщений, статусов и т.д.).",
        "operationId": "addWebhook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "webhookUrl": {
                    "type": "string",
                    "example": "https://example.com/webhook"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "webhookUrl"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "webhookUrl": "https://example.com/webhook"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/deleteWebhook": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Удалить URL вебхука",
        "description": "Удаляет зарегистрированный URL из списка вебхуков.",
        "operationId": "deleteWebhook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "whatsapp"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "webhookUrl": {
                    "type": "string",
                    "example": "https://example.com/webhook"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "webhookUrl"
                ]
              },
              "example": {
                "source": "whatsapp",
                "login": "71234567890",
                "webhookUrl": "https://example.com/webhook"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getConfigList": {
      "post": {
        "tags": [
          "Configuration"
        ],
        "summary": "Список конфигураций",
        "description": "Возвращает список сохранённых конфигураций для токена/аккаунта.",
        "operationId": "getConfigList",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "telegram"
                  },
                  "token": {
                    "type": "string"
                  }
                },
                "required": [
                  "source",
                  "token"
                ]
              },
              "example": {
                "source": "telegram"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getConfig": {
      "post": {
        "tags": [
          "Configuration"
        ],
        "summary": "Получить конфигурацию",
        "description": "Возвращает конфигурацию по имени.",
        "operationId": "getConfig",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "telegram"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "name": {
                    "type": "string",
                    "example": "my_config"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "name"
                ]
              },
              "example": {
                "source": "telegram",
                "login": "71234567890",
                "name": "my_config"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/setConfig": {
      "post": {
        "tags": [
          "Configuration"
        ],
        "summary": "Установить конфигурацию",
        "description": "Создаёт или обновляет конфигурацию для аккаунта.",
        "operationId": "setConfig",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "example": "telegram"
                  },
                  "token": {
                    "type": "string"
                  },
                  "login": {
                    "type": "string",
                    "example": "71234567890"
                  },
                  "name": {
                    "type": "string",
                    "example": "my_config"
                  },
                  "config": {
                    "$ref": "#/components/schemas/AccountConfig"
                  }
                },
                "required": [
                  "source",
                  "token",
                  "login",
                  "name",
                  "config"
                ]
              },
              "example": {
                "source": "telegram",
                "login": "71234567890",
                "name": "my_config"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/screenshot": {
      "get": {
        "tags": [
          "Auth"
        ],
        "summary": "Скриншот QR-кода (whatsapp)",
        "description": "Возвращает PNG-изображение с QR-кодом для авторизации. Если серверы недоступны из РФ, добавьте параметр useAlternativeAddress=1.",
        "operationId": "getScreenshot",
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "login",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "source",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "default": "whatsapp"
            }
          },
          {
            "name": "useAlternativeAddress",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PNG QR",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SuccessResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "ok"
          },
          "uuid": {
            "type": "string",
            "example": "8bed4fe3-8221-4ecf-b696-a05e7af6f335"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "error"
          },
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "example": "Access denied"
              }
            }
          },
          "uuid": {
            "type": "string",
            "description": "ID ошибки для поддержки"
          }
        }
      },
      "AccountStep": {
        "type": "object",
        "description": "Текущий шаг авторизации аккаунта",
        "properties": {
          "message": {
            "type": "string",
            "example": "QR code received"
          },
          "value": {
            "type": "number",
            "example": 2.2
          }
        }
      },
      "AccountConfig": {
        "type": "object",
        "properties": {
          "services": {
            "type": "object",
            "properties": {
              "authMethod": {
                "type": "string",
                "enum": [
                  "qr",
                  "code"
                ]
              },
              "stateHook": {
                "type": "boolean",
                "description": "Хуки на изменение состояния"
              },
              "outgoingOnlyHook": {
                "type": "boolean",
                "description": "Только исходящие вебхуки"
              }
            }
          },
          "conflict": {
            "type": "object",
            "properties": {
              "takeover": {
                "type": "boolean",
                "description": "Автоматически принимать управление (кнопка «Использовать здесь»)"
              },
              "takeoverTimeoutMs": {
                "type": "integer",
                "example": 10000,
                "description": "Задержка перед перехватом, мс"
              }
            }
          }
        }
      },
      "AccountInfo": {
        "type": "object",
        "description": "Информация об аккаунте",
        "properties": {
          "source": {
            "type": "string",
            "example": "whatsapp"
          },
          "login": {
            "type": "string",
            "example": "71234567890"
          },
          "owner": {
            "type": "string"
          },
          "activated": {
            "type": "boolean"
          },
          "addedTime": {
            "type": "integer",
            "format": "int64",
            "description": "Timestamp (мс)"
          },
          "webhookUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "webhookUrls": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "proxyString": {
            "type": "string"
          },
          "defaultState": {
            "type": "boolean"
          },
          "APIv": {
            "type": "string",
            "example": "stable/s30"
          },
          "state": {
            "type": "boolean"
          },
          "step": {
            "$ref": "#/components/schemas/AccountStep"
          },
          "status": {
            "type": "string",
            "example": "ok"
          },
          "uuid": {
            "type": "string"
          },
          "lastAuthorizedAt": {
            "type": "integer",
            "format": "int64"
          },
          "additional": {
            "type": "object",
            "properties": {
              "isBeta": {
                "type": "boolean"
              },
              "config": {
                "$ref": "#/components/schemas/AccountConfig"
              }
            }
          }
        }
      },
      "AccountInfoByToken": {
        "type": "object",
        "description": "Ответ /getInfoByToken",
        "properties": {
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountInfo"
            }
          },
          "summary": {
            "type": "object",
            "properties": {
              "active": {
                "type": "integer"
              },
              "activated": {
                "type": "integer"
              },
              "demo": {
                "type": "integer"
              },
              "count": {
                "type": "integer"
              },
              "payment": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "per day",
                      "per month"
                    ]
                  },
                  "balance": {
                    "type": "number"
                  }
                }
              }
            }
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "example": "ok"
          },
          "uuid": {
            "type": "string"
          }
        }
      },
      "MeResponse": {
        "type": "object",
        "properties": {
          "username": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          }
        }
      },
      "QrResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "ok"
          },
          "uuid": {
            "type": "string"
          },
          "value": {
            "type": "string",
            "description": "Содержимое для QR"
          }
        }
      },
      "AuthCodeResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "ok"
          },
          "uuid": {
            "type": "string"
          },
          "value": {
            "type": "string",
            "description": "Код для ввода"
          }
        }
      },
      "ClearSessionResponse": {
        "type": "object",
        "properties": {
          "forceStop": {
            "type": "boolean"
          },
          "clearSession": {
            "type": "boolean"
          },
          "getNewProxy": {
            "type": "boolean"
          }
        }
      },
      "MessageContentItem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "audio",
              "file",
              "link",
              "geo",
              "contact",
              "multi-contact",
              "scheduled-event"
            ],
            "description": "Тип контента"
          },
          "src": {
            "type": "string",
            "description": "URL файла / JSON-строка для geo/contact / описание для link"
          },
          "filename": {
            "type": "string",
            "description": "Имя файла"
          }
        }
      },
      "MsgObject": {
        "type": "object",
        "description": "Объект сообщения для /sendMessage",
        "properties": {
          "to": {
            "type": "string",
            "description": "Получатель (телефон/username/ID)"
          },
          "text": {
            "type": [
              "string",
              "null"
            ],
            "description": "Текст (если content пуст)"
          },
          "content": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessageContentItem"
            },
            "description": "Вложения (если text пуст)"
          }
        },
        "required": [
          "to"
        ]
      },
      "SendMessageResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "ok"
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "result": {
            "type": "object",
            "properties": {
              "thread": {
                "type": "string",
                "example": "71234567890@c.us"
              },
              "item": {
                "type": "string",
                "description": "ID сообщения"
              },
              "timestamp": {
                "type": "integer",
                "format": "int64",
                "description": "Время (мкс)"
              }
            }
          }
        }
      },
      "SendMessageResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "ok"
          },
          "uuid": {
            "type": "string"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SendMessageResult"
            }
          }
        }
      },
      "UserInfoResponse": {
        "type": "object",
        "description": "Информация о контакте",
        "properties": {
          "number": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "pushname": {
            "type": "string"
          },
          "shortName": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "isBusiness": {
            "type": "boolean"
          },
          "isEnterprise": {
            "type": "boolean"
          },
          "labels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "statusMute": {
            "type": "boolean"
          },
          "isMe": {
            "type": "boolean"
          },
          "isUser": {
            "type": "boolean"
          },
          "isGroup": {
            "type": "boolean"
          },
          "isWAContact": {
            "type": "boolean"
          },
          "isMyContact": {
            "type": "boolean"
          },
          "isBlocked": {
            "type": "boolean"
          },
          "pictureUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "example": "ok"
          }
        }
      }
    }
  }
}