{
  "openapi": "3.1.0",
  "info": {
    "title": "Шлюз мессенджеров (MAX, WhatsApp, Telegram)",
    "version": "1.0.0",
    "description": "HTTP API в формате GREEN-API. Человекочитаемая документация: /docs. Тот же путь доступен с префиксом /v3. Имена методов не зависят от регистра. Поле x-messengers — мессенджеры, где метод работает."
  },
  "servers": [
    {
      "url": "https://message.bclife.ru"
    }
  ],
  "tags": [
    {
      "name": "Partner API"
    },
    {
      "name": "Аккаунт"
    },
    {
      "name": "Вход"
    },
    {
      "name": "Отправка"
    },
    {
      "name": "Уведомления"
    },
    {
      "name": "Журналы"
    },
    {
      "name": "Контакты"
    },
    {
      "name": "Очереди"
    },
    {
      "name": "Служебные"
    }
  ],
  "paths": {
    "/waInstance{idInstance}/getStateInstance/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "getStateInstance",
        "tags": [
          "Аккаунт"
        ],
        "summary": "Состояние инстанса",
        "description": "Подробно: /docs#getStateInstance",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "stateInstance": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getStateInstanceHistory/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "getStateInstanceHistory",
        "tags": [
          "Аккаунт"
        ],
        "summary": "История состояний, новые первыми",
        "description": "Подробно: /docs#getStateInstanceHistory",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "stateInstance": {
                        "type": "string"
                      },
                      "timestamp": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getSettings/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "getSettings",
        "tags": [
          "Аккаунт"
        ],
        "summary": "Настройки инстанса",
        "description": "Подробно: /docs#getSettings",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Settings"
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/setSettings/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "setSettings",
        "tags": [
          "Аккаунт"
        ],
        "summary": "Изменить настройки (частично)",
        "description": "Подробно: /docs#setSettings",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "saveSettings": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Settings"
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/reboot/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "reboot",
        "tags": [
          "Аккаунт"
        ],
        "summary": "Переподключиться к мессенджеру",
        "description": "Подробно: /docs#reboot",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "isReboot": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/logout/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "logout",
        "tags": [
          "Аккаунт"
        ],
        "summary": "Выйти из аккаунта мессенджера",
        "description": "Подробно: /docs#logout",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "isLogout": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getWaSettings/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "getWaSettings",
        "tags": [
          "Аккаунт"
        ],
        "summary": "Сведения об аккаунте",
        "description": "Подробно: /docs#getWaSettings",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "avatar": {
                      "type": "string"
                    },
                    "phone": {
                      "type": "string"
                    },
                    "stateInstance": {
                      "type": "string"
                    },
                    "deviceId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/qr/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "qr",
        "tags": [
          "Вход"
        ],
        "summary": "QR-код (PNG base64)",
        "description": "Подробно: /docs#qr",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "qrCode",
                        "alreadyLogged",
                        "error"
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/qrPage/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "qrPage",
        "tags": [
          "Вход"
        ],
        "summary": "Расширение: HTML-страница входа с автообновлением QR",
        "description": "Подробно: /docs#qrPage",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getAuthorizationCode/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "getAuthorizationCode",
        "tags": [
          "Вход"
        ],
        "summary": "Код для входа по номеру (WhatsApp)",
        "description": "Подробно: /docs#getAuthorizationCode",
        "x-messengers": [
          "whatsapp"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "boolean"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumber": {
                    "type": "integer",
                    "description": "номер цифрами, например 79991234567",
                    "example": 79991234567
                  }
                },
                "required": [
                  "phoneNumber"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/startAuthorization/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "startAuthorization",
        "tags": [
          "Вход"
        ],
        "summary": "Начать вход по номеру (Telegram)",
        "description": "Подробно: /docs#startAuthorization",
        "x-messengers": [
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResult"
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumber": {
                    "type": "integer",
                    "description": "номер цифрами, например 79991234567",
                    "example": 79991234567
                  }
                },
                "required": [
                  "phoneNumber"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/sendAuthorizationCode/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "sendAuthorizationCode",
        "tags": [
          "Вход"
        ],
        "summary": "Код из Telegram и, при необходимости, облачный пароль",
        "description": "Подробно: /docs#sendAuthorizationCode",
        "x-messengers": [
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResult"
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/sendAuthorizationPassword/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "sendAuthorizationPassword",
        "tags": [
          "Вход"
        ],
        "summary": "Пароль 2FA (MAX) или облачный пароль (Telegram)",
        "description": "Подробно: /docs#sendAuthorizationPassword",
        "x-messengers": [
          "max",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResult"
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "password": {
                    "type": "string"
                  }
                },
                "required": [
                  "password"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/sendMessage/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "sendMessage",
        "tags": [
          "Отправка"
        ],
        "summary": "Отправить текст (через очередь)",
        "description": "Подробно: /docs#sendMessage",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "idMessage": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chatId": {
                    "type": "string",
                    "description": "см. раздел chatId",
                    "example": "79991234567@c.us"
                  },
                  "message": {
                    "type": "string",
                    "maxLength": 4096
                  },
                  "quotedMessageId": {
                    "type": "string"
                  },
                  "typingTime": {
                    "type": "integer",
                    "minimum": 1000,
                    "maximum": 20000
                  }
                },
                "required": [
                  "chatId",
                  "message"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/sendTyping/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "sendTyping",
        "tags": [
          "Отправка"
        ],
        "summary": "Показать «печатает»",
        "description": "Подробно: /docs#sendTyping",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chatId": {
                    "type": "string",
                    "description": "см. раздел chatId",
                    "example": "79991234567@c.us"
                  }
                },
                "required": [
                  "chatId"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/receiveNotification/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        },
        {
          "name": "receiveTimeout",
          "in": "query",
          "schema": {
            "type": "integer",
            "minimum": 5,
            "maximum": 60,
            "default": 5
          }
        }
      ],
      "get": {
        "operationId": "receiveNotification",
        "tags": [
          "Уведомления"
        ],
        "summary": "Взять первое уведомление (долгий опрос до receiveTimeout секунд)",
        "description": "Подробно: /docs#receiveNotification",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "receiptId": {
                          "type": "integer"
                        },
                        "body": {
                          "$ref": "#/components/schemas/Notification"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/deleteNotification/{apiTokenInstance}/{receiptId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        },
        {
          "name": "receiptId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "delete": {
        "operationId": "deleteNotification",
        "tags": [
          "Уведомления"
        ],
        "summary": "Удалить обработанное уведомление",
        "description": "Подробно: /docs#deleteNotification",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getChatHistory/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "getChatHistory",
        "tags": [
          "Журналы"
        ],
        "summary": "История чата, новые первыми",
        "description": "Подробно: /docs#getChatHistory",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/JournalItem"
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chatId": {
                    "type": "string",
                    "description": "см. раздел chatId",
                    "example": "79991234567@c.us"
                  },
                  "count": {
                    "type": "integer",
                    "maximum": 1000
                  }
                },
                "required": [
                  "chatId"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getMessage/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "getMessage",
        "tags": [
          "Журналы"
        ],
        "summary": "Одно сообщение",
        "description": "Подробно: /docs#getMessage",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JournalItem"
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chatId": {
                    "type": "string",
                    "description": "см. раздел chatId",
                    "example": "79991234567@c.us"
                  },
                  "idMessage": {
                    "type": "string"
                  }
                },
                "required": [
                  "chatId",
                  "idMessage"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getChats/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        },
        {
          "name": "count",
          "in": "query",
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "operationId": "getChats_get",
        "tags": [
          "Журналы"
        ],
        "summary": "Список чатов",
        "description": "Подробно: /docs#getChats",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "chatId": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      },
                      "phoneNumber": {
                        "type": "string"
                      },
                      "unreadCount": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "getChats_post",
        "tags": [
          "Журналы"
        ],
        "summary": "Список чатов",
        "description": "Подробно: /docs#getChats",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "chatId": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      },
                      "phoneNumber": {
                        "type": "string"
                      },
                      "unreadCount": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/readChat/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "readChat",
        "tags": [
          "Журналы"
        ],
        "summary": "Отметить прочитанным",
        "description": "Подробно: /docs#readChat",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "setRead": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chatId": {
                    "type": "string",
                    "description": "см. раздел chatId",
                    "example": "79991234567@c.us"
                  },
                  "idMessage": {
                    "type": "string"
                  }
                },
                "required": [
                  "chatId"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/checkAccount/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "checkAccount",
        "tags": [
          "Контакты"
        ],
        "summary": "Есть ли у номера аккаунт",
        "description": "Подробно: /docs#checkAccount",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "exist": {
                      "type": "boolean"
                    },
                    "chatId": {
                      "type": "string"
                    },
                    "fromCache": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumber": {
                    "type": "integer",
                    "description": "номер цифрами, например 79991234567",
                    "example": 79991234567
                  },
                  "force": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "phoneNumber"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/checkWhatsapp/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "checkWhatsapp",
        "tags": [
          "Контакты"
        ],
        "summary": "Есть ли у номера аккаунт (формат GREEN-API WhatsApp)",
        "description": "Подробно: /docs#checkWhatsapp",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "existsWhatsapp": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumber": {
                    "type": "integer",
                    "description": "номер цифрами, например 79991234567",
                    "example": 79991234567
                  }
                },
                "required": [
                  "phoneNumber"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getContactInfo/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "getContactInfo",
        "tags": [
          "Контакты"
        ],
        "summary": "Сведения о собеседнике",
        "description": "Подробно: /docs#getContactInfo",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "avatar": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "contactName": {
                      "type": "string"
                    },
                    "chatId": {
                      "type": "string"
                    },
                    "chatType": {
                      "type": "string"
                    },
                    "lastSeen": {
                      "type": "null"
                    },
                    "phoneNumber": {
                      "type": "string"
                    },
                    "phoneNumberTimestamp": {
                      "type": "integer"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chatId": {
                    "type": "string",
                    "description": "см. раздел chatId",
                    "example": "79991234567@c.us"
                  }
                },
                "required": [
                  "chatId"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getContacts/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "getContacts",
        "tags": [
          "Контакты"
        ],
        "summary": "Адресная книга аккаунта",
        "description": "Подробно: /docs#getContacts",
        "x-messengers": [
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "contactName": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/addContact/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "addContact",
        "tags": [
          "Контакты"
        ],
        "summary": "Добавить контакт (MAX)",
        "description": "Подробно: /docs#addContact",
        "x-messengers": [
          "max"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "addContact": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Contact"
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/editContact/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "editContact",
        "tags": [
          "Контакты"
        ],
        "summary": "Переименовать контакт (MAX)",
        "description": "Подробно: /docs#editContact",
        "x-messengers": [
          "max"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "editContact": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Contact"
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/deleteContact/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "deleteContact",
        "tags": [
          "Контакты"
        ],
        "summary": "Удалить контакт (MAX)",
        "description": "Подробно: /docs#deleteContact",
        "x-messengers": [
          "max"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleteContact": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chatId": {
                    "type": "string",
                    "description": "см. раздел chatId",
                    "example": "79991234567@c.us"
                  },
                  "phoneNumber": {
                    "type": "integer",
                    "description": "номер цифрами, например 79991234567",
                    "example": 79991234567
                  }
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/importContacts/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "importContacts",
        "tags": [
          "Контакты"
        ],
        "summary": "Расширение: фоновый импорт до 10 000 контактов (MAX)",
        "description": "Подробно: /docs#importContacts",
        "x-messengers": [
          "max"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "importId": {
                      "type": "integer"
                    },
                    "status": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contacts": {
                    "type": "array",
                    "maxItems": 10000,
                    "items": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  }
                },
                "required": [
                  "contacts"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getImportContactsStatus/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "getImportContactsStatus",
        "tags": [
          "Контакты"
        ],
        "summary": "Расширение: ход импорта",
        "description": "Подробно: /docs#getImportContactsStatus",
        "x-messengers": [
          "max"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportStatus"
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "importId": {
                    "type": "integer"
                  },
                  "withResults": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "importId"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/cancelImportContacts/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "post": {
        "operationId": "cancelImportContacts",
        "tags": [
          "Контакты"
        ],
        "summary": "Расширение: отменить импорт",
        "description": "Подробно: /docs#cancelImportContacts",
        "x-messengers": [
          "max"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportStatus"
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "importId": {
                    "type": "integer"
                  }
                },
                "required": [
                  "importId"
                ]
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/showMessagesQueue/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "showMessagesQueue",
        "tags": [
          "Очереди"
        ],
        "summary": "Сообщения в очереди отправки",
        "description": "Подробно: /docs#showMessagesQueue",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "messageID": {
                        "type": "string"
                      },
                      "messagesIDs": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "type": {
                        "type": "string"
                      },
                      "body": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/clearMessagesQueue/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "clearMessagesQueue",
        "tags": [
          "Очереди"
        ],
        "summary": "Очистить очередь отправки",
        "description": "Подробно: /docs#clearMessagesQueue",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "isCleared": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getMessagesCount/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "getMessagesCount",
        "tags": [
          "Очереди"
        ],
        "summary": "Число сообщений в очереди",
        "description": "Подробно: /docs#getMessagesCount",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/getWebhooksCount/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "getWebhooksCount",
        "tags": [
          "Очереди"
        ],
        "summary": "Число недоставленных уведомлений",
        "description": "Подробно: /docs#getWebhooksCount",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/waInstance{idInstance}/clearWebhooksQueue/{apiTokenInstance}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/idInstance"
        },
        {
          "$ref": "#/components/parameters/apiTokenInstance"
        }
      ],
      "get": {
        "operationId": "clearWebhooksQueue",
        "tags": [
          "Очереди"
        ],
        "summary": "Очистить очередь уведомлений",
        "description": "Подробно: /docs#clearWebhooksQueue",
        "x-messengers": [
          "max",
          "whatsapp",
          "telegram"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "isCleared": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "ошибка запроса или инстанс не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный токен",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "инстанс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/partner/createInstance/{partnerToken}": {
      "parameters": [
        {
          "name": "partnerToken",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "createInstance",
        "tags": [
          "Partner API"
        ],
        "summary": "Создать инстанс",
        "description": "Партнёр видит только свои инстансы. Токен — в адресе или в заголовке `Authorization: Bearer <partnerToken>` (тогда адрес `/partner/{method}`). Подробно: /docs#createInstance",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "idInstance": {
                      "type": "integer"
                    },
                    "apiTokenInstance": {
                      "type": "string"
                    },
                    "typeInstance": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "неверный или отозванный токен, партнёр отключён",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "слишком частые запросы; пауза — в заголовке Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "секунд до следующей попытки"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "превышен лимит инстансов партнёра или мессенджер не разрешён",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "messenger": {
                        "type": "string",
                        "enum": [
                          "max",
                          "whatsapp",
                          "telegram"
                        ],
                        "default": "max"
                      },
                      "maxTransport": {
                        "type": "string",
                        "enum": [
                          "web"
                        ]
                      },
                      "proxyUrl": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "$ref": "#/components/schemas/Settings"
                  }
                ]
              }
            }
          }
        },
        "security": [
          {},
          {
            "partnerBearer": []
          }
        ]
      }
    },
    "/partner/deleteInstanceAccount/{partnerToken}": {
      "parameters": [
        {
          "name": "partnerToken",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "deleteInstanceAccount",
        "tags": [
          "Partner API"
        ],
        "summary": "Выйти из аккаунта и удалить инстанс",
        "description": "Партнёр видит только свои инстансы. Токен — в адресе или в заголовке `Authorization: Bearer <partnerToken>` (тогда адрес `/partner/{method}`). Подробно: /docs#deleteInstanceAccount",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleteInstanceAccount": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "неверный или отозванный токен, партнёр отключён",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "слишком частые запросы; пауза — в заголовке Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "секунд до следующей попытки"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idInstance": {
                    "type": "integer"
                  }
                },
                "required": [
                  "idInstance"
                ]
              }
            }
          }
        },
        "security": [
          {},
          {
            "partnerBearer": []
          }
        ]
      }
    },
    "/partner/getInstances/{partnerToken}": {
      "parameters": [
        {
          "name": "partnerToken",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getInstances",
        "tags": [
          "Partner API"
        ],
        "summary": "Инстансы партнёра (с токенами)",
        "description": "Партнёр видит только свои инстансы. Токен — в адресе или в заголовке `Authorization: Bearer <partnerToken>` (тогда адрес `/partner/{method}`). Подробно: /docs#getInstances",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "idInstance": {
                        "type": "integer"
                      },
                      "name": {
                        "type": "string"
                      },
                      "typeInstance": {
                        "type": "string"
                      },
                      "apiTokenInstance": {
                        "type": "string"
                      },
                      "stateInstance": {
                        "type": "string"
                      },
                      "maxTransport": {
                        "type": "string"
                      },
                      "timeCreated": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "неверный или отозванный токен, партнёр отключён",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "слишком частые запросы; пауза — в заголовке Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "секунд до следующей попытки"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {},
          {
            "partnerBearer": []
          }
        ]
      }
    },
    "/partner/getPartnerInfo/{partnerToken}": {
      "parameters": [
        {
          "name": "partnerToken",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getPartnerInfo",
        "tags": [
          "Partner API"
        ],
        "summary": "Сведения о партнёре: лимит, число инстансов, мессенджеры",
        "description": "Расширение шлюза, только для токена партнёра. Токен — в адресе или в заголовке `Authorization: Bearer <partnerToken>` (тогда адрес `/partner/{method}`). Подробно: /docs#getPartnerInfo",
        "security": [
          {},
          {
            "partnerBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "partnerId": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "active"
                      ]
                    },
                    "maxInstances": {
                      "type": "integer",
                      "description": "0 — без лимита"
                    },
                    "instances": {
                      "type": "integer"
                    },
                    "messengers": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "max",
                          "whatsapp",
                          "telegram"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "вызван общим токеном шлюза, а не токеном партнёра",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "неверный или отозванный токен, партнёр отключён",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "слишком частые запросы; пауза — в заголовке Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "секунд до следующей попытки"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/healthz": {
      "get": {
        "operationId": "healthz",
        "tags": [
          "Служебные"
        ],
        "summary": "Проверка доступности",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "idInstance": {
        "name": "idInstance",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        },
        "description": "10 цифр: 31… MAX, 11… WhatsApp, 41… Telegram"
      },
      "apiTokenInstance": {
        "name": "apiTokenInstance",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ]
      },
      "AuthResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "success",
                  "fail"
                ]
              },
              "reason": {
                "type": "string"
              },
              "retryAfter": {
                "type": "integer",
                "description": "мс, при rate_limit_exceeded"
              }
            }
          }
        }
      },
      "Settings": {
        "type": "object",
        "properties": {
          "wid": {
            "type": "string",
            "readOnly": true
          },
          "typeInstance": {
            "type": "string",
            "readOnly": true
          },
          "webhookUrl": {
            "type": "string"
          },
          "webhookUrlToken": {
            "type": "string"
          },
          "delaySendMessagesMilliseconds": {
            "type": "integer"
          },
          "markIncomingMessagesReaded": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "markIncomingMessagesReadedOnReply": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "outgoingWebhook": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "outgoingMessageWebhook": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "outgoingAPIMessageWebhook": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "stateWebhook": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "incomingWebhook": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "editedMessageWebhook": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "deletedMessageWebhook": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "pollMessageWebhook": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "downloadUrlJpeg": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "keepOnlineStatus": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ]
          },
          "enableLidMode": {
            "type": "string",
            "enum": [
              "yes",
              "no"
            ],
            "description": "только WhatsApp"
          },
          "maxTransport": {
            "type": "string",
            "readOnly": true,
            "description": "расширение, только MAX"
          }
        }
      },
      "JournalItem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "incoming",
              "outgoing"
            ]
          },
          "idMessage": {
            "type": "string"
          },
          "timestamp": {
            "type": "integer"
          },
          "typeMessage": {
            "type": "string"
          },
          "chatId": {
            "type": "string"
          },
          "chatType": {
            "type": "string"
          },
          "textMessage": {
            "type": "string"
          },
          "statusMessage": {
            "type": "string"
          },
          "sendByApi": {
            "type": "boolean"
          },
          "senderId": {
            "type": "string"
          },
          "senderName": {
            "type": "string"
          },
          "senderType": {
            "type": "string"
          },
          "senderContactName": {
            "type": "string"
          },
          "isForwarded": {
            "type": "boolean"
          },
          "forwardingScore": {
            "type": "integer"
          },
          "isEdited": {
            "type": "boolean"
          },
          "isDeleted": {
            "type": "boolean"
          }
        }
      },
      "ImportStatus": {
        "type": "object",
        "properties": {
          "importId": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "paused",
              "done",
              "failed",
              "cancelled"
            ]
          },
          "total": {
            "type": "integer"
          },
          "processed": {
            "type": "integer"
          },
          "found": {
            "type": "integer"
          },
          "notFound": {
            "type": "integer"
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          },
          "resumeAt": {
            "type": "integer"
          },
          "error": {
            "type": "string"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "phoneNumber": {
                  "type": "string"
                },
                "exist": {
                  "type": "boolean"
                },
                "chatId": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Contact": {
        "type": "object",
        "properties": {
          "chatId": {
            "type": "string",
            "description": "см. раздел chatId",
            "example": "79991234567@c.us"
          },
          "phoneNumber": {
            "type": "integer",
            "description": "номер цифрами, например 79991234567",
            "example": 79991234567
          },
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          }
        }
      },
      "Notification": {
        "type": "object",
        "properties": {
          "typeWebhook": {
            "type": "string"
          },
          "instanceData": {
            "type": "object",
            "properties": {
              "idInstance": {
                "type": "integer"
              },
              "wid": {
                "type": "string"
              },
              "typeInstance": {
                "type": "string"
              }
            }
          },
          "timestamp": {
            "type": "integer"
          }
        },
        "required": [
          "typeWebhook"
        ]
      }
    },
    "securitySchemes": {
      "partnerBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Токен партнёра в заголовке Authorization. Тогда адрес метода — /partner/{method}, без токена в конце."
      }
    }
  }
}
