{
  "info": {
    "name": "Chatbeep Public API",
    "_postman_id": "c7d0d6b0-chatbeep-public-api-v1",
    "description": "Collection pública do Chatbeep para health, widget, verificação e operações mobile maduras em /api/v1.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url", "value": "https://sandbox.chatbeep.app/api/v1" },
    { "key": "widget_token", "value": "pub_demo_installation_token" },
    { "key": "visitor_uuid", "value": "11111111-1111-4111-8111-111111111111" },
    { "key": "conversation_id", "value": "" },
    { "key": "mobile_token", "value": "" }
  ],
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "Get Health",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/health",
              "host": ["{{base_url}}"],
              "path": ["health"]
            }
          }
        }
      ]
    },
    {
      "name": "Widget",
      "item": [
        {
          "name": "Get Widget Config",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/widget/config/{{widget_token}}",
              "host": ["{{base_url}}"],
              "path": ["widget", "config", "{{widget_token}}"]
            }
          }
        },
        {
          "name": "Create Visitor",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const payload = pm.response.json();",
                  "const uuid = payload?.data?.uuid;",
                  "if (uuid) pm.collectionVariables.set('visitor_uuid', uuid);"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"token\": \"{{widget_token}}\",\n  \"uuid\": \"{{visitor_uuid}}\",\n  \"name\": \"Visitor Demo\",\n  \"email\": \"visitor@example.com\",\n  \"current_url\": \"https://example.com/help\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/widget/visitors",
              "host": ["{{base_url}}"],
              "path": ["widget", "visitors"]
            }
          }
        },
        {
          "name": "Create Widget Conversation",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const payload = pm.response.json();",
                  "const publicId = payload?.data?.conversation?.id;",
                  "if (publicId) pm.collectionVariables.set('conversation_id', publicId);"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"token\": \"{{widget_token}}\",\n  \"visitor_uuid\": \"{{visitor_uuid}}\",\n  \"subject\": \"Pedido de suporte\",\n  \"message\": \"Olá. Preciso de ajuda com o widget.\",\n  \"privacy_accepted\": true,\n  \"current_url\": \"https://example.com/help\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/widget/conversations",
              "host": ["{{base_url}}"],
              "path": ["widget", "conversations"]
            }
          }
        },
        {
          "name": "Get Widget Messages",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/widget/conversations/{{conversation_id}}/messages?token={{widget_token}}&after_id=1",
              "host": ["{{base_url}}"],
              "path": ["widget", "conversations", "{{conversation_id}}", "messages"],
              "query": [
                { "key": "token", "value": "{{widget_token}}" },
                { "key": "after_id", "value": "1" }
              ]
            }
          }
        },
        {
          "name": "Create Widget Message",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"token\": \"{{widget_token}}\",\n  \"body\": \"Mensagem enviada pelo visitante via Postman\",\n  \"current_url\": \"https://example.com/help\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/widget/conversations/{{conversation_id}}/messages",
              "host": ["{{base_url}}"],
              "path": ["widget", "conversations", "{{conversation_id}}", "messages"]
            }
          }
        }
      ]
    },
    {
      "name": "Mobile",
      "item": [
        {
          "name": "Mobile Login",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const payload = pm.response.json();",
                  "const token = payload?.data?.token;",
                  "if (token) pm.collectionVariables.set('mobile_token', token);"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"operator@example.com\",\n  \"password\": \"CHANGE_ME\",\n  \"device_name\": \"postman-sandbox\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/mobile/login",
              "host": ["{{base_url}}"],
              "path": ["mobile", "login"]
            }
          }
        },
        {
          "name": "Get Mobile Me",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{mobile_token}}" }
            ],
            "url": {
              "raw": "{{base_url}}/mobile/me",
              "host": ["{{base_url}}"],
              "path": ["mobile", "me"]
            }
          }
        },
        {
          "name": "List Mobile Conversations",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{mobile_token}}" }
            ],
            "url": {
              "raw": "{{base_url}}/mobile/conversations?page=1&per_page=15",
              "host": ["{{base_url}}"],
              "path": ["mobile", "conversations"],
              "query": [
                { "key": "page", "value": "1" },
                { "key": "per_page", "value": "15" }
              ]
            }
          }
        }
      ]
    }
  ]
}
