{
    "info": {
        "name": "BOTIX Public API v1",
        "description": "Публичный REST API BOTIX. Документация: https://developers.botix.pro\n\nКонвертировано из Bruno-коллекции локально (scripts/bruno-to-postman.php). Источник правды — Bruno в репозитории.",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
        "_postman_id": "11111111-2222-3333-4444-555555555555"
    },
    "item": [
        {
            "name": "channels",
            "item": [
                {
                    "name": "GET /channels",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/channels",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "channels"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "description": "Список подключённых/доступных каналов БЕЗ секретов:\nтип, человекочитаемая метка, разрешён ли тарифом, подключён ли фактически.\nТокены и идентификаторы внешних аккаунтов в ответе не отдаются."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200\", function() {",
                                    "  pm.expect(pm.response.code).to.equal(200);",
                                    "});",
                                    "pm.test(\"data — массив каналов\", function() {",
                                    "  pm.expect(pm.response.json().data).to.be.an('array');",
                                    "});",
                                    "pm.test(\"у канала есть type/label/allowed/connected\", function() {",
                                    "  var ch = pm.response.json().data[0];",
                                    "  if (ch) {",
                                    "    pm.expect(ch).to.have.property('type');",
                                    "    pm.expect(ch).to.have.property('label');",
                                    "    pm.expect(ch).to.have.property('allowed');",
                                    "    pm.expect(ch).to.have.property('connected');",
                                    "  }",
                                    "});"
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        {
            "name": "chats",
            "item": [
                {
                    "name": "GET /chats",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/chats?per_page=50&status=active",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "chats"
                            ],
                            "query": [
                                {
                                    "key": "per_page",
                                    "value": "50",
                                    "disabled": false
                                },
                                {
                                    "key": "status",
                                    "value": "active",
                                    "disabled": false
                                },
                                {
                                    "key": "per_page",
                                    "value": "50",
                                    "disabled": false
                                },
                                {
                                    "key": "status",
                                    "value": "active",
                                    "disabled": false
                                },
                                {
                                    "key": "channel",
                                    "value": "telegram",
                                    "disabled": true
                                },
                                {
                                    "key": "contact_id",
                                    "value": "{{contact_id}}",
                                    "disabled": true
                                }
                            ]
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200\", function() {",
                                    "  pm.expect(pm.response.code).to.equal(200);",
                                    "});",
                                    "pm.test(\"data — массив\", function() {",
                                    "  pm.expect(pm.response.json().data).to.be.an('array');",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "GET /chats/{id}/messages",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/chats/{{chat_id}}/messages?per_page=50&page=1",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "chats",
                                "{{chat_id}}",
                                "messages"
                            ],
                            "query": [
                                {
                                    "key": "per_page",
                                    "value": "50",
                                    "disabled": false
                                },
                                {
                                    "key": "page",
                                    "value": "1",
                                    "disabled": false
                                }
                            ]
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200 OR 404\", function() {",
                                    "  pm.expect([200, 404]).to.include(pm.response.code);",
                                    "});",
                                    "pm.test(\"если 200 — data — массив\", function() {",
                                    "  if (pm.response.code === 200) {",
                                    "    pm.expect(pm.response.json().data).to.be.an('array');",
                                    "  }",
                                    "});"
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        {
            "name": "contacts",
            "item": [
                {
                    "name": "GET /contacts",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/contacts?per_page=20&page=1",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "contacts"
                            ],
                            "query": [
                                {
                                    "key": "per_page",
                                    "value": "20",
                                    "disabled": false
                                },
                                {
                                    "key": "page",
                                    "value": "1",
                                    "disabled": false
                                },
                                {
                                    "key": "per_page",
                                    "value": "20",
                                    "disabled": false
                                },
                                {
                                    "key": "page",
                                    "value": "1",
                                    "disabled": false
                                },
                                {
                                    "key": "tag",
                                    "value": "vip",
                                    "disabled": true
                                },
                                {
                                    "key": "channel",
                                    "value": "telegram",
                                    "disabled": true
                                },
                                {
                                    "key": "lead_status",
                                    "value": "new",
                                    "disabled": true
                                },
                                {
                                    "key": "since",
                                    "value": "2026-01-01T00:00:00Z",
                                    "disabled": true
                                }
                            ]
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "description": "Список контактов с пагинацией. Фильтры (опциональные):\n- tag — точное совпадение тега\n- channel — telegram/whatsapp/vk/widget/email/phone\n- lead_status — new/warm/hot/client/lost\n- since — created_at >= since (ISO-8601)\nПараметры с префиксом ~ в Bruno — отключены по умолчанию."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200\", function() {",
                                    "  pm.expect(pm.response.code).to.equal(200);",
                                    "});",
                                    "pm.test(\"data — массив\", function() {",
                                    "  pm.expect(pm.response.json().data).to.be.an('array');",
                                    "});",
                                    "pm.test(\"meta.page / per_page / total\", function() {",
                                    "  pm.expect(pm.response.json().meta).to.have.property('total');",
                                    "  pm.expect(pm.response.json().meta).to.have.property('per_page');",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "GET /contacts/{id}",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/contacts/{{contact_id}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "contacts",
                                "{{contact_id}}"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200 OR 404\", function() {",
                                    "  pm.expect([200, 404]).to.include(pm.response.code);",
                                    "});",
                                    "pm.test(\"если 200 — data.id совпадает\", function() {",
                                    "  if (pm.response.code === 200) {",
                                    "    pm.expect(String(pm.response.json().data.id)).to.equal(String(bru.getVar('contact_id')));",
                                    "  }",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "POST /contacts",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json",
                                "disabled": false
                            },
                            {
                                "key": "Idempotency-Key",
                                "value": "{{idem_key}}",
                                "disabled": false
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/public/v1/contacts",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "contacts"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"first_name\": \"Иван\",\n  \"last_name\": \"Тестов\",\n  \"phone\": \"+79001234567\",\n  \"email\": \"ivan@example.com\",\n  \"lead_status\": \"warm\",\n  \"tags\": [\"api-test\"]\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "description": "Создание контакта. Поддерживает Idempotency-Key (24ч TTL):\nповторный запрос с тем же ключом вернёт ранее созданный контакт\n+ заголовок `Idempotent-Replayed: 1`. В pre-request scripts генерим UUIDv4."
                    },
                    "event": [
                        {
                            "listen": "prerequest",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "// Уникальный Idempotency-Key для каждого запуска",
                                    "function uuidv4() {",
                                    "  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {",
                                    "    var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);",
                                    "    return v.toString(16);",
                                    "  });",
                                    "}",
                                    "bru.setVar('idem_key', 'bruno-' + uuidv4());"
                                ]
                            }
                        },
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 201\", function() {",
                                    "  pm.expect(pm.response.code).to.equal(201);",
                                    "});",
                                    "pm.test(\"data.id — число\", function() {",
                                    "  pm.expect(pm.response.json().data.id).to.be.a('number');",
                                    "});",
                                    "pm.test(\"data.first_name === 'Иван'\", function() {",
                                    "  pm.expect(pm.response.json().data.first_name).to.equal('Иван');",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "PUT /contacts/{id}",
                    "request": {
                        "method": "PUT",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json",
                                "disabled": false
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/public/v1/contacts/{{contact_id}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "contacts",
                                "{{contact_id}}"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"first_name\": \"Иван (обновлён)\",\n  \"city\": \"Москва\",\n  \"lead_status\": \"hot\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200 OR 404\", function() {",
                                    "  pm.expect([200, 404]).to.include(pm.response.code);",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "DELETE /contacts/{id}",
                    "request": {
                        "method": "DELETE",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/contacts/{{contact_id}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "contacts",
                                "{{contact_id}}"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "description": "Soft delete — контакт получает lead_status='lost'. Не удаляется физически,\nчтобы сохранить ссылочную целостность с messages/conversations."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 204 OR 404\", function() {",
                                    "  pm.expect([204, 404]).to.include(pm.response.code);",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "POST /contacts/{id}/tags",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json",
                                "disabled": false
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/public/v1/contacts/{{contact_id}}/tags",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "contacts",
                                "{{contact_id}}",
                                "tags"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"tag\": \"vip\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200 OR 404\", function() {",
                                    "  pm.expect([200, 404]).to.include(pm.response.code);",
                                    "});",
                                    "pm.test(\"если 200 — data.tags — массив\", function() {",
                                    "  if (pm.response.code === 200) {",
                                    "    pm.expect(pm.response.json().data.tags).to.be.an('array');",
                                    "  }",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "DELETE /contacts/{id}/tags/{tag}",
                    "request": {
                        "method": "DELETE",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/contacts/{{contact_id}}/tags/vip",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "contacts",
                                "{{contact_id}}",
                                "tags",
                                "vip"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200 OR 404\", function() {",
                                    "  pm.expect([200, 404]).to.include(pm.response.code);",
                                    "});"
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        {
            "name": "messages",
            "item": [
                {
                    "name": "GET /messages",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/messages?per_page=50&contact_id={{contact_id}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "messages"
                            ],
                            "query": [
                                {
                                    "key": "per_page",
                                    "value": "50",
                                    "disabled": false
                                },
                                {
                                    "key": "contact_id",
                                    "value": "{{contact_id}}",
                                    "disabled": false
                                },
                                {
                                    "key": "per_page",
                                    "value": "50",
                                    "disabled": false
                                },
                                {
                                    "key": "contact_id",
                                    "value": "{{contact_id}}",
                                    "disabled": false
                                },
                                {
                                    "key": "chat_id",
                                    "value": "{{chat_id}}",
                                    "disabled": true
                                },
                                {
                                    "key": "channel",
                                    "value": "telegram",
                                    "disabled": true
                                },
                                {
                                    "key": "role",
                                    "value": "user",
                                    "disabled": true
                                },
                                {
                                    "key": "since",
                                    "value": "2026-01-01T00:00:00Z",
                                    "disabled": true
                                }
                            ]
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200\", function() {",
                                    "  pm.expect(pm.response.code).to.equal(200);",
                                    "});",
                                    "pm.test(\"data — массив\", function() {",
                                    "  pm.expect(pm.response.json().data).to.be.an('array');",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "POST /messages",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json",
                                "disabled": false
                            },
                            {
                                "key": "Idempotency-Key",
                                "value": "{{idem_key}}",
                                "disabled": false
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/public/v1/messages",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "messages"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"contact_id\": {{contact_id}},\n  \"channel\": \"telegram\",\n  \"content\": \"Здравствуйте! Это сообщение из публичного API.\",\n  \"attachments\": []\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "description": "Отправляет сообщение через канал (Telegram/widget/VK).\n\nРезолв канала:\n1) поле `channel` в payload — приоритет;\n2) `last_channel` контакта;\n3) иначе 422 NO_CHANNEL_AVAILABLE.\n\nHTTP-коды:\n- 200 OK — отправлено каналом\n- 422 — состояние не позволяет отправить (см. data.error.code)\n- 502 DELIVERY_FAILED — канал ответил ошибкой при отправке\n\nПоддержка Idempotency-Key: повтор с тем же ключом в течение 24ч не создаёт новое сообщение."
                    },
                    "event": [
                        {
                            "listen": "prerequest",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "function uuidv4() {",
                                    "  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {",
                                    "    var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);",
                                    "    return v.toString(16);",
                                    "  });",
                                    "}",
                                    "bru.setVar('idem_key', 'bruno-' + uuidv4());"
                                ]
                            }
                        },
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200 OR 422 OR 502\", function() {",
                                    "  pm.expect([200, 422, 502]).to.include(pm.response.code);",
                                    "});",
                                    "pm.test(\"если 200 — status === 'sent'\", function() {",
                                    "  if (pm.response.code === 200) {",
                                    "    pm.expect(pm.response.json().data.status).to.equal('sent');",
                                    "  }",
                                    "});",
                                    "pm.test(\"если 422 — есть код ошибки канала\", function() {",
                                    "  if (pm.response.code === 422) {",
                                    "    var code = pm.response.json().error.code;",
                                    "    var expected = ['NO_CHANNEL_AVAILABLE','CHANNEL_NOT_SUPPORTED_YET','CHANNEL_NOT_ALLOWED','CHANNEL_NOT_CONNECTED','CONTACT_NOT_REACHABLE'];",
                                    "    pm.expect(expected).to.include(code);",
                                    "  }",
                                    "});"
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        {
            "name": "scenarios",
            "item": [
                {
                    "name": "GET /scenarios",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/scenarios",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "scenarios"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200\", function() {",
                                    "  pm.expect(pm.response.code).to.equal(200);",
                                    "});",
                                    "pm.test(\"data — массив\", function() {",
                                    "  pm.expect(pm.response.json().data).to.be.an('array');",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "POST /scenarios/{id}/run",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json",
                                "disabled": false
                            },
                            {
                                "key": "Idempotency-Key",
                                "value": "{{idem_key}}",
                                "disabled": false
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/public/v1/scenarios/{{scenario_id}}/run",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "scenarios",
                                "{{scenario_id}}",
                                "run"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"contact_id\": {{contact_id}},\n  \"channel\": \"widget\",\n  \"variables\": {\n    \"source\": \"bruno-test\"\n  },\n  \"force\": false\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "description": "Синхронно запускает сценарий для контакта.\n\n- Для widget-канала: первый блок возвращается в data.first_block / first_blocks\n- Для telegram/vk: первый блок уходит сразу пользователю в канал, в ответе — пусто\n\nЕсли контакт уже в другом сценарии — 422 CONTACT_BUSY. Передайте force=true,\nчтобы прервать предыдущий и начать новый."
                    },
                    "event": [
                        {
                            "listen": "prerequest",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "function uuidv4() {",
                                    "  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {",
                                    "    var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);",
                                    "    return v.toString(16);",
                                    "  });",
                                    "}",
                                    "bru.setVar('idem_key', 'bruno-scenario-' + uuidv4());"
                                ]
                            }
                        },
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200 OR 422 OR 404\", function() {",
                                    "  pm.expect([200, 422, 404]).to.include(pm.response.code);",
                                    "});",
                                    "pm.test(\"если 200 — data.status === 'started'\", function() {",
                                    "  if (pm.response.code === 200) {",
                                    "    pm.expect(pm.response.json().data.status).to.equal('started');",
                                    "    pm.expect(pm.response.json().data).to.have.property('conversation_id');",
                                    "  }",
                                    "});"
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        {
            "name": "service",
            "item": [
                {
                    "name": "GET /me",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/me",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "me"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "description": "Возвращает контекст текущего ключа: project_id, scopes, plan_key, остаток rate-limit.\nПолезен для отладки — клиент сразу видит, чем он аутентифицирован."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200\", function() {",
                                    "  pm.expect(pm.response.code).to.equal(200);",
                                    "});",
                                    "pm.test(\"body.success === true\", function() {",
                                    "  pm.expect(pm.response.json().success).to.equal(true);",
                                    "});",
                                    "pm.test(\"data.project_id присутствует\", function() {",
                                    "  pm.expect(pm.response.json().data).to.have.property('project_id');",
                                    "});",
                                    "pm.test(\"data.scopes — массив\", function() {",
                                    "  pm.expect(pm.response.json().data.scopes).to.be.an('array');",
                                    "});"
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        {
            "name": "webhooks",
            "item": [
                {
                    "name": "GET /webhooks",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/webhooks",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "webhooks"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200\", function() {",
                                    "  pm.expect(pm.response.code).to.equal(200);",
                                    "});",
                                    "pm.test(\"data — массив\", function() {",
                                    "  pm.expect(pm.response.json().data).to.be.an('array');",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "POST /webhooks",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json",
                                "disabled": false
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/public/v1/webhooks",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "webhooks"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"url\": \"{{example_url}}\",\n  \"events\": [\n    \"contact.created\",\n    \"contact.updated\",\n    \"message.sent\",\n    \"scenario.started\",\n    \"scenario.completed\"\n  ]\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "description": "Создание подписки. Возвращает `data.secret` ОДИН РАЗ — сохраните его на своей стороне\nдля верификации заголовка X-Botix-Signature.\n\nДопустимые события:\n- contact.created, contact.updated, contact.deleted, contact.tagged\n- message.received, message.sent\n- chat.opened, chat.closed, chat.assigned\n- scenario.started, scenario.completed, scenario.failed"
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 201\", function() {",
                                    "  pm.expect(pm.response.code).to.equal(201);",
                                    "});",
                                    "pm.test(\"data.secret присутствует\", function() {",
                                    "  pm.expect(pm.response.json().data).to.have.property('secret');",
                                    "});",
                                    "pm.test(\"Сохраняем webhook_id и secret в env\", function() {",
                                    "  if (pm.response.code === 201) {",
                                    "    bru.setEnvVar('webhook_id', pm.response.json().data.webhook.id);",
                                    "    bru.setEnvVar('webhook_secret', pm.response.json().data.secret);",
                                    "  }",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "PUT /webhooks/{id}",
                    "request": {
                        "method": "PUT",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json",
                                "disabled": false
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/public/v1/webhooks/{{webhook_id}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "webhooks",
                                "{{webhook_id}}"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"status\": \"paused\",\n  \"events\": [\"contact.created\", \"message.sent\"]\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200 OR 404\", function() {",
                                    "  pm.expect([200, 404]).to.include(pm.response.code);",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "DELETE /webhooks/{id}",
                    "request": {
                        "method": "DELETE",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/webhooks/{{webhook_id}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "webhooks",
                                "{{webhook_id}}"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 204 OR 404\", function() {",
                                    "  pm.expect([204, 404]).to.include(pm.response.code);",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "POST /webhooks/{id}/test",
                    "request": {
                        "method": "POST",
                        "header": [],
                        "url": {
                            "raw": "{{base_url}}/public/v1/webhooks/{{webhook_id}}/test",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "public",
                                "v1",
                                "webhooks",
                                "{{webhook_id}}",
                                "test"
                            ],
                            "query": []
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{api_key}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "description": "Отправляет тестовое событие `test` на URL подписки. Полезно для проверки,\nчто endpoint на стороне клиента доступен и правильно верифицирует HMAC.\n\nТестовая доставка НЕ ретраится — это одноразовая попытка."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test(\"status 200 OR 404\", function() {",
                                    "  pm.expect([200, 404]).to.include(pm.response.code);",
                                    "});",
                                    "pm.test(\"если 200 — data.delivered — boolean\", function() {",
                                    "  if (pm.response.code === 200) {",
                                    "    pm.expect(pm.response.json().data).to.have.property('delivered');",
                                    "  }",
                                    "});"
                                ]
                            }
                        }
                    ]
                }
            ]
        }
    ],
    "variable": [
        {
            "key": "base_url",
            "value": "https://api.botix.pro",
            "type": "string"
        },
        {
            "key": "api_key",
            "value": "btx_live_REPLACE_WITH_YOUR_KEY",
            "type": "string"
        },
        {
            "key": "contact_id",
            "value": "1",
            "type": "string"
        },
        {
            "key": "chat_id",
            "value": "1",
            "type": "string"
        },
        {
            "key": "scenario_id",
            "value": "1",
            "type": "string"
        },
        {
            "key": "webhook_id",
            "value": "1",
            "type": "string"
        },
        {
            "key": "example_url",
            "value": "https://example.com/botix-webhook",
            "type": "string"
        }
    ]
}