{
  "info": {
    "name": "Senden API — интеграции",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Bearer API рабочего пространства. Read-only по умолчанию: все изменения пропускаются, пока allowWrites != true. Создайте именованный ключ в кабинете. Ключ не управляет аккаунтом/администратором. 202 != доставка; неизвестный исход не повторять новым ключом."
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{SendenAPIKey}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://api-senden.ru/api/v1",
      "type": "string"
    },
    {
      "key": "SendenAPIKey",
      "value": "",
      "type": "string"
    },
    {
      "key": "allowWrites",
      "value": "false",
      "type": "string"
    },
    {
      "key": "instanceId",
      "value": "",
      "type": "string"
    },
    {
      "key": "chatId",
      "value": "",
      "type": "string"
    },
    {
      "key": "groupId",
      "value": "",
      "type": "string"
    },
    {
      "key": "participantChatId",
      "value": "",
      "type": "string"
    },
    {
      "key": "phoneNumber",
      "value": "",
      "type": "string"
    },
    {
      "key": "providerMessageId",
      "value": "",
      "type": "string"
    },
    {
      "key": "messageId",
      "value": "",
      "type": "string"
    },
    {
      "key": "fileId",
      "value": "",
      "type": "string"
    },
    {
      "key": "receiptId",
      "value": "",
      "type": "string"
    },
    {
      "key": "jobId",
      "value": "",
      "type": "string"
    },
    {
      "key": "idempotencyKey",
      "value": "",
      "type": "string"
    },
    {
      "key": "assetName",
      "value": "README.txt",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Чтение и discovery",
      "item": [
        {
          "name": "GET /api/v1/events",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/events",
            "description": "События с курсором\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/files/{fileId}",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/files/{{fileId}}",
            "description": "Скачать ранее загруженный локальный файл\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/health",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/health",
            "description": "Проверка процесса\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/instances",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances",
            "description": "Получить активные или архивные подключения\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/instances/{id}",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}",
            "description": "Состояние подключения\nScope: read. Connected: false. Messengers: whatsapp, telegram, max."
          }
        },
        {
          "name": "GET /api/v1/instances/{id}/chats",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}/chats",
            "description": "Получить чаты\nScope: read. Connected: true."
          }
        },
        {
          "name": "GET /api/v1/instances/{id}/deliveries",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}/deliveries",
            "description": "Результаты доставки webhook\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/instances/{id}/deliveries/{jobId}/attempts",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}/deliveries/{{jobId}}/attempts",
            "description": "Журнал попыток webhook\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/instances/{id}/deliveries/stats",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}/deliveries/stats",
            "description": "Счётчики заданий webhook\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/instances/{id}/messages",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}/messages",
            "description": "Сохранённая история сообщений\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/instances/{id}/notifications/stats",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}/notifications/stats",
            "description": "Число ожидающих и обработанных уведомлений\nScope: read. Connected: false."
          }
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/account.settings.get",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/account.settings.get",
            "description": "Профиль подключённого аккаунта\nScope: read. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/chats.reactions",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/chats.reactions",
            "description": "Получить доступные реакции\nScope: read. Connected: true. Messengers: telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/contacts.get",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/contacts.get",
            "description": "Информация о контакте\nScope: read. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/contacts.list",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/contacts.list",
            "description": "Список контактов\nScope: read. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/contacts.lookup",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/contacts.lookup",
            "description": "Проверить наличие аккаунта по телефону или ID\nScope: read. Connected: true. Messengers: whatsapp, telegram, max.\nMAX: chatId в ответе — user ID, не ID приватного чата для отправки.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"phoneNumber\": \"{{phoneNumber}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/groups.get",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/groups.get",
            "description": "Информация о группе\nScope: read. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"groupId\": \"{{groupId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.get",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.get",
            "description": "Получить сообщение из мессенджера\nScope: read. Connected: true. Messengers: telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"idMessage\": \"{{providerMessageId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.history",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.history",
            "description": "Загрузить историю из мессенджера\nScope: read. Connected: true. Messengers: telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"count\": 50\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/profile.avatar.get",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/profile.avatar.get",
            "description": "Получить аватар\nScope: read. Connected: true. Messengers: whatsapp.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "GET /api/v1/instances/{id}/queue",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}/queue",
            "description": "Постоянная очередь сообщений\nScope: read. Connected: false. Messengers: whatsapp, telegram, max."
          }
        },
        {
          "name": "GET /api/v1/instances/{id}/settings",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}/settings",
            "description": "Настройки подключения и событий\nScope: read. Connected: false. Messengers: whatsapp, telegram, max."
          }
        },
        {
          "name": "GET /api/v1/integrations/files/{name}",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/integrations/files/{{assetName}}",
            "description": "Скачать шаблон интеграции или общий ZIP без личных данных\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/integrations/manifest",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/integrations/manifest",
            "description": "Подключения текущего пространства, команды и готовые файлы интеграции без ключей и данных авторизации\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/methods",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/methods",
            "description": "Каталог доступных операций\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/status",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/status",
            "description": "Подключения и состояния\nScope: read. Connected: false."
          }
        },
        {
          "name": "GET /api/v1/stream",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/stream",
            "description": "Поток событий SSE\nScope: read. Connected: false."
          }
        }
      ]
    },
    {
      "name": "Изменения — только явно разрешённые",
      "item": [
        {
          "name": "PUT /api/v1/config",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/config",
            "description": "Настройки приложения и сетевых подключений\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/files",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/octet-stream"
              },
              {
                "key": "X-Filename",
                "value": "document.pdf"
              },
              {
                "key": "X-File-Mime",
                "value": "application/pdf"
              }
            ],
            "url": "{{baseUrl}}/files",
            "description": "Загрузить файл до 20 МБ\nScope: write. Connected: false.",
            "body": {
              "mode": "file",
              "file": {
                "src": ""
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances",
            "description": "Создать подключение\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Новое подключение\",\n  \"messenger\": \"max\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "DELETE /api/v1/instances/{id}",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}",
            "description": "Остановить и архивировать подключение с сохранением истории и сессии\nScope: write. Connected: false."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "PATCH /api/v1/instances/{id}",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}",
            "description": "Изменить название подключения\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Название подключения\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/auth",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/auth",
            "description": "Продолжить текущий шаг входа\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/connect",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/connect",
            "description": "Начать вход\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"mode\": \"qr\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/deliveries/{jobId}/retry",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/deliveries/{{jobId}}/retry",
            "description": "Повторить webhook из dead-letter\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/deliveries/clear",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/deliveries/clear",
            "description": "Отменить ожидающие, повторяемые и dead-letter webhook\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/logout",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/logout",
            "description": "Запросить выход\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/messages",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/messages",
            "description": "Поставить текст или файл в очередь\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"{{chatId}}\",\n  \"text\": \"Сообщение из вашей интеграции\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/messages/from-url",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/messages/from-url",
            "description": "Безопасно загрузить HTTPS-файл и поставить документ в очередь\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"{{chatId}}\",\n  \"urlFile\": \"https://files.example.org/document.pdf\",\n  \"fileName\": \"document.pdf\",\n  \"caption\": \"Документ\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "DELETE /api/v1/instances/{id}/notifications/{receiptId}",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": "{{baseUrl}}/instances/{{instanceId}}/notifications/{{receiptId}}",
            "description": "Подтвердить обработку текущей квитанции\nScope: write. Connected: false."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/notifications/receive",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/notifications/receive",
            "description": "Получить уведомление с арендой и ожиданием\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"timeoutSeconds\": 0,\n  \"leaseSeconds\": 30\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/chats.archive",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/chats.archive",
            "description": "Архивировать чат\nScope: write. Connected: true. Messengers: whatsapp, telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/chats.expiration",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/chats.expiration",
            "description": "Настроить исчезающие сообщения\nScope: write. Connected: true. Messengers: whatsapp, telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"ephemeralExpiration\": 86400\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/chats.typing",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/chats.typing",
            "description": "Показать индикатор набора\nScope: write. Connected: true. Messengers: whatsapp, telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/chats.unarchive",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/chats.unarchive",
            "description": "Вернуть чат из архива\nScope: write. Connected: true. Messengers: whatsapp, telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/contacts.create",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/contacts.create",
            "description": "Добавить контакт\nScope: write. Connected: true. Messengers: telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"firstName\": \"Имя\",\n  \"phoneNumber\": \"{{phoneNumber}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/contacts.delete",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/contacts.delete",
            "description": "Удалить контакт\nScope: write. Connected: true. Messengers: telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/contacts.update",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/contacts.update",
            "description": "Изменить контакт\nScope: write. Connected: true. Messengers: telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"firstName\": \"Новое имя\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/groups.admins.add",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/groups.admins.add",
            "description": "Назначить администратора группы\nScope: write. Connected: true. Messengers: whatsapp.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"groupId\": \"{{groupId}}\",\n  \"participantChatId\": \"{{participantChatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/groups.admins.remove",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/groups.admins.remove",
            "description": "Снять администратора группы\nScope: write. Connected: true. Messengers: whatsapp.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"groupId\": \"{{groupId}}\",\n  \"participantChatId\": \"{{participantChatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/groups.create",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/groups.create",
            "description": "Создать группу\nScope: write. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"groupName\": \"Моя группа\",\n  \"chatIds\": [\n    \"CHAT_ID\"\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/groups.leave",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/groups.leave",
            "description": "Покинуть группу\nScope: write. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"groupId\": \"{{groupId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/groups.members.add",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/groups.members.add",
            "description": "Добавить участника\nScope: write. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"groupId\": \"{{groupId}}\",\n  \"participantChatId\": \"{{participantChatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/groups.members.remove",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/groups.members.remove",
            "description": "Удалить участника\nScope: write. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"groupId\": \"{{groupId}}\",\n  \"participantChatId\": \"{{participantChatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/groups.rename",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/groups.rename",
            "description": "Изменить название группы\nScope: write. Connected: true. Messengers: whatsapp, telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"groupId\": \"{{groupId}}\",\n  \"groupName\": \"Новое название\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/groups.settings",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/groups.settings",
            "description": "Изменить одно разрешение группы\nScope: write. Connected: true. Messengers: whatsapp.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"groupId\": \"{{groupId}}\",\n  \"announcement\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.contact",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.contact",
            "description": "Отправить карточку контакта\nScope: write. Connected: true. Messengers: whatsapp, telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"contact\": {\n    \"phoneContact\": \"{{phoneNumber}}\",\n    \"firstName\": \"Имя\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.delete",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.delete",
            "description": "Удалить сообщение\nScope: write. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"idMessage\": \"{{providerMessageId}}\",\n  \"onlySenderDelete\": false\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.edit",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.edit",
            "description": "Изменить текст сообщения\nScope: write. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"idMessage\": \"{{providerMessageId}}\",\n  \"message\": \"Новый текст\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.forward",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.forward",
            "description": "Переслать выбранные сообщения\nScope: write. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"chatIdFrom\": \"{{chatId}}\",\n  \"messages\": [\n    \"{{providerMessageId}}\"\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.location",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.location",
            "description": "Отправить местоположение\nScope: write. Connected: true. Messengers: whatsapp, telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"latitude\": 55.75,\n  \"longitude\": 37.62\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.poll",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.poll",
            "description": "Отправить опрос\nScope: write. Connected: true. Messengers: whatsapp, telegram.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"message\": \"Ваш выбор?\",\n  \"options\": [\n    \"Первый\",\n    \"Второй\"\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.react",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.react",
            "description": "Изменить реакцию на сообщение\nScope: write. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\",\n  \"idMessage\": \"{{providerMessageId}}\",\n  \"reaction\": \"👍\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/operations/messages.read",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/operations/messages.read",
            "description": "Отметить сообщения прочитанными\nScope: write. Connected: true. Messengers: whatsapp, telegram, max.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatId\": \"{{chatId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }",
                  "else { const key = pm.variables.get('idempotencyKey'); if (typeof key !== 'string' || key.trim().length < 8 || key.length > 128) { pm.execution.skipRequest(); throw new Error('Set an explicit stable idempotencyKey (8..128 characters).'); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/queue/{messageId}/cancel",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/queue/{{messageId}}/cancel",
            "description": "Отменить одно queued сообщение\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/queue/{messageId}/retry",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/queue/{{messageId}}/retry",
            "description": "Повторить только подтверждённую ошибку failed\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/queue/clear",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/queue/clear",
            "description": "Отменить все queued сообщения\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/restore",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/restore",
            "description": "Восстановить из архива в пределах лимитов, без автоматического подключения\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "PUT /api/v1/instances/{id}/settings",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/settings",
            "description": "Изменить настройки\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sendDelayMs\": 1000\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/instances/{id}/stop",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{baseUrl}}/instances/{{instanceId}}/stop",
            "description": "Остановить с сохранением сессии\nScope: write. Connected: false.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.variables.get('allowWrites') !== 'true') { pm.execution.skipRequest(); }"
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}
