{
  "openapi": "3.0.3",
  "info": {
    "title": "API do WhatzaBot",
    "version": "0.1.0",
    "description": "Use esta API para ligar outro sistema ao WhatzaBot.\n\nPara mandar uma mensagem ou começar uma automação, crie uma chave de integração (`wzb_…`) no painel, em Configurações › Integrações, e envie a chave no cabeçalho `Authorization: Bearer`. As outras rotas usam o login de um usuário da empresa: faça o login em `POST /api/v1/auth/login` e envie o `accessToken` da mesma forma. O token vale 15 minutos. Para pegar um novo, chame `POST /api/v1/auth/refresh` com o cookie que o login devolveu.\n\nO arquivo [openapi.json](./openapi.json) traz esta documentação no formato OpenAPI 3.0, para importar no Postman e em programas parecidos.\n\nAs automações também avisam o seu sistema quando algo acontece no WhatzaBot: veja a seção \"Automações: o que o Chamar endereço manda\"."
  },
  "servers": [
    {
      "url": "https://api.whatzabot.com.br",
      "description": "Produção"
    }
  ],
  "tags": [
    {
      "name": "Autenticação"
    },
    {
      "name": "Equipe"
    },
    {
      "name": "Conexões: números e Conectores"
    },
    {
      "name": "Número oficial: modelos e webhook"
    },
    {
      "name": "Contatos"
    },
    {
      "name": "Empresas"
    },
    {
      "name": "Campos personalizados"
    },
    {
      "name": "Conversas e mensagens"
    },
    {
      "name": "Arquivos"
    },
    {
      "name": "Operações e cartões"
    },
    {
      "name": "Chat interno"
    },
    {
      "name": "Etiquetas e respostas rápidas"
    },
    {
      "name": "Modelos de avaliação"
    },
    {
      "name": "Ligações"
    },
    {
      "name": "Relatórios"
    },
    {
      "name": "Configurações e novidades"
    },
    {
      "name": "Painel de atividade"
    },
    {
      "name": "Conhecimento"
    },
    {
      "name": "Central de ajuda (sem login)",
      "description": "Conhecimento"
    },
    {
      "name": "Agentes de IA"
    },
    {
      "name": "IA da empresa",
      "description": "Agentes de IA"
    },
    {
      "name": "Fluxos"
    },
    {
      "name": "Automações"
    },
    {
      "name": "Campanhas e avisos"
    },
    {
      "name": "Importar dados"
    },
    {
      "name": "Integração"
    },
    {
      "name": "Mandar mensagem (sem sessão)",
      "description": "Integração"
    },
    {
      "name": "Consultar dados (sem sessão)",
      "description": "Integração"
    },
    {
      "name": "Deivid"
    },
    {
      "name": "Automações: o que o Chamar endereço manda",
      "description": "Com o corpo vazio, o bloco **Chamar endereço** manda ao outro sistema os\ndados do que aconteceu, em JSON, pelo método escolhido no bloco (`POST`,\n`PUT` ou `PATCH`). Os exemplos abaixo mostram o JSON de cada evento. Os\nvalores guardados por blocos anteriores (Guardar valores, a resposta de\noutro Chamar endereço) também vão, com o nome que receberam.\n\nComo o pedido chega:\n\n- **Cabeçalhos:** `Content-Type: application/json`,\n  `User-Agent: WhatzaBot-Fluxos/1`, os cabeçalhos escritos no bloco e o\n  segredo escolhido nele.\n- **Assinatura:** com **Assinar o pedido** ligado (o padrão), vão também\n  `X-WhatzaBot-Timestamp`, a hora do envio em segundos desde 1970, e\n  `X-WhatzaBot-Signature`, que é `sha256=` seguido do HMAC-SHA256 em\n  hexadecimal de `<timestamp>.<corpo>`, calculado com a chave de assinatura\n  da automação (aparece no bloco). Para conferir, calcule o mesmo com o\n  corpo exatamente como chegou e compare. Recuse o pedido com o timestamp\n  de mais de 5 minutos atrás, para ninguém reaproveitar um pedido antigo.\n- **Resposta:** o outro sistema tem 10 segundos para responder. Uma\n  resposta `2xx` dá certo. Sem resposta ou com erro do servidor (`5xx`), e\n  com **Tentar de novo se falhar** ligado, o WhatzaBot tenta mais 5 vezes:\n  depois de 1 min, 5 min, 20 min, 1 h e 4 h.\n- **Campos comuns:** `evento` (o tipo do evento), `quando` (data e hora em\n  UTC, no padrão ISO 8601) e `automacao` (`id` e `nome`). Os ids são os do\n  WhatzaBot, os mesmos das rotas desta API. Quando quem fez a ação foi o\n  próprio sistema, como na conversa fechada sozinha por falta de resposta,\n  `autor` vem sem `id` e com o `nome` vazio.\n\nConferir a assinatura em Node.js:\n\n```js\nconst crypto = require(\"crypto\");\nfunction assinaturaValida(corpo, timestamp, assinatura, chave) {\n  const esperada = \"sha256=\" + crypto.createHmac(\"sha256\", chave).update(timestamp + \".\" + corpo).digest(\"hex\");\n  const antiga = Math.abs(Date.now() / 1000 - Number(timestamp)) > 300;\n  return !antiga && crypto.timingSafeEqual(Buffer.from(esperada), Buffer.from(assinatura));\n}\n```"
    }
  ],
  "paths": {
    "/api/v1/auth/login": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Entrar com e-mail e senha",
        "operationId": "postAuthLogin",
        "description": "**Corpo:** `{ email, password, acceptInvite? }`\n\n**Resposta:** `Session` + cookie. Sem nenhuma empresa ativa e com convite: `403 invite_pending` com `details.companyId` e `details.companyName`; o mesmo pedido com `acceptInvite` (o `companyId`) aceita o convite e entra nela. Com a verificação em duas etapas ligada (e sem o cookie `wzb_trusted` desta conta): `{ step: \"totp\", ticket }` no lugar da sessão; o ticket vale 5 min e leva o convite aceito, que só é aceito no passo seguinte",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "example": "ana@exemplo.com.br"
                  },
                  "password": {
                    "type": "string",
                    "example": "Senha#forte2026"
                  },
                  "acceptInvite": {}
                },
                "required": [
                  "email",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Session` + cookie. Sem nenhuma empresa ativa e com convite: `403 invite_pending` com `details.companyId` e `details.companyName`; o mesmo pedido com `acceptInvite` (o `companyId`) aceita o convite e entra nela. Com a verificação em duas etapas ligada (e sem o cookie `wzb_trusted` desta conta): `{ step: \"totp\", ticket }` no lugar da sessão; o ticket vale 5 min e leva o convite aceito, que só é aceito no passo seguinte",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "403": {
            "description": "`invite_pending`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/auth/login\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"email\":\"ana@exemplo.com.br\",\"password\":\"Senha#forte2026\"}'"
          }
        ]
      }
    },
    "/api/v1/auth/totp": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Entrar com o código de verificação",
        "operationId": "postAuthTotp",
        "description": "**Corpo:** `{ ticket, code?, recoveryCode?, remember }`\n\n**Resposta:** `Session` + cookie. `code`: os 6 números do app; ou `recoveryCode`, um código de recuperação (vale uma vez). `remember: true` lembra o computador por 30 dias (cookie `wzb_trusted`, só para `/api/v1/auth`). Erros: `401 ticket_expired` (ticket vencido, ou a verificação foi desligada depois da senha), `422 invalid_code` com `details.code` ou `details.recoveryCode`, `429 locked`, `409 totp_unreadable` (segredo ilegível, `JWT_SECRET` trocado)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ticket": {},
                  "code": {
                    "type": "string"
                  },
                  "recoveryCode": {},
                  "remember": {}
                },
                "required": [
                  "ticket",
                  "remember"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Session` + cookie. `code`: os 6 números do app; ou `recoveryCode`, um código de recuperação (vale uma vez). `remember: true` lembra o computador por 30 dias (cookie `wzb_trusted`, só para `/api/v1/auth`). Erros: `401 ticket_expired` (ticket vencido, ou a verificação foi desligada depois da senha), `422 invalid_code` com `details.code` ou `details.recoveryCode`, `429 locked`, `409 totp_unreadable` (segredo ilegível, `JWT_SECRET` trocado)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "401": {
            "description": "`ticket_expired`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`totp_unreadable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`invalid_code`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "429": {
            "description": "`locked`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/auth/totp\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"code\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/auth/refresh": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Renovar a sessão",
        "operationId": "postAuthRefresh",
        "description": "**Corpo:** — (cookie)\n\n**Resposta:** `Session` + cookie novo",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "— (cookie)"
              }
            }
          },
          "description": "— (cookie)"
        },
        "responses": {
          "200": {
            "description": "`Session` + cookie novo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          }
        },
        "security": [],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/auth/refresh\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/auth/logout": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Sair do sistema",
        "operationId": "postAuthLogout",
        "description": "**Resposta:** `204`, apaga o cookie",
        "responses": {
          "204": {
            "description": "`204`, apaga o cookie"
          }
        },
        "security": [],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/auth/logout\""
          }
        ]
      }
    },
    "/api/v1/auth/switch": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Trocar de empresa",
        "operationId": "postAuthSwitch",
        "description": "**Corpo:** `{ companyId }`\n\n**Resposta:** `Session` da outra empresa",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "companyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Session` da outra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/auth/switch\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"companyId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/me": {
      "get": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Ver meus dados",
        "operationId": "getMe",
        "description": "**Resposta:** `Session` sem `accessToken`",
        "responses": {
          "200": {
            "description": "`Session` sem `accessToken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/me\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/me/password": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Trocar minha senha",
        "operationId": "postMePassword",
        "description": "**Corpo:** `{ current, password }`\n\n**Resposta:** `204`; `422` em `current` (não confere) ou `password` (fora da regra, ou igual à recebida no primeiro acesso: \"Crie uma senha diferente da que você recebeu.\"); `409 password_locked` quando só a empresa muda a senha",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "current": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string",
                    "example": "Senha#forte2026"
                  }
                },
                "required": [
                  "current",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "`204`; `422` em `current` (não confere) ou `password` (fora da regra, ou igual à recebida no primeiro acesso: \"Crie uma senha diferente da que você recebeu.\"); `409 password_locked` quando só a empresa muda a senha"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`password_locked`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/me/password\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"current\":\"texto\",\"password\":\"Senha#forte2026\"}'"
          }
        ]
      }
    },
    "/api/v1/me/photo": {
      "put": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Trocar minha foto",
        "operationId": "putMePhoto",
        "description": "**Corpo:** multipart: `file`\n\n**Resposta:** `{ id, photoUrl }`: a foto da própria pessoa nesta empresa (\"Meus dados\"); as regras da imagem estão em Foto do usuário e do contato. No acesso de suporte: `403`",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "description": "multipart: `file`"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ id, photoUrl }`: a foto da própria pessoa nesta empresa (\"Meus dados\"); as regras da imagem estão em Foto do usuário e do contato. No acesso de suporte: `403`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "photoUrl": {
                      "type": "string",
                      "example": "https://exemplo.com.br"
                    }
                  },
                  "required": [
                    "id",
                    "photoUrl"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/me/photo\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -F \"file=@arquivo.pdf\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Apagar minha foto",
        "operationId": "deleteMePhoto",
        "description": "**Resposta:** `{ id }`: tira a foto; voltam as iniciais. No acesso de suporte: `403`",
        "responses": {
          "200": {
            "description": "`{ id }`: tira a foto; voltam as iniciais. No acesso de suporte: `403`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/me/photo\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/me/two-factor": {
      "get": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Ver a verificação em duas etapas",
        "operationId": "getMeTwoFactor",
        "description": "**Resposta:** `{ on, at?, recoveryLeft, required }`: ligada desde `at`, quantos códigos de recuperação ainda valem e se a empresa exige",
        "responses": {
          "200": {
            "description": "`{ on, at?, recoveryLeft, required }`: ligada desde `at`, quantos códigos de recuperação ainda valem e se a empresa exige",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "on": {},
                    "at": {
                      "type": "string",
                      "format": "date-time",
                      "example": "2026-12-01T12:12:00Z"
                    },
                    "recoveryLeft": {},
                    "required": {}
                  },
                  "required": [
                    "on",
                    "recoveryLeft",
                    "required"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/me/two-factor\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/me/two-factor/setup": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Começar a verificação em duas etapas",
        "operationId": "postMeTwoFactorSetup",
        "description": "**Resposta:** `{ ticket, secret, qr }`: o segredo novo (`secret` em base32, para digitar; `qr` é `data:image/png;base64,…` do `otpauth://totp/WhatzaBot:<email>?secret=…&issuer=WhatzaBot`) e o ticket de 15 min que o leva cifrado. Já ligada: `409 two_factor_on`. No acesso de suporte: `409 support`",
        "responses": {
          "200": {
            "description": "`{ ticket, secret, qr }`: o segredo novo (`secret` em base32, para digitar; `qr` é `data:image/png;base64,…` do `otpauth://totp/WhatzaBot:<email>?secret=…&issuer=WhatzaBot`) e o ticket de 15 min que o leva cifrado. Já ligada: `409 two_factor_on`. No acesso de suporte: `409 support`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ticket": {},
                    "secret": {},
                    "qr": {}
                  },
                  "required": [
                    "ticket",
                    "secret",
                    "qr"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`two_factor_on`, `support`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/me/two-factor/setup\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/me/two-factor/enable": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Ligar a verificação em duas etapas",
        "operationId": "postMeTwoFactorEnable",
        "description": "**Corpo:** `{ ticket, code, password }`\n\n**Resposta:** `{ recoveryCodes }`: 10 códigos, como `k7m2p-x9qtr`, a única vez em que aparecem. A senha confirma que é a pessoa (errada: `422` em `password`, contando no bloqueio de 5 erros). O segredo só entra na conta quando o código confere (`422 invalid_code` com `details.code`). Ticket vencido: `409 setup_expired`; já ligada: `409 two_factor_on`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ticket": {},
                  "code": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string",
                    "example": "Senha#forte2026"
                  }
                },
                "required": [
                  "ticket",
                  "code",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ recoveryCodes }`: 10 códigos, como `k7m2p-x9qtr`, a única vez em que aparecem. A senha confirma que é a pessoa (errada: `422` em `password`, contando no bloqueio de 5 erros). O segredo só entra na conta quando o código confere (`422 invalid_code` com `details.code`). Ticket vencido: `409 setup_expired`; já ligada: `409 two_factor_on`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "recoveryCodes": {}
                  },
                  "required": [
                    "recoveryCodes"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`setup_expired`, `two_factor_on`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`invalid_code`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/me/two-factor/enable\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"code\":\"texto\",\"password\":\"Senha#forte2026\"}'"
          }
        ]
      }
    },
    "/api/v1/me/two-factor/disable": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Desligar a verificação em duas etapas",
        "operationId": "postMeTwoFactorDisable",
        "description": "**Corpo:** `{ code }` ou `{ recoveryCode }`\n\n**Resposta:** `204`; apaga a verificação e esquece os computadores lembrados. Só a senha não desliga. Errado: `422 invalid_code` (em `code` ou `recoveryCode`), contando no bloqueio de 5 erros. Já desligada: `409 two_factor_off`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ],
                "description": "ou `{ recoveryCode }`"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "`204`; apaga a verificação e esquece os computadores lembrados. Só a senha não desliga. Errado: `422 invalid_code` (em `code` ou `recoveryCode`), contando no bloqueio de 5 erros. Já desligada: `409 two_factor_off`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`two_factor_off`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`invalid_code`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/me/two-factor/disable\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"code\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/me/invites/{companyId}/accept": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Aceitar o convite da empresa",
        "operationId": "postMeInvitesByCompanyIdAccept",
        "description": "**Resposta:** `204`; o vínculo fica ativo e a pessoa entra nas operações em que a empresa a pôs (pelas áreas e pelo acesso de cada operação). Cancelado ou já respondido: `404 invite_not_found`",
        "parameters": [
          {
            "name": "companyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; o vínculo fica ativo e a pessoa entra nas operações em que a empresa a pôs (pelas áreas e pelo acesso de cada operação). Cancelado ou já respondido: `404 invite_not_found`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`invite_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/me/invites/6750a1c2e4b0a1b2c3d4e5f1/accept\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/me/invites/{companyId}/decline": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Recusar o convite da empresa",
        "operationId": "postMeInvitesByCompanyIdDecline",
        "description": "**Resposta:** `204`; o convite é apagado. Já respondido: `404 invite_not_found`",
        "parameters": [
          {
            "name": "companyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; o convite é apagado. Já respondido: `404 invite_not_found`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`invite_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/me/invites/6750a1c2e4b0a1b2c3d4e5f1/decline\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/areas": {
      "get": {
        "tags": [
          "Equipe"
        ],
        "summary": "Listar áreas",
        "operationId": "getAreas",
        "description": "**Quem:** todos\n\n**Resposta:** `{ data: [Area] }`; `profiles` são os perfis que liberam a área (quem tem um deles está nela pelo perfil)",
        "responses": {
          "200": {
            "description": "`{ data: [Area] }`; `profiles` são os perfis que liberam a área (quem tem um deles está nela pelo perfil)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Area"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/areas\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Equipe"
        ],
        "summary": "Criar área",
        "operationId": "postAreas",
        "description": "**Quem:** `operations`\n\n**Corpo:** `{ name, icon, audience, hours, sla, memberIds? }`\n\n**Resposta:** `201 Area`. `memberIds`: as pessoas da área (ativas na equipe; senão `422` em `memberIds`)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "icon": {
                    "type": "string"
                  },
                  "audience": {},
                  "hours": {
                    "type": "integer"
                  },
                  "sla": {},
                  "memberIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  }
                },
                "required": [
                  "name",
                  "icon",
                  "audience",
                  "hours",
                  "sla"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Area`. `memberIds`: as pessoas da área (ativas na equipe; senão `422` em `memberIds`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Area"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`operations`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/areas\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"icon\":\"texto\",\"hours\":0,\"memberIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}'"
          }
        ]
      }
    },
    "/api/v1/areas/{id}": {
      "patch": {
        "tags": [
          "Equipe"
        ],
        "summary": "Alterar área",
        "operationId": "patchAreasById",
        "description": "**Quem:** `operations`\n\n**Corpo:** campos; `memberIds` é a lista inteira das pessoas da área; quem está nela pelo perfil continua, mesmo fora da lista, e não vira escolhido\n\n**Resposta:** `Area`; renomear acerta o nome nas operações e no Conhecimento; mudar as pessoas refaz as operações de cada uma e os canais das operações no chat. As conexões da área não mudam aqui",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "campos; `memberIds` é a lista inteira das pessoas da área; quem está nela pelo perfil continua, mesmo fora da lista, e não vira escolhido"
              }
            }
          },
          "description": "campos; `memberIds` é a lista inteira das pessoas da área; quem está nela pelo perfil continua, mesmo fora da lista, e não vira escolhido"
        },
        "responses": {
          "200": {
            "description": "`Area`; renomear acerta o nome nas operações e no Conhecimento; mudar as pessoas refaz as operações de cada uma e os canais das operações no chat. As conexões da área não mudam aqui",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Area"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`operations`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/areas/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Equipe"
        ],
        "summary": "Apagar área",
        "operationId": "deleteAreasById",
        "description": "**Quem:** `operations`\n\n**Resposta:** `204`; `409 area_in_use` se a área tem operações, atende conexões ou tem páginas do Conhecimento só para ela; as pessoas saem da área",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; `409 area_in_use` se a área tem operações, atende conexões ou tem páginas do Conhecimento só para ela; as pessoas saem da área"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`area_in_use`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`operations`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/areas/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/profiles": {
      "get": {
        "tags": [
          "Equipe"
        ],
        "summary": "Listar perfis",
        "operationId": "getProfiles",
        "description": "**Quem:** `team`\n\n**Resposta:** `{ data: [Profile] }`, o Administrador primeiro e os outros pelo nome",
        "responses": {
          "200": {
            "description": "`{ data: [Profile] }`, o Administrador primeiro e os outros pelo nome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Profile"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/profiles\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Equipe"
        ],
        "summary": "Criar perfil",
        "operationId": "postProfiles",
        "description": "**Quem:** `team`\n\n**Corpo:** `{ name, perms?, allNumbers?, numberIds?, areaIds? }`\n\n**Resposta:** `201 Profile`; sem `allNumbers`, todas as conexões. `name` de 1 a 40 letras, sem repetir (`422` em `name`, \"Já existe um perfil com este nome.\"). Quem não é administrador só dá as permissões e as conexões que o próprio perfil tem (`422` em `perms`, `allNumbers` ou `numberIds`). `areaIds`: as áreas em que quem tem o perfil entra automaticamente (`422` em `areaIds` se uma não existe)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "perms": {},
                  "allNumbers": {},
                  "numberIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "areaIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Profile`; sem `allNumbers`, todas as conexões. `name` de 1 a 40 letras, sem repetir (`422` em `name`, \"Já existe um perfil com este nome.\"). Quem não é administrador só dá as permissões e as conexões que o próprio perfil tem (`422` em `perms`, `allNumbers` ou `numberIds`). `areaIds`: as áreas em que quem tem o perfil entra automaticamente (`422` em `areaIds` se uma não existe)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/profiles\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"numberIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"areaIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}'"
          }
        ]
      }
    },
    "/api/v1/profiles/{id}": {
      "patch": {
        "tags": [
          "Equipe"
        ],
        "summary": "Alterar perfil",
        "operationId": "patchProfilesById",
        "description": "**Quem:** `team`\n\n**Corpo:** os mesmos campos\n\n**Resposta:** `Profile`; vale na hora para quem tem o perfil (o perfil é relido a cada pedido). O Administrador não muda: `409 profile_admin`. Renomear acerta o nome nas pessoas. Mudar `areaIds` põe e tira das áreas quem tem o perfil (fica quem foi escolhido na área), refaz as operações de cada um e os canais das operações no chat",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "os mesmos campos"
              }
            }
          },
          "description": "os mesmos campos"
        },
        "responses": {
          "200": {
            "description": "`Profile`; vale na hora para quem tem o perfil (o perfil é relido a cada pedido). O Administrador não muda: `409 profile_admin`. Renomear acerta o nome nas pessoas. Mudar `areaIds` põe e tira das áreas quem tem o perfil (fica quem foi escolhido na área), refaz as operações de cada um e os canais das operações no chat",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`profile_admin`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/profiles/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Equipe"
        ],
        "summary": "Apagar perfil",
        "operationId": "deleteProfilesById",
        "description": "**Quem:** `team`\n\n**Resposta:** `204`; o Administrador não sai (`409 profile_admin`); perfil com alguém (ativo, desativado ou convite) dá `409 profile_in_use`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; o Administrador não sai (`409 profile_admin`); perfil com alguém (ativo, desativado ou convite) dá `409 profile_in_use`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`profile_admin`, `profile_in_use`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/profiles/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/users": {
      "get": {
        "tags": [
          "Equipe"
        ],
        "summary": "Listar pessoas da equipe",
        "operationId": "getUsers",
        "description": "**Quem:** `team`, `operations`, `flows`, `knowledge`, `attendance`, `campaigns` ou gestor de uma operação\n\n**Resposta:** `{ data: [User] }`, a equipe toda (a lista também serve às telas que escolhem pessoas)",
        "responses": {
          "200": {
            "description": "`{ data: [User] }`, a equipe toda (a lista também serve às telas que escolhem pessoas)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`, `operations`, `flows`, `knowledge`, `attendance`, `campaigns` ou gestor de uma operação",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/users\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Equipe"
        ],
        "summary": "Convidar ou criar pessoa da equipe",
        "operationId": "postUsers",
        "description": "**Quem:** `team`\n\n**Corpo:** `{ name, email, profileId, password?, canChangePassword?, calendarId?, title?, birthday?, birthYear?, since?, birthdayQuiet?, signName? }`\n\n**Resposta:** `201 { user: User, password?, linked? }`. E-mail sem conta: `{ user, password }`, a conta nova com a senha digitada ou, sem ela, uma gerada (mostrada uma vez); a pessoa cria a dela no primeiro acesso, a não ser com `canChangePassword: false` (`passwordLocked`: só a empresa muda a senha). E-mail com conta (de outra empresa): `201 { user: User, linked: true }`, o vínculo já ativo, sem mexer na conta (nome e senha são da pessoa). `422` em `name` (vazio ou mais de 80 letras), `email` (inválido, já é da empresa, desativada ou com convite antigo), `password` (fora da regra) e `profileId`. Acima do limite de usuários do plano: `409 plan_limit`. As operações vêm depois, pelas áreas e pelo acesso de cada operação",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "email": {
                    "type": "string",
                    "example": "ana@exemplo.com.br"
                  },
                  "profileId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "password": {
                    "type": "string",
                    "example": "Senha#forte2026"
                  },
                  "canChangePassword": {
                    "type": "boolean"
                  },
                  "calendarId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "birthday": {},
                  "birthYear": {},
                  "since": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  },
                  "birthdayQuiet": {},
                  "signName": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "email",
                  "profileId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 { user: User, password?, linked? }`. E-mail sem conta: `{ user, password }`, a conta nova com a senha digitada ou, sem ela, uma gerada (mostrada uma vez); a pessoa cria a dela no primeiro acesso, a não ser com `canChangePassword: false` (`passwordLocked`: só a empresa muda a senha). E-mail com conta (de outra empresa): `201 { user: User, linked: true }`, o vínculo já ativo, sem mexer na conta (nome e senha são da pessoa). `422` em `name` (vazio ou mais de 80 letras), `email` (inválido, já é da empresa, desativada ou com convite antigo), `password` (fora da regra) e `profileId`. Acima do limite de usuários do plano: `409 plan_limit`. As operações vêm depois, pelas áreas e pelo acesso de cada operação",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/User"
                    },
                    "password": {
                      "type": "string",
                      "example": "Senha#forte2026"
                    },
                    "linked": {}
                  },
                  "required": [
                    "user"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`plan_limit`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/users\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"email\":\"ana@exemplo.com.br\",\"profileId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"password\":\"Senha#forte2026\",\"canChangePassword\":true,\"calendarId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"title\":\"Pedido 48211\",\"since\":\"2026-12-01T12:12:00Z\",\"signName\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/users/{id}": {
      "patch": {
        "tags": [
          "Equipe"
        ],
        "summary": "Alterar pessoa da equipe",
        "operationId": "patchUsersById",
        "description": "**Quem:** `team`\n\n**Corpo:** `{ name, profileId, status, canChangePassword?, calendarId?, title?, birthday?, birthYear?, since?, birthdayQuiet?, signName? }` (`calendarId`: um dos `attendance.calendars`; `\"\"` volta ao expediente padrão; outro dá `422` em `calendarId`)\n\n**Resposta:** `User`. `name` muda a conta só com `ownAccount` (senão `422` em `name`, se diferente); no convite, muda o nome do convite. `profileId`: o próprio perfil não muda (`409 self_profile`); tirar o Administrador do último administrador ativo dá `409 last_admin`. `status` `active` ou `disabled` refaz as operações da pessoa; convite não muda `status` (`409 invite_pending`); inativar a si mesmo, `409 self_disable`, e o último administrador, `409 last_admin`; reativar acima do limite: `409 plan_limit`. `canChangePassword` só com `ownAccount` (`409 shared_account`); `false` deixa a senha só com a empresa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "profileId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "status": {
                    "type": "string"
                  },
                  "canChangePassword": {
                    "type": "boolean"
                  },
                  "calendarId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "birthday": {},
                  "birthYear": {},
                  "since": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  },
                  "birthdayQuiet": {},
                  "signName": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "profileId",
                  "status"
                ],
                "description": "(`calendarId`: um dos `attendance.calendars`; `\"\"` volta ao expediente padrão; outro dá `422` em `calendarId`)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`User`. `name` muda a conta só com `ownAccount` (senão `422` em `name`, se diferente); no convite, muda o nome do convite. `profileId`: o próprio perfil não muda (`409 self_profile`); tirar o Administrador do último administrador ativo dá `409 last_admin`. `status` `active` ou `disabled` refaz as operações da pessoa; convite não muda `status` (`409 invite_pending`); inativar a si mesmo, `409 self_disable`, e o último administrador, `409 last_admin`; reativar acima do limite: `409 plan_limit`. `canChangePassword` só com `ownAccount` (`409 shared_account`); `false` deixa a senha só com a empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`self_profile`, `last_admin`, `invite_pending`, `self_disable`, `plan_limit`, `shared_account`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/users/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"profileId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"status\":\"texto\",\"canChangePassword\":true,\"calendarId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"title\":\"Pedido 48211\",\"since\":\"2026-12-01T12:12:00Z\",\"signName\":\"texto\"}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Equipe"
        ],
        "summary": "Apagar pessoa da equipe",
        "operationId": "deleteUsersById",
        "description": "**Quem:** `team`\n\n**Resposta:** `204`; cancela o convite antigo que a pessoa ainda não aceitou. Vínculo ativo ou desativado: `409 not_invite`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; cancela o convite antigo que a pessoa ainda não aceitou. Vínculo ativo ou desativado: `409 not_invite`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_invite`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/users/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/users/{id}/revoke": {
      "post": {
        "tags": [
          "Equipe"
        ],
        "summary": "Cancelar o convite da pessoa",
        "operationId": "postUsersByIdRevoke",
        "description": "**Quem:** `team`\n\n**Resposta:** `User`. **Tirar o acesso**: desativa a pessoa na empresa (como `status: \"disabled\"`) e refaz as operações. Para si mesmo, `409 self_disable`; convite, `409 invite_pending` (use o `DELETE`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`User`. **Tirar o acesso**: desativa a pessoa na empresa (como `status: \"disabled\"`) e refaz as operações. Para si mesmo, `409 self_disable`; convite, `409 invite_pending` (use o `DELETE`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`self_disable`, `invite_pending`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/users/6750a1c2e4b0a1b2c3d4e5f1/revoke\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/users/{id}/keep": {
      "post": {
        "tags": [
          "Equipe"
        ],
        "summary": "Manter a pessoa na equipe",
        "operationId": "postUsersByIdKeep",
        "description": "**Quem:** `team`\n\n**Resposta:** `User`; **Manter**: a pessoa sai do aviso de acesso parado por 90 dias (`idleKeptUntil`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`User`; **Manter**: a pessoa sai do aviso de acesso parado por 90 dias (`idleKeptUntil`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/users/6750a1c2e4b0a1b2c3d4e5f1/keep\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/users/{id}/resend": {
      "post": {
        "tags": [
          "Equipe"
        ],
        "summary": "Reenviar o convite",
        "operationId": "postUsersByIdResend",
        "description": "**Quem:** `team`\n\n**Resposta:** `{ user: User, password? }`. **Reenviar** (o WhatzaBot não manda e-mail): no convite antigo, ele volta a valer como novo (`invitedAt` agora, `invitedBy` quem reenviou); na conta criada aqui que nunca entrou, sai uma senha nova em `password`, e o aviso espera mais 30 dias. Quem já entrou: `409 not_pending`; conta que também entra em outra empresa: `409 shared_account`; convite aceito no meio do caminho: `409 not_invite`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ user: User, password? }`. **Reenviar** (o WhatzaBot não manda e-mail): no convite antigo, ele volta a valer como novo (`invitedAt` agora, `invitedBy` quem reenviou); na conta criada aqui que nunca entrou, sai uma senha nova em `password`, e o aviso espera mais 30 dias. Quem já entrou: `409 not_pending`; conta que também entra em outra empresa: `409 shared_account`; convite aceito no meio do caminho: `409 not_invite`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/User"
                    },
                    "password": {
                      "type": "string",
                      "example": "Senha#forte2026"
                    }
                  },
                  "required": [
                    "user"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_pending`, `shared_account`, `not_invite`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/users/6750a1c2e4b0a1b2c3d4e5f1/resend\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/users/{id}/password": {
      "post": {
        "tags": [
          "Equipe"
        ],
        "summary": "Trocar a senha da pessoa",
        "operationId": "postUsersByIdPassword",
        "description": "**Quem:** `team`\n\n**Corpo:** `{ password? }` (vazio: o sistema gera)\n\n**Resposta:** `{ password, locked }`: a senha nova (mostrada uma vez); com `locked` falso, a pessoa cria a dela no próximo acesso. A senha antiga deixa de valer, o bloqueio por erros sai e as sessões da pessoa acabam (o token de acesso já emitido vence em até 15 min). Só com `ownAccount`: senão `409 shared_account`; para si mesmo, `409 self_password`; vínculo que não está ativo, `409 not_active`; `422` em `password` fora da regra",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "password": {
                    "type": "string",
                    "example": "Senha#forte2026"
                  }
                },
                "description": "(vazio: o sistema gera)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ password, locked }`: a senha nova (mostrada uma vez); com `locked` falso, a pessoa cria a dela no próximo acesso. A senha antiga deixa de valer, o bloqueio por erros sai e as sessões da pessoa acabam (o token de acesso já emitido vence em até 15 min). Só com `ownAccount`: senão `409 shared_account`; para si mesmo, `409 self_password`; vínculo que não está ativo, `409 not_active`; `422` em `password` fora da regra",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "password": {
                      "type": "string",
                      "example": "Senha#forte2026"
                    },
                    "locked": {}
                  },
                  "required": [
                    "password",
                    "locked"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`shared_account`, `self_password`, `not_active`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/users/6750a1c2e4b0a1b2c3d4e5f1/password\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"password\":\"Senha#forte2026\"}'"
          }
        ]
      }
    },
    "/api/v1/users/photos": {
      "get": {
        "tags": [
          "Equipe"
        ],
        "summary": "Listar fotos da equipe",
        "operationId": "getUsersPhotos",
        "description": "**Quem:** todos\n\n**Resposta:** `{ data: [{ id, photoUrl }] }`: as fotos da equipe (`id` é a conta), só de quem tem foto. O painel lê ao entrar, de novo a cada 45 min (os links valem 1 hora) e acompanha o evento `user.photo`",
        "responses": {
          "200": {
            "description": "`{ data: [{ id, photoUrl }] }`: as fotos da equipe (`id` é a conta), só de quem tem foto. O painel lê ao entrar, de novo a cada 45 min (os links valem 1 hora) e acompanha o evento `user.photo`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "photoUrl": {
                            "type": "string",
                            "example": "https://exemplo.com.br"
                          }
                        },
                        "required": [
                          "id",
                          "photoUrl"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/users/photos\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/users/{id}/photo": {
      "put": {
        "tags": [
          "Equipe"
        ],
        "summary": "Trocar a foto da pessoa",
        "operationId": "putUsersByIdPhoto",
        "description": "**Quem:** `team`\n\n**Corpo:** multipart: `file`\n\n**Resposta:** `User`; troca a foto da pessoa (regras da imagem). A de outro administrador, só um administrador troca (`403`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "description": "multipart: `file`"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`User`; troca a foto da pessoa (regras da imagem). A de outro administrador, só um administrador troca (`403`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/users/6750a1c2e4b0a1b2c3d4e5f1/photo\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -F \"file=@arquivo.pdf\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Equipe"
        ],
        "summary": "Apagar a foto da pessoa",
        "operationId": "deleteUsersByIdPhoto",
        "description": "**Quem:** `team`\n\n**Resposta:** `User`; tira a foto (voltam as iniciais)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`User`; tira a foto (voltam as iniciais)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/users/6750a1c2e4b0a1b2c3d4e5f1/photo\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/users/{id}/two-factor/reset": {
      "post": {
        "tags": [
          "Equipe"
        ],
        "summary": "Zerar a verificação em duas etapas da pessoa",
        "operationId": "postUsersByIdTwoFactorReset",
        "description": "**Quem:** `team`\n\n**Resposta:** `204`; \"Desligar a verificação em duas etapas\": desliga a verificação em duas etapas da pessoa (perdeu o celular) e esquece os computadores lembrados; as sessões abertas continuam. Como a senha, só com `ownAccount` (senão `409 shared_account`: quem resolve é o suporte do WhatzaBot); para si mesmo, `409 self_two_factor`; vínculo que não está ativo, `409 not_active`; a pessoa não ligou, `409 two_factor_off`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; \"Desligar a verificação em duas etapas\": desliga a verificação em duas etapas da pessoa (perdeu o celular) e esquece os computadores lembrados; as sessões abertas continuam. Como a senha, só com `ownAccount` (senão `409 shared_account`: quem resolve é o suporte do WhatzaBot); para si mesmo, `409 self_two_factor`; vínculo que não está ativo, `409 not_active`; a pessoa não ligou, `409 two_factor_off`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`shared_account`, `self_two_factor`, `not_active`, `two_factor_off`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`team`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/users/6750a1c2e4b0a1b2c3d4e5f1/two-factor/reset\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/numbers": {
      "get": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Listar conexões",
        "operationId": "getNumbers",
        "description": "**Quem:** todos (com `connections`, todos; os outros, as conexões do perfil que atendem as operações deles, ou todas as do perfil com `allOperations`)\n\n**Resposta:** `{ data: [Number] }`",
        "responses": {
          "200": {
            "description": "`{ data: [Number] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Number"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos (com `connections`, todos; os outros, as conexões do perfil que atendem as operações deles, ou todas as do perfil com `allOperations`)",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/numbers\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Criar conexão",
        "operationId": "postNumbers",
        "description": "**Quem:** `connections`\n\n**Corpo:** `{ phone, label, channel: \"qr\", conectorId?, calls? }` ou `{ phone?, label?, channel: \"official\", official: { phoneNumberId, wabaId, token, pin? } }`\n\n**Resposta:** `201 Number`; `phone` com DDI (10 a 15 dígitos); `label` até 40 letras (`422` em `label`); `409 phone_taken`; `calls: true` faz dele o número de ligação do Conector (só com `conectorId`). Oficial: confere tudo na Graph API (`422` em `phoneNumberId`, `wabaId`, `token` ou `phone`), acima do limite de números do plano: `409 plan_limit`; `409 official_taken`, `409 official_register` (`details.pin: \"required\"`: mande de novo com o PIN de 6 dígitos), `409 meta_error`, `409 official_not_configured` (servidor sem o app da Meta)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone": {
                    "type": "string",
                    "example": "5554999990000"
                  },
                  "label": {
                    "type": "string"
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "qr"
                    ],
                    "example": "qr"
                  },
                  "conectorId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "calls": {}
                },
                "required": [
                  "phone",
                  "label",
                  "channel"
                ],
                "description": "ou `{ phone?, label?, channel: \"official\", official: { phoneNumberId, wabaId, token, pin? } }`"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Number`; `phone` com DDI (10 a 15 dígitos); `label` até 40 letras (`422` em `label`); `409 phone_taken`; `calls: true` faz dele o número de ligação do Conector (só com `conectorId`). Oficial: confere tudo na Graph API (`422` em `phoneNumberId`, `wabaId`, `token` ou `phone`), acima do limite de números do plano: `409 plan_limit`; `409 official_taken`, `409 official_register` (`details.pin: \"required\"`: mande de novo com o PIN de 6 dígitos), `409 meta_error`, `409 official_not_configured` (servidor sem o app da Meta)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Number"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`phone_taken`, `plan_limit`, `official_taken`, `official_register`, `meta_error`, `official_not_configured`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/numbers\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"phone\":\"5554999990000\",\"label\":\"texto\",\"channel\":\"qr\",\"conectorId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/numbers/{id}": {
      "patch": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Alterar conexão",
        "operationId": "patchNumbersById",
        "description": "**Quem:** `connections`\n\n**Corpo:** `{ label?, conectorId? (null tira), calls? }`\n\n**Resposta:** `Number`; `label` de 1 a 40 letras (`422` em `label`); `calls: true` sem Conector dá `409 no_conector`; com o Conector sem sinal, sem conferência ou com item de erro nela (fora o do número), `422` em `calls` (o mesmo no `POST /numbers`, que não cadastra); trocar ou tirar o `conectorId` de número conectado, com o Conector dele com sinal, dá `409 number_connected` (nada é gravado). Oficial: `calls` liga ou desliga as ligações na Meta (`409 meta_error`); `conectorId` não vale",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string"
                  },
                  "conectorId": {
                    "type": "string",
                    "description": "(null tira)",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "calls": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Number`; `label` de 1 a 40 letras (`422` em `label`); `calls: true` sem Conector dá `409 no_conector`; com o Conector sem sinal, sem conferência ou com item de erro nela (fora o do número), `422` em `calls` (o mesmo no `POST /numbers`, que não cadastra); trocar ou tirar o `conectorId` de número conectado, com o Conector dele com sinal, dá `409 number_connected` (nada é gravado). Oficial: `calls` liga ou desliga as ligações na Meta (`409 meta_error`); `conectorId` não vale",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Number"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`no_conector`, `number_connected`, `meta_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/numbers/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"label\":\"texto\",\"conectorId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Apagar conexão",
        "operationId": "deleteNumbersById",
        "description": "**Quem:** `connections`\n\n**Resposta:** `204`; desconecta a sessão no Conector. Oficial: o WhatzaBot para de usar o número (na Meta ele fica) e, se era o último da conta, apaga os modelos dela",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; desconecta a sessão no Conector. Oficial: o WhatzaBot para de usar o número (na Meta ele fica) e, se era o último da conta, apaga os modelos dela"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/numbers/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/numbers/{id}/areas": {
      "put": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Definir as áreas da conexão",
        "operationId": "putNumbersByIdAreas",
        "description": "**Quem:** `connections`\n\n**Corpo:** `{ areaIds, principalId? }`\n\n**Resposta:** `Number`; as operações que seguem essas áreas passam a atender o número (e as das outras áreas deixam de atender), numa transação. Com operação atendendo, `principalId` é obrigatório e precisa ser uma das operações das áreas marcadas ou uma que já atende o número (`422` em `principalId`); a principal com conexões próprias (`ownNumbers`) ganha o número em `numbers`; `409 principal_lost` se outro número perderia a principal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "areaIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "principalId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "areaIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Number`; as operações que seguem essas áreas passam a atender o número (e as das outras áreas deixam de atender), numa transação. Com operação atendendo, `principalId` é obrigatório e precisa ser uma das operações das áreas marcadas ou uma que já atende o número (`422` em `principalId`); a principal com conexões próprias (`ownNumbers`) ganha o número em `numbers`; `409 principal_lost` se outro número perderia a principal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Number"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`principal_lost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/numbers/6750a1c2e4b0a1b2c3d4e5f1/areas\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"areaIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"principalId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/numbers/{id}/check": {
      "post": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Conferir a conexão",
        "operationId": "postNumbersByIdCheck",
        "description": "**Quem:** `connections`\n\n**Resposta:** `Number` lido de novo na Meta (nome, qualidade, limite); `409 not_official`, `token_invalid`, `meta_error`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Number` lido de novo na Meta (nome, qualidade, limite); `409 not_official`, `token_invalid`, `meta_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Number"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_official`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/numbers/6750a1c2e4b0a1b2c3d4e5f1/check\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/numbers/{id}/call-check": {
      "post": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Conferir as ligações da conexão",
        "operationId": "postNumbersByIdCallCheck",
        "description": "**Quem:** `connections`\n\n**Resposta:** `CallCheck` das ligações do número oficial, na hora e sem gravar: `token`, `calling` (ligações ligadas na Meta), `webhook` (avisos assinados) e, no local, o aviso `held`; `409 not_official`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`CallCheck` das ligações do número oficial, na hora e sem gravar: `token`, `calling` (ligações ligadas na Meta), `webhook` (avisos assinados) e, no local, o aviso `held`; `409 not_official`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallCheck"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_official`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/numbers/6750a1c2e4b0a1b2c3d4e5f1/call-check\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/numbers/{id}/token": {
      "put": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Guardar o token da conexão",
        "operationId": "putNumbersByIdToken",
        "description": "**Quem:** `connections`\n\n**Corpo:** `{ token }`\n\n**Resposta:** `Number`; confere o token novo na Meta antes de trocar (`422 token`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string"
                  }
                },
                "required": [
                  "token"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Number`; confere o token novo na Meta antes de trocar (`422 token`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Number"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`token`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/numbers/6750a1c2e4b0a1b2c3d4e5f1/token\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"token\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/numbers/{id}/pair": {
      "post": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Parear a conexão",
        "operationId": "postNumbersByIdPair",
        "description": "**Quem:** `connections`\n\n**Resposta:** `202`; o Conector abre o QR e manda cada um ao painel (`number.qr`), sem mostrar na tela dele; com o QR já aberto, manda o da vez de novo; `409 no_conector` ou `conector_offline`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "`202`; o Conector abre o QR e manda cada um ao painel (`number.qr`), sem mostrar na tela dele; com o QR já aberto, manda o da vez de novo; `409 no_conector` ou `conector_offline`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`no_conector`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/numbers/6750a1c2e4b0a1b2c3d4e5f1/pair\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/numbers/{id}/logout": {
      "post": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Desconectar a conexão",
        "operationId": "postNumbersByIdLogout",
        "description": "**Quem:** `connections`\n\n**Resposta:** `202`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "`202`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/numbers/6750a1c2e4b0a1b2c3d4e5f1/logout\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/numbers/{id}/events": {
      "get": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Ver o histórico da conexão",
        "operationId": "getNumbersByIdEvents",
        "description": "**Quem:** `connections`\n\n**Resposta:** `{ data: [NumberEvent] }`: o histórico do número, os 30 avisos do WhatsApp mais novos do último ano (`id`, `numberId`, `kind`, `reason?`, `until?`, `detail`, `at`; data-model.md). Sem nenhum, lista vazia",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [NumberEvent] }`: o histórico do número, os 30 avisos do WhatsApp mais novos do último ano (`id`, `numberId`, `kind`, `reason?`, `until?`, `detail`, `at`; data-model.md). Sem nenhum, lista vazia",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/NumberEvent"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/numbers/6750a1c2e4b0a1b2c3d4e5f1/events\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conectores": {
      "get": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Listar Conectores",
        "operationId": "getConectores",
        "description": "**Quem:** `connections`\n\n**Resposta:** `{ data: [Conector] }`",
        "responses": {
          "200": {
            "description": "`{ data: [Conector] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Conector"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/conectores\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Cadastrar Conector",
        "operationId": "postConectores",
        "description": "**Quem:** `connections`\n\n**Corpo:** `{ code, name }`\n\n**Resposta:** `201 Conector`; `code` são os 6 números da tela do Conector; `name` até 40 letras (`422` em `code` ou `name`); `404 pairing_not_found` vencido ou errado",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  }
                },
                "required": [
                  "code",
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Conector`; `code` são os 6 números da tela do Conector; `name` até 40 letras (`422` em `code` ou `name`); `404 pairing_not_found` vencido ou errado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conector"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`pairing_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/conectores\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"code\":\"texto\",\"name\":\"Ana Prado\"}'"
          }
        ]
      }
    },
    "/api/v1/conectores/{id}": {
      "patch": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Alterar Conector",
        "operationId": "patchConectoresById",
        "description": "**Quem:** `connections`\n\n**Corpo:** `{ name?, callNumberId? (null tira) }`\n\n**Resposta:** `Conector`; `name` de 1 a 40 letras (`422` em `name`); número de outro Conector, `422` em `callNumberId`; escolher o número de ligação num Conector que ainda não ligava confere o computador como o `calls` (`422` em `callNumberId`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "callNumberId": {
                    "type": "string",
                    "description": "(null tira)",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Conector`; `name` de 1 a 40 letras (`422` em `name`); número de outro Conector, `422` em `callNumberId`; escolher o número de ligação num Conector que ainda não ligava confere o computador como o `calls` (`422` em `callNumberId`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conector"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/conectores/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"callNumberId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Apagar Conector",
        "operationId": "deleteConectoresById",
        "description": "**Quem:** `connections`\n\n**Resposta:** `204`; revoga a chave; os números ficam sem Conector",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; revoga a chave; os números ficam sem Conector"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/conectores/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conectores/{id}/command": {
      "post": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Mandar comando ao Conector",
        "operationId": "postConectoresByIdCommand",
        "description": "**Quem:** `connections`\n\n**Corpo:** `{ cmd: \"restart\"|\"update\"|\"send_logs\"|\"call_check\"|\"web_code\" }`\n\n**Resposta:** `202`; `call_check` responde `{ status, ref }`, e a conferência completa chega pelo `conector.update` com `callCheck.ref` igual; `web_code` pede o código do WhatsApp Web do número de ligação, que chega pelo `conector.update` em `callCheck.web`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cmd": {
                    "type": "string",
                    "enum": [
                      "restart",
                      "update",
                      "send_logs",
                      "call_check",
                      "web_code"
                    ],
                    "example": "restart"
                  }
                },
                "required": [
                  "cmd"
                ]
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "`202`; `call_check` responde `{ status, ref }`, e a conferência completa chega pelo `conector.update` com `callCheck.ref` igual; `web_code` pede o código do WhatsApp Web do número de ligação, que chega pelo `conector.update` em `callCheck.web`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/conectores/6750a1c2e4b0a1b2c3d4e5f1/command\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"cmd\":\"restart\"}'"
          }
        ]
      }
    },
    "/api/v1/conectores/{id}/logs": {
      "get": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Ver os registros do Conector",
        "operationId": "getConectoresByIdLogs",
        "description": "**Quem:** `connections`\n\n**Resposta:** `{ data: [{ at, level, text }] }`, 200 por vez, mais recente primeiro (7 dias)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "level",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [{ at, level, text }] }`, 200 por vez, mais recente primeiro (7 dias)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "at": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          },
                          "level": {},
                          "text": {
                            "type": "string",
                            "example": "Bom dia, o pedido já saiu?"
                          }
                        },
                        "required": [
                          "at",
                          "level",
                          "text"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/conectores/6750a1c2e4b0a1b2c3d4e5f1/logs\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conectores/download": {
      "get": {
        "tags": [
          "Conexões: números e Conectores"
        ],
        "summary": "Baixar o Conector",
        "operationId": "getConectoresDownload",
        "description": "**Quem:** `connections`\n\n**Resposta:** `{ url, version }` do instalador (`CONECTOR_DOWNLOAD_URL`). No local, sem a variável, o `apps/conector/dist` servido pelo painel em `/downloads/`; `url` vazia quando não há instalador",
        "responses": {
          "200": {
            "description": "`{ url, version }` do instalador (`CONECTOR_DOWNLOAD_URL`). No local, sem a variável, o `apps/conector/dist` servido pelo painel em `/downloads/`; `url` vazia quando não há instalador",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "example": "https://exemplo.com.br"
                    },
                    "version": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "url",
                    "version"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/conectores/download\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/templates": {
      "get": {
        "tags": [
          "Número oficial: modelos e webhook"
        ],
        "summary": "Listar modelos de mensagem",
        "operationId": "getTemplates",
        "description": "**Quem:** todos (sem `connections`, só os `approved`)\n\n**Resposta:** `{ data: [Template] }`",
        "parameters": [
          {
            "name": "numberId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [Template] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Template"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos (sem `connections`, só os `approved`)",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/templates\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Número oficial: modelos e webhook"
        ],
        "summary": "Criar modelo de mensagem",
        "operationId": "postTemplates",
        "description": "**Quem:** `connections`\n\n**Corpo:** `{ numberId, name, language, category: \"utility\" ou \"marketing\", header?: { format, text?, example?, fileId? }, body, bodyExample: [], footer?, buttons: [{ type: \"quick_reply\", \"url\", \"phone_number\" ou \"copy_code\", text, url?, phone?, example? }] }`\n\n**Resposta:** `201 Template` em `pending` (vai para a análise da Meta); `422` com o campo; `409 template_taken`, `meta_error`; cabeçalho com arquivo pede `META_APP_ID` no servidor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "numberId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "language": {},
                  "category": {
                    "oneOf": [
                      {
                        "enum": [
                          "utility"
                        ],
                        "example": "utility"
                      },
                      {
                        "enum": [
                          "marketing"
                        ],
                        "example": "marketing"
                      }
                    ],
                    "description": "ou"
                  },
                  "header": {
                    "type": "object",
                    "properties": {
                      "format": {},
                      "text": {
                        "type": "string",
                        "example": "Bom dia, o pedido já saiu?"
                      },
                      "example": {},
                      "fileId": {
                        "type": "string",
                        "example": "6750a1c2e4b0a1b2c3d4e5f1"
                      }
                    },
                    "required": [
                      "format"
                    ]
                  },
                  "body": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "bodyExample": {
                    "type": "array",
                    "items": {}
                  },
                  "footer": {},
                  "buttons": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "quick_reply"
                          ],
                          "example": "quick_reply"
                        },
                        "url": {
                          "type": "string",
                          "example": "https://exemplo.com.br"
                        },
                        "phone_number": {},
                        "ou": {},
                        "copy_code": {},
                        "text": {
                          "type": "string",
                          "example": "Bom dia, o pedido já saiu?"
                        },
                        "phone": {
                          "type": "string",
                          "example": "5554999990000"
                        },
                        "example": {}
                      },
                      "required": [
                        "type",
                        "url",
                        "phone_number",
                        "ou",
                        "copy_code",
                        "text"
                      ]
                    }
                  }
                },
                "required": [
                  "numberId",
                  "name",
                  "language",
                  "category",
                  "body",
                  "bodyExample",
                  "buttons"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Template` em `pending` (vai para a análise da Meta); `422` com o campo; `409 template_taken`, `meta_error`; cabeçalho com arquivo pede `META_APP_ID` no servidor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Template"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`template_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/templates\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"numberId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"name\":\"Ana Prado\",\"category\":\"utility\",\"header\":{\"text\":\"Bom dia, o pedido já saiu?\",\"fileId\":\"6750a1c2e4b0a1b2c3d4e5f1\"},\"body\":\"Bom dia, o pedido já saiu?\",\"bodyExample\":[],\"buttons\":[{\"type\":\"quick_reply\",\"url\":\"https://exemplo.com.br\",\"text\":\"Bom dia, o pedido já saiu?\",\"phone\":\"5554999990000\"}]}'"
          }
        ]
      }
    },
    "/api/v1/templates/sync": {
      "post": {
        "tags": [
          "Número oficial: modelos e webhook"
        ],
        "summary": "Atualizar os modelos de mensagem",
        "operationId": "postTemplatesSync",
        "description": "**Quem:** `connections`\n\n**Corpo:** `{ numberId }`\n\n**Resposta:** `{ data: [Template] }` lidos da Meta; os que sumiram de lá saem. Com `?preview=1`, não grava: `{ total, added: [{ name, language }], removed: [{ name, language }] }` (quantos a Meta tem, os que entram e os que saem daqui), para o painel confirmar antes de tirar modelos",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "numberId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "numberId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ data: [Template] }` lidos da Meta; os que sumiram de lá saem. Com `?preview=1`, não grava: `{ total, added: [{ name, language }], removed: [{ name, language }] }` (quantos a Meta tem, os que entram e os que saem daqui), para o painel confirmar antes de tirar modelos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Template"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/templates/sync\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"numberId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/templates/{id}": {
      "delete": {
        "tags": [
          "Número oficial: modelos e webhook"
        ],
        "summary": "Apagar modelo de mensagem",
        "operationId": "deleteTemplatesById",
        "description": "**Quem:** `connections`\n\n**Resposta:** `204`; apaga na Meta o nome em todos os idiomas",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; apaga na Meta o nome em todos os idiomas"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`connections`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/templates/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/contacts": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Listar contatos",
        "operationId": "getContacts",
        "description": "**Resposta:** paginada `Contact`; o administrador vê todos; os outros, os das conversas que veem (pelas conexões do perfil e pelas operações) e os que ainda não têm conversa. `q` procura nome, e-mail, empresa, telefone (com ou sem o 9º dígito) e os meios (o @ também); `organizationId`: as pessoas da empresa; `birthMonth` (`01` a `12`): quem faz aniversário no mês; `field.<chave>`: a opção do campo de opções ou `true`/`false` do sim ou não (só campos que a pessoa vê; `422` em `field.<chave>` se não)",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "organizationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "birthMonth",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "field.<chave>",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "paginada `Contact`; o administrador vê todos; os outros, os das conversas que veem (pelas conexões do perfil e pelas operações) e os que ainda não têm conversa. `q` procura nome, e-mail, empresa, telefone (com ou sem o 9º dígito) e os meios (o @ também); `organizationId`: as pessoas da empresa; `birthMonth` (`01` a `12`): quem faz aniversário no mês; `field.<chave>`: a opção do campo de opções ou `true`/`false` do sim ou não (só campos que a pessoa vê; `422` em `field.<chave>` se não)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Paginada"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Contact"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/contacts\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Contatos"
        ],
        "summary": "Criar contato",
        "operationId": "postContacts",
        "description": "**Corpo:** `{ name, kind, channels?, organizations?, birthday?, birthYear?, city?, notes?, tags?, entryOperationId?, fields? }`. `fields`: `{ chave: valor }` dos campos personalizados que a pessoa vê (`null` ou vazio tira; campo que não existe ou que ela não vê dá `422` em `fields.<chave>`); com `fields` no corpo, os obrigatórios que ela vê precisam vir preenchidos (`422` em `fields.<chave>`). `channels` (até 20) substitui os meios e regrava `phones` e `email` (os dois que vierem junto ficam de fora); sem `channels`, valem `phones` e `email`. `organizations` (até 10): `[{ id, role?, primary? }]`, empresas vivas (`422` em `organizations.N`); substitui as empresas e regrava `organization`. `birthday` `MM-DD` (vazio tira, e tira o ano); `birthYear` de 1900 ao ano atual (0 tira). `entryOperationId`: a operação de entrada (`null` no `PATCH` tira; `422` se a operação não existe). Limites em letras: `name` 120, `email` 254, `organization` 120, `city` 80, `notes` 1.000, `label` 20, `role` 60 (`422` no campo; nos meios, `channels.N`)\n\n**Resposta:** `201 Contact`; `409 phone_taken` (telefone de outro contato): `message` \"Este telefone já é de Beatriz Lopes.\", `details.phone` com o telefone repetido e, se quem pediu vê aquele contato, `details.contactId` e `details.contactName`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "kind": {
                    "type": "string"
                  },
                  "channels": {},
                  "organizations": {},
                  "birthday": {},
                  "birthYear": {},
                  "city": {},
                  "notes": {},
                  "tags": {},
                  "entryOperationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "fields": {}
                },
                "required": [
                  "name",
                  "kind"
                ],
                "description": "`fields`: `{ chave: valor }` dos campos personalizados que a pessoa vê (`null` ou vazio tira; campo que não existe ou que ela não vê dá `422` em `fields.<chave>`); com `fields` no corpo, os obrigatórios que ela vê precisam vir preenchidos (`422` em `fields.<chave>`). `channels` (até 20) substitui os meios e regrava `phones` e `email` (os dois que vierem junto ficam de fora); sem `channels`, valem `phones` e `email`. `organizations` (até 10): `[{ id, role?, primary? }]`, empresas vivas (`422` em `organizations.N`); substitui as empresas e regrava `organization`. `birthday` `MM-DD` (vazio tira, e tira o ano); `birthYear` de 1900 ao ano atual (0 tira). `entryOperationId`: a operação de entrada (`null` no `PATCH` tira; `422` se a operação não existe). Limites em letras: `name` 120, `email` 254, `organization` 120, `city` 80, `notes` 1.000, `label` 20, `role` 60 (`422` no campo; nos meios, `channels.N`)"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Contact`; `409 phone_taken` (telefone de outro contato): `message` \"Este telefone já é de Beatriz Lopes.\", `details.phone` com o telefone repetido e, se quem pediu vê aquele contato, `details.contactId` e `details.contactName`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`phone_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/contacts\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"kind\":\"texto\",\"entryOperationId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/contacts/{id}": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Ver um contato",
        "operationId": "getContactsById",
        "description": "**Resposta:** `Contact`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Contact`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/contacts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Contatos"
        ],
        "summary": "Alterar contato",
        "operationId": "patchContactsById",
        "description": "**Corpo:** campos\n\n**Resposta:** `Contact`; os mesmos limites e o mesmo `409 phone_taken` do `POST`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "campos"
              }
            }
          },
          "description": "campos"
        },
        "responses": {
          "200": {
            "description": "`Contact`; os mesmos limites e o mesmo `409 phone_taken` do `POST`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`phone_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/contacts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Contatos"
        ],
        "summary": "Apagar contato",
        "operationId": "deleteContactsById",
        "description": "**Resposta:** `204` (permissão `deleteContacts`; some das listas, conversas ficam)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204` (permissão `deleteContacts`; some das listas, conversas ficam)"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/contacts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/contacts/{id}/merge": {
      "post": {
        "tags": [
          "Contatos"
        ],
        "summary": "Juntar dois contatos",
        "operationId": "postContactsByIdMerge",
        "description": "**Corpo:** `{ otherId }`\n\n**Resposta:** `Contact`: meios, empresas, etiquetas, conversas e cartões do outro passam para este (os principais deste continuam); o aniversário vem do outro se este não tem; o outro some das listas. Grupo não junta com pessoa (`409 merge_group`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "otherId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "otherId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Contact`: meios, empresas, etiquetas, conversas e cartões do outro passam para este (os principais deste continuam); o aniversário vem do outro se este não tem; o outro some das listas. Grupo não junta com pessoa (`409 merge_group`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`merge_group`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/contacts/6750a1c2e4b0a1b2c3d4e5f1/merge\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"otherId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/contacts/{id}/photo": {
      "put": {
        "tags": [
          "Contatos"
        ],
        "summary": "Trocar a foto do contato",
        "operationId": "putContactsByIdPhoto",
        "description": "**Corpo:** multipart: `file`\n\n**Resposta:** `Contact`; põe a foto da equipe na frente da do WhatsApp (regras da imagem). Quem vê o contato pode trocar; as conversas dele recebem `conversation.update` com o link novo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "description": "multipart: `file`"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Contact`; põe a foto da equipe na frente da do WhatsApp (regras da imagem). Quem vê o contato pode trocar; as conversas dele recebem `conversation.update` com o link novo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/contacts/6750a1c2e4b0a1b2c3d4e5f1/photo\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -F \"file=@arquivo.pdf\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Contatos"
        ],
        "summary": "Apagar a foto do contato",
        "operationId": "deleteContactsByIdPhoto",
        "description": "**Resposta:** `Contact`; tira a foto da equipe e volta a do WhatsApp",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Contact`; tira a foto da equipe e volta a do WhatsApp",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/contacts/6750a1c2e4b0a1b2c3d4e5f1/photo\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/contacts/{id}/conversations": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Listar atendimentos do contato",
        "operationId": "getContactsByIdConversations",
        "description": "**Resposta:** `{ data: Conversation[] }`: as conversas do contato que a pessoa vê, da mais recente, até 100 (sem notas nem mensagens)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: Conversation[] }`: as conversas do contato que a pessoa vê, da mais recente, até 100 (sem notas nem mensagens)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/Conversation"
                        },
                        {
                          "type": "array",
                          "items": {}
                        }
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/contacts/6750a1c2e4b0a1b2c3d4e5f1/conversations\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/contacts/{id}/cards": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Listar cartões do contato",
        "operationId": "getContactsByIdCards",
        "description": "**Resposta:** `{ data: Card[] }`: os cartões do contato, só das operações que a pessoa vê (com `allOperations` ou no Administrador, todas), do mais mexido, até 100",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: Card[] }`: os cartões do contato, só das operações que a pessoa vê (com `allOperations` ou no Administrador, todas), do mais mexido, até 100",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/Card"
                        },
                        {
                          "type": "array",
                          "items": {}
                        }
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/contacts/6750a1c2e4b0a1b2c3d4e5f1/cards\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/organizations": {
      "get": {
        "tags": [
          "Empresas"
        ],
        "summary": "Listar empresas",
        "operationId": "getOrganizations",
        "description": "**Resposta:** paginada `Organization`, pelo nome. `q` procura nome (sem olhar acento), razão social e CNPJ; `field.<chave>` como no contato",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "field.<chave>",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "paginada `Organization`, pelo nome. `q` procura nome (sem olhar acento), razão social e CNPJ; `field.<chave>` como no contato",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Paginada"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Organization"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/organizations\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Empresas"
        ],
        "summary": "Criar empresa",
        "operationId": "postOrganizations",
        "description": "**Corpo:** `{ name, kind?, legalName?, document?, site?, city?, notes?, tags?, fields? }` (`fields` como no contato). `document`: CNPJ (14 números) ou CPF (11), com ou sem pontuação. Limites em letras: `name` 120, `legalName` 160, `site` 200, `city` 80, `notes` 1.000 (`422` no campo)\n\n**Resposta:** `201 Organization`; `409 org_taken` (o mesmo nome, sem olhar acento nem maiúsculas) ou `409 document_taken` (o mesmo CNPJ): `message` \"Este CNPJ já é de Padaria Pão de Luz.\", `details.organizationId` e `details.organizationName`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "kind": {
                    "type": "string"
                  },
                  "legalName": {
                    "type": "string"
                  },
                  "document": {},
                  "site": {},
                  "city": {},
                  "notes": {},
                  "tags": {},
                  "fields": {}
                },
                "required": [
                  "name"
                ],
                "description": "(`fields` como no contato). `document`: CNPJ (14 números) ou CPF (11), com ou sem pontuação. Limites em letras: `name` 120, `legalName` 160, `site` 200, `city` 80, `notes` 1.000 (`422` no campo)"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Organization`; `409 org_taken` (o mesmo nome, sem olhar acento nem maiúsculas) ou `409 document_taken` (o mesmo CNPJ): `message` \"Este CNPJ já é de Padaria Pão de Luz.\", `details.organizationId` e `details.organizationName`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`org_taken`, `document_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/organizations\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"kind\":\"texto\",\"legalName\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/organizations/{id}": {
      "get": {
        "tags": [
          "Empresas"
        ],
        "summary": "Ver uma empresa",
        "operationId": "getOrganizationsById",
        "description": "**Resposta:** `Organization`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Organization`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/organizations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Empresas"
        ],
        "summary": "Alterar empresa",
        "operationId": "patchOrganizationsById",
        "description": "**Corpo:** campos (vazio tira)\n\n**Resposta:** `Organization`; os mesmos limites e `409` do `POST`. Renomear acerta o nome nos contatos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "campos (vazio tira)"
              }
            }
          },
          "description": "campos (vazio tira)"
        },
        "responses": {
          "200": {
            "description": "`Organization`; os mesmos limites e `409` do `POST`. Renomear acerta o nome nos contatos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/organizations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Empresas"
        ],
        "summary": "Apagar empresa",
        "operationId": "deleteOrganizationsById",
        "description": "**Resposta:** `204` (permissão `deleteContacts`): some das listas e sai dos contatos; as pessoas ficam",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204` (permissão `deleteContacts`): some das listas e sai dos contatos; as pessoas ficam"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/organizations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/organizations/{id}/merge": {
      "post": {
        "tags": [
          "Empresas"
        ],
        "summary": "Juntar duas empresas",
        "operationId": "postOrganizationsByIdMerge",
        "description": "**Corpo:** `{ otherId }`\n\n**Resposta:** `Organization`: as pessoas e as etiquetas da outra passam para esta (razão social, CNPJ, site e cidade vêm da outra se esta não tem); a outra some",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "otherId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "otherId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Organization`: as pessoas e as etiquetas da outra passam para esta (razão social, CNPJ, site e cidade vêm da outra se esta não tem); a outra some",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/organizations/6750a1c2e4b0a1b2c3d4e5f1/merge\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"otherId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/organizations/{id}/conversations": {
      "get": {
        "tags": [
          "Empresas"
        ],
        "summary": "Listar atendimentos da empresa",
        "operationId": "getOrganizationsByIdConversations",
        "description": "**Resposta:** `{ data: Conversation[] }`: as conversas das pessoas da empresa que a pessoa vê, até 100",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: Conversation[] }`: as conversas das pessoas da empresa que a pessoa vê, até 100",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/Conversation"
                        },
                        {
                          "type": "array",
                          "items": {}
                        }
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/organizations/6750a1c2e4b0a1b2c3d4e5f1/conversations\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/organizations/{id}/cards": {
      "get": {
        "tags": [
          "Empresas"
        ],
        "summary": "Listar cartões da empresa",
        "operationId": "getOrganizationsByIdCards",
        "description": "**Resposta:** `{ data: Card[] }`: os cartões das pessoas da empresa, só das operações de que a pessoa participa, até 100",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: Card[] }`: os cartões das pessoas da empresa, só das operações de que a pessoa participa, até 100",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/Card"
                        },
                        {
                          "type": "array",
                          "items": {}
                        }
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/organizations/6750a1c2e4b0a1b2c3d4e5f1/cards\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/custom-fields": {
      "get": {
        "tags": [
          "Campos personalizados"
        ],
        "summary": "Listar campos personalizados",
        "operationId": "getCustomFields",
        "description": "**Resposta:** `Fichas` cortada para quem pede: sem as seções e os campos que ela não vê, nem as abas sem seção que ela vê (o Administrador vê tudo)",
        "responses": {
          "200": {
            "description": "`Fichas` cortada para quem pede: sem as seções e os campos que ela não vê, nem as abas sem seção que ela vê (o Administrador vê tudo)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fichas"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/custom-fields\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/custom-fields/{entity}/sections": {
      "post": {
        "tags": [
          "Campos personalizados"
        ],
        "summary": "Criar seção de campos",
        "operationId": "postCustomFieldsByEntitySections",
        "description": "**Corpo:** `{ name, tabId?, newTab?, access, fields }` (`fields`). `newTab` cria a aba (até 30 letras, até 8 abas, sem repetir nem usar Dados, Conversas, Cartões ou Pessoas). `access.mode` `all`, `admin` (só o perfil Administrador vê) ou `ops` (com pelo menos uma área ou operação que exista). `fields` (1 a 40): `{ key?, name, type, options?, required?, access? }`; nome até 40 letras e único no cadastro; `options` (1 a 50, até 60 letras) só em `select` e `multi`; `access` do campo só `admin` ou `ops`\n\n**Resposta:** `Fichas`; `409 ficha_full` com 30 seções; `422` em `name`, `newTab`, `tabId`, `access` ou `fields.N.<campo>`",
        "parameters": [
          {
            "name": "entity",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "tabId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "newTab": {},
                  "access": {},
                  "fields": {}
                },
                "required": [
                  "name",
                  "access",
                  "fields"
                ],
                "description": "(`fields`). `newTab` cria a aba (até 30 letras, até 8 abas, sem repetir nem usar Dados, Conversas, Cartões ou Pessoas). `access.mode` `all`, `admin` (só o perfil Administrador vê) ou `ops` (com pelo menos uma área ou operação que exista). `fields` (1 a 40): `{ key?, name, type, options?, required?, access? }`; nome até 40 letras e único no cadastro; `options` (1 a 50, até 60 letras) só em `select` e `multi`; `access` do campo só `admin` ou `ops`"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Fichas`; `409 ficha_full` com 30 seções; `422` em `name`, `newTab`, `tabId`, `access` ou `fields.N.<campo>`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fichas"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`ficha_full`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/custom-fields/<entity>/sections\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"tabId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/custom-fields/{entity}/sections/{id}": {
      "patch": {
        "tags": [
          "Campos personalizados"
        ],
        "summary": "Alterar seção de campos",
        "operationId": "patchCustomFieldsByEntitySectionsById",
        "description": "**Corpo:** o mesmo corpo (`fields`). O campo que vem com `key` é o mesmo de antes (o `type` não muda: `422` \"O tipo não muda depois de criado.\"); o que não vem sai, com os valores dele\n\n**Resposta:** `Fichas`",
        "parameters": [
          {
            "name": "entity",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "o mesmo corpo (`fields`). O campo que vem com `key` é o mesmo de antes (o `type` não muda: `422` \"O tipo não muda depois de criado.\"); o que não vem sai, com os valores dele"
              }
            }
          },
          "description": "o mesmo corpo (`fields`). O campo que vem com `key` é o mesmo de antes (o `type` não muda: `422` \"O tipo não muda depois de criado.\"); o que não vem sai, com os valores dele"
        },
        "responses": {
          "200": {
            "description": "`Fichas`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fichas"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/custom-fields/<entity>/sections/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Campos personalizados"
        ],
        "summary": "Apagar seção de campos",
        "operationId": "deleteCustomFieldsByEntitySectionsById",
        "description": "**Resposta:** `Fichas` (`fields`); os valores dos campos dela saem de todas as fichas",
        "parameters": [
          {
            "name": "entity",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Fichas` (`fields`); os valores dos campos dela saem de todas as fichas",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fichas"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/custom-fields/<entity>/sections/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/custom-fields/{entity}/sections/{id}/move": {
      "post": {
        "tags": [
          "Campos personalizados"
        ],
        "summary": "Mover a seção de campos",
        "operationId": "postCustomFieldsByEntitySectionsByIdMove",
        "description": "**Corpo:** `{ dir: \"up\" | \"down\" }` (`fields`)\n\n**Resposta:** `Fichas`",
        "parameters": [
          {
            "name": "entity",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "dir": {
                    "type": "string",
                    "enum": [
                      "up",
                      "down"
                    ],
                    "example": "up"
                  }
                },
                "required": [
                  "dir"
                ],
                "description": "(`fields`)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Fichas`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fichas"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/custom-fields/<entity>/sections/6750a1c2e4b0a1b2c3d4e5f1/move\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"dir\":\"up\"}'"
          }
        ]
      }
    },
    "/api/v1/custom-fields/{entity}/tabs": {
      "put": {
        "tags": [
          "Campos personalizados"
        ],
        "summary": "Definir as abas dos campos",
        "operationId": "putCustomFieldsByEntityTabs",
        "description": "**Corpo:** `{ tabs: [{ id?, name }] }` (`fields`): a lista inteira, na ordem; sem `id`, aba nova; a aba que não vem sai e as seções dela voltam para Dados\n\n**Resposta:** `Fichas`; `422` em `tabs.N`",
        "parameters": [
          {
            "name": "entity",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tabs": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "6750a1c2e4b0a1b2c3d4e5f1"
                        },
                        "name": {
                          "type": "string",
                          "example": "Ana Prado"
                        }
                      },
                      "required": [
                        "name"
                      ]
                    }
                  }
                },
                "required": [
                  "tabs"
                ],
                "description": "(`fields`): a lista inteira, na ordem; sem `id`, aba nova; a aba que não vem sai e as seções dela voltam para Dados"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Fichas`; `422` em `tabs.N`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fichas"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/custom-fields/<entity>/tabs\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"tabs\":[{\"id\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"name\":\"Ana Prado\"}]}'"
          }
        ]
      }
    },
    "/api/v1/conversations": {
      "get": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Listar conversas",
        "operationId": "getConversations",
        "description": "**Resposta:** `{ data: [Conversation], next: \"<cursor>\" }`, por `lastMessageAt` decrescente, 40 por vez; `before=<next>` traz as seguintes. `all` (o padrão) = todas, fechadas também, como no WhatsApp; `open` = as abertas (`open` e `bot`); `queue` = abertas sem dono; `operationId=none` = sem operação; `q` procura nome, telefone, grupo, etiqueta e protocolo (o aberto ou um antigo da conversa, com o texto exato do protocolo). Com `old=1` e `q`, procura nas conversas paradas há mais de 6 meses (arquivo frio), pelo nome ou telefone do contato e pelo protocolo, com o número e a operação da lista e sem a situação: uma página só (`next` vazio), cada uma com `archived: true`. Abrir uma delas (`GET /conversations/{id}`) traz de volta",
        "parameters": [
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "open",
                "mine",
                "queue",
                "bot",
                "resolved"
              ],
              "example": "all"
            }
          },
          {
            "name": "numberId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "operationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [Conversation], next: \"<cursor>\" }`, por `lastMessageAt` decrescente, 40 por vez; `before=<next>` traz as seguintes. `all` (o padrão) = todas, fechadas também, como no WhatsApp; `open` = as abertas (`open` e `bot`); `queue` = abertas sem dono; `operationId=none` = sem operação; `q` procura nome, telefone, grupo, etiqueta e protocolo (o aberto ou um antigo da conversa, com o texto exato do protocolo). Com `old=1` e `q`, procura nas conversas paradas há mais de 6 meses (arquivo frio), pelo nome ou telefone do contato e pelo protocolo, com o número e a operação da lista e sem a situação: uma página só (`next` vazio), cada uma com `archived: true`. Abrir uma delas (`GET /conversations/{id}`) traz de volta",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Conversation"
                      }
                    },
                    "next": {
                      "type": "string",
                      "enum": [
                        "<cursor>"
                      ],
                      "example": "<cursor>"
                    }
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/conversations\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Abrir conversa com um contato",
        "operationId": "postConversations",
        "description": "**Corpo:** `{ numberId, contactId? , phone?, operationId? }`\n\n**Resposta:** `201 Conversation` com a pessoa como dona; `200` com a que já existe; `409 conversation_hidden` se já existe numa operação que a pessoa não vê. O número precisa estar no perfil da pessoa e, sem `allOperations`, atender uma operação dela (`422` em `numberId`); `operationId` precisa atender o número e ser uma operação em que ela atende, não só vê (`422` em `operationId`); sem ele, fica a única operação do número em que ela atende, e quem só vê as operações do número recebe `403 view_only`. Sem `contactId`, usa o contato que já tem o telefone (com ou sem o 9º dígito) ou cria um. Com `contactId`, `phone` é o **Para** da Nova conversa: um dos WhatsApp do contato (`phones`, com ou sem o 9º dígito; fora deles, `422` em `phone`), e sem ele vale o principal; contato sem WhatsApp dá `422` em `contactId`. A que já existe é achada pelo número e pelo telefone da conversa (`contact.phone`) ou pelo chat, com ou sem o 9º dígito; só sem `phone` vale qualquer conversa do contato no número. Na que já existe e está concluída, `operationId` (com as mesmas regras) passa a ser a operação dela, para o atendimento novo começar ali; na aberta, `operationId` não muda nada. A primeira mensagem vai depois, por `POST /conversations/{id}/messages`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "numberId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "contactId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "phone": {
                    "type": "string",
                    "example": "5554999990000"
                  },
                  "operationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "numberId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Conversation` com a pessoa como dona; `200` com a que já existe; `409 conversation_hidden` se já existe numa operação que a pessoa não vê. O número precisa estar no perfil da pessoa e, sem `allOperations`, atender uma operação dela (`422` em `numberId`); `operationId` precisa atender o número e ser uma operação em que ela atende, não só vê (`422` em `operationId`); sem ele, fica a única operação do número em que ela atende, e quem só vê as operações do número recebe `403 view_only`. Sem `contactId`, usa o contato que já tem o telefone (com ou sem o 9º dígito) ou cria um. Com `contactId`, `phone` é o **Para** da Nova conversa: um dos WhatsApp do contato (`phones`, com ou sem o 9º dígito; fora deles, `422` em `phone`), e sem ele vale o principal; contato sem WhatsApp dá `422` em `contactId`. A que já existe é achada pelo número e pelo telefone da conversa (`contact.phone`) ou pelo chat, com ou sem o 9º dígito; só sem `phone` vale qualquer conversa do contato no número. Na que já existe e está concluída, `operationId` (com as mesmas regras) passa a ser a operação dela, para o atendimento novo começar ali; na aberta, `operationId` não muda nada. A primeira mensagem vai depois, por `POST /conversations/{id}/messages`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`view_only`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`conversation_hidden`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/conversations\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"numberId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"contactId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"phone\":\"5554999990000\",\"operationId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/conversations/counts": {
      "get": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Contar conversas por filtro",
        "operationId": "getConversationsCounts",
        "description": "**Resposta:** `{ filters: { open, mine, queue, bot }, operations: { \"<operationId>\": n, \"none\": n } }`: quantas conversas não concluídas há em cada aba (com a operação escolhida) e em cada operação (com a aba escolhida), com o mesmo número e a mesma busca da lista e só o que a pessoa vê. Concluídas não são contadas (`filter=resolved` traz `operations` vazio; com `all`, `operations` conta só as abertas, e o painel não mostra esses números)",
        "parameters": [
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "numberId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "operationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ filters: { open, mine, queue, bot }, operations: { \"<operationId>\": n, \"none\": n } }`: quantas conversas não concluídas há em cada aba (com a operação escolhida) e em cada operação (com a aba escolhida), com o mesmo número e a mesma busca da lista e só o que a pessoa vê. Concluídas não são contadas (`filter=resolved` traz `operations` vazio; com `all`, `operations` conta só as abertas, e o painel não mostra esses números)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "filters": {
                      "type": "object",
                      "properties": {
                        "open": {},
                        "mine": {},
                        "queue": {},
                        "bot": {}
                      },
                      "required": [
                        "open",
                        "mine",
                        "queue",
                        "bot"
                      ]
                    },
                    "operations": {
                      "type": "object",
                      "properties": {
                        "<operationId>": {
                          "description": "n"
                        },
                        "none": {
                          "description": "n"
                        }
                      },
                      "required": [
                        "<operationId>",
                        "none"
                      ]
                    }
                  },
                  "required": [
                    "filters",
                    "operations"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/conversations/counts\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conversations/{id}": {
      "get": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Ver uma conversa",
        "operationId": "getConversationsById",
        "description": "**Resposta:** `Conversation`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Conversation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Alterar conversa",
        "operationId": "patchConversationsById",
        "description": "**Corpo:** `{ tags?, operationId? (null tira), ownerId? (null solta), status? }`\n\n**Resposta:** `Conversation`; ao mudar de operação, o dono sai se não atende a nova e as etiquetas são tiradas. A operação nova precisa atender o número da conversa e o dono novo, poder atender o número (administrador; ou com o número no perfil e com `allOperations` ou atendendo, não só vendo, uma operação do número); se não, `422` em `operationId` ou `ownerId` (cada número com a sua equipe). Quem só vê as operações da conversa (e não é o dono) recebe `403 view_only`. `tags`: nomes das etiquetas da operação da conversa (a nova, quando muda junto); sem operação, `422` em `tags`; o cartão aberto da conversa fica igual. Na conversa com o agente (`bot`), dar dono ou mudar o status tira o agente (sem `status`, vira `open`). A troca de operação ou de dono vai para as passagens do atendimento aberto; `resolved` fecha o atendimento e grava `closed`. `open` na conversa fechada (o **Abrir atendimento**) abre na hora o atendimento novo, com o protocolo, e a conversa fica com quem abriu (sem `ownerId`). Com o número da conversa parado (desconectado, sem Conector, bloqueado, com o token vencido ou arquivado; reconectando não conta), esse `open` dá `422 number_down` com o motivo para a pessoa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tags": {},
                  "operationId": {
                    "type": "string",
                    "description": "(null tira)",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "ownerId": {
                    "type": "string",
                    "description": "(null solta)",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "status": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Conversation`; ao mudar de operação, o dono sai se não atende a nova e as etiquetas são tiradas. A operação nova precisa atender o número da conversa e o dono novo, poder atender o número (administrador; ou com o número no perfil e com `allOperations` ou atendendo, não só vendo, uma operação do número); se não, `422` em `operationId` ou `ownerId` (cada número com a sua equipe). Quem só vê as operações da conversa (e não é o dono) recebe `403 view_only`. `tags`: nomes das etiquetas da operação da conversa (a nova, quando muda junto); sem operação, `422` em `tags`; o cartão aberto da conversa fica igual. Na conversa com o agente (`bot`), dar dono ou mudar o status tira o agente (sem `status`, vira `open`). A troca de operação ou de dono vai para as passagens do atendimento aberto; `resolved` fecha o atendimento e grava `closed`. `open` na conversa fechada (o **Abrir atendimento**) abre na hora o atendimento novo, com o protocolo, e a conversa fica com quem abriu (sem `ownerId`). Com o número da conversa parado (desconectado, sem Conector, bloqueado, com o token vencido ou arquivado; reconectando não conta), esse `open` dá `422 number_down` com o motivo para a pessoa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`view_only`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`number_down`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"operationId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"ownerId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"status\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/conversations/{id}/tickets": {
      "get": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Listar protocolos da conversa",
        "operationId": "getConversationsByIdTickets",
        "description": "**Resposta:** paginada, `TicketRow`, do mais novo: todos os atendimentos da conversa, para quem vê a conversa, com os filtros de `GET /tickets` (`q` só no protocolo). Cada um com `id`, `protocol?`, `number`, `operation?`, `origin`, `openedAt`, `repliedAt?`, `repliedBy?`, `resolvedAt?`, `resolvedBy?`, `entry?`, `closeReason?` (`resolved`, `idle`), `events[]` (`kind`: `opened`, `operation`, `owner`, `bot`, `resolved`, `idle`; `at`, `by?`, `from?`, `to?`), `rating?` (a avaliação: `survey` Ref, `status` `waiting`, `done` ou `expired`, `sentAt`, `expiresAt`, `score?` de 1 a 5, `answeredAt?`, `comment?`; já vem `expired` quando o prazo passou). Ver atendimento.md",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "+5554999990000"
            }
          },
          {
            "name": "operationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "paginada, `TicketRow`, do mais novo: todos os atendimentos da conversa, para quem vê a conversa, com os filtros de `GET /tickets` (`q` só no protocolo). Cada um com `id`, `protocol?`, `number`, `operation?`, `origin`, `openedAt`, `repliedAt?`, `repliedBy?`, `resolvedAt?`, `resolvedBy?`, `entry?`, `closeReason?` (`resolved`, `idle`), `events[]` (`kind`: `opened`, `operation`, `owner`, `bot`, `resolved`, `idle`; `at`, `by?`, `from?`, `to?`), `rating?` (a avaliação: `survey` Ref, `status` `waiting`, `done` ou `expired`, `sentAt`, `expiresAt`, `score?` de 1 a 5, `answeredAt?`, `comment?`; já vem `expired` quando o prazo passou). Ver atendimento.md",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Paginada"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/TicketRow"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/tickets\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/tickets": {
      "get": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Listar protocolos",
        "operationId": "getTickets",
        "description": "**Resposta:** paginada, `TicketRow`, do mais novo (`openedAt`). A busca de protocolos (atendimento.md): só os protocolos que a pessoa vê (o recorte das conversas, pelas operações por onde o protocolo passou, ou os que passaram por ela). `from` e `to`: dias `AAAA-MM-DD` da abertura, no fuso dos relatórios, os dois incluídos. `userId`: qualquer usuário que passou pelo protocolo; com `role=replied`, só quem respondeu primeiro, e com `role=resolved`, só quem concluiu. `operationId`: qualquer operação por onde passou. `status`: `open`, `resolved` (concluído por alguém) ou `idle` (fechado sem resposta). `origin`: `contact` ou `team`. `agent`: `yes` (o agente de IA atendeu) ou `no`. `forwarded`: `yes` (passou por mais de um usuário ou operação) ou `no`. `firstReply`: `15m`, `1h` (de 15 min a 1 h), `more` ou `none` (o contato escreveu e ninguém respondeu). `organizationId`: os das pessoas da empresa. `q` acha o protocolo e o nome ou telefone do contato; com `contactId` ou `organizationId`, acha também um trecho de mensagem (texto ou nome do arquivo, sem diferença de acento, nas 500 mensagens mais novas que têm o trecho, recentes e do arquivo frio), e cada protocolo vem com `hits` (até 3: `id`, `at`, `text`, `fromMe`) e `hitCount`. `TicketRow` é o `Ticket` com `contactId?` e `contact?` (`id`, `name`, `phone?`, `organizations`, com os nomes de agora). Valor de filtro fora da lista dá `422` no campo",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "+5554999990000"
            }
          },
          {
            "name": "userId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "role",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "numberId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "operationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "organizationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "contactId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "origin",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agent",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "forwarded",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "firstReply",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "paginada, `TicketRow`, do mais novo (`openedAt`). A busca de protocolos (atendimento.md): só os protocolos que a pessoa vê (o recorte das conversas, pelas operações por onde o protocolo passou, ou os que passaram por ela). `from` e `to`: dias `AAAA-MM-DD` da abertura, no fuso dos relatórios, os dois incluídos. `userId`: qualquer usuário que passou pelo protocolo; com `role=replied`, só quem respondeu primeiro, e com `role=resolved`, só quem concluiu. `operationId`: qualquer operação por onde passou. `status`: `open`, `resolved` (concluído por alguém) ou `idle` (fechado sem resposta). `origin`: `contact` ou `team`. `agent`: `yes` (o agente de IA atendeu) ou `no`. `forwarded`: `yes` (passou por mais de um usuário ou operação) ou `no`. `firstReply`: `15m`, `1h` (de 15 min a 1 h), `more` ou `none` (o contato escreveu e ninguém respondeu). `organizationId`: os das pessoas da empresa. `q` acha o protocolo e o nome ou telefone do contato; com `contactId` ou `organizationId`, acha também um trecho de mensagem (texto ou nome do arquivo, sem diferença de acento, nas 500 mensagens mais novas que têm o trecho, recentes e do arquivo frio), e cada protocolo vem com `hits` (até 3: `id`, `at`, `text`, `fromMe`) e `hitCount`. `TicketRow` é o `Ticket` com `contactId?` e `contact?` (`id`, `name`, `phone?`, `organizations`, com os nomes de agora). Valor de filtro fora da lista dá `422` no campo",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Paginada"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/TicketRow"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/tickets\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/tickets/{id}": {
      "get": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Ver um protocolo",
        "operationId": "getTicketsById",
        "description": "**Resposta:** `TicketRow`. Abre para quem acha o protocolo na busca ou vê a conversa dele (a aba Protocolos da conversa); fora disso, `404`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`TicketRow`. Abre para quem acha o protocolo na busca ou vê a conversa dele (a aba Protocolos da conversa); fora disso, `404`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketRow"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/tickets/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/tickets/{id}/messages": {
      "get": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Ver as mensagens do protocolo",
        "operationId": "getTicketsByIdMessages",
        "description": "**Resposta:** `{ data: [Message] (mais antiga primeiro), hasMore }`: as mensagens da conversa entre a abertura e a conclusão do protocolo (até agora, se aberto), até 1.000, das recentes e do arquivo frio. A conversa parada continua no arquivo: ler o protocolo não traz ela de volta",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [Message] (mais antiga primeiro), hasMore }`: as mensagens da conversa entre a abertura e a conclusão do protocolo (até agora, se aberto), até 1.000, das recentes e do arquivo frio. A conversa parada continua no arquivo: ler o protocolo não traz ela de volta",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Message"
                      },
                      "description": "(mais antiga primeiro)"
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "data",
                    "hasMore"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/tickets/6750a1c2e4b0a1b2c3d4e5f1/messages\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conversations/{id}/agent": {
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Ligar ou desligar o agente na conversa",
        "operationId": "postConversationsByIdAgent",
        "description": "**Corpo:** `{ on, agentId? }`\n\n**Resposta:** `Conversation` — a chave \"Agente de IA\": `on: true` põe o agente (o escolhido ou o que cobre a conversa) e a conversa vira `bot`, sem dono; `false` tira e a pessoa vira a dona. `409 ai_off`, `ai_group` ou `no_agent`; `422` com `agentId` desligado",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "on": {},
                  "agentId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "on"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Conversation` — a chave \"Agente de IA\": `on: true` põe o agente (o escolhido ou o que cobre a conversa) e a conversa vira `bot`, sem dono; `false` tira e a pessoa vira a dona. `409 ai_off`, `ai_group` ou `no_agent`; `422` com `agentId` desligado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`ai_off`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/agent\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"agentId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/conversations/{id}/suggestion": {
      "delete": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Descartar a sugestão de resposta",
        "operationId": "deleteConversationsByIdSuggestion",
        "description": "**Resposta:** `204` — descarta a sugestão da IA",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204` — descarta a sugestão da IA"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/suggestion\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conversations/{id}/read": {
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Marcar a conversa como lida",
        "operationId": "postConversationsByIdRead",
        "description": "**Resposta:** `204` (zera `unread`; manda o \"lido\" ao WhatsApp)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204` (zera `unread`; manda o \"lido\" ao WhatsApp)"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/read\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conversations/{id}/messages": {
      "get": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Listar mensagens da conversa",
        "operationId": "getConversationsByIdMessages",
        "description": "**Resposta:** `{ data: [Message] (mais antiga primeiro), hasMore }`; as de mais de 90 dias vêm do arquivo frio, na mesma lista",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "<messageId>"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": "50"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [Message] (mais antiga primeiro), hasMore }`; as de mais de 90 dias vêm do arquivo frio, na mesma lista",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Message"
                      },
                      "description": "(mais antiga primeiro)"
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "data",
                    "hasMore"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/messages\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Mandar mensagem na conversa",
        "operationId": "postConversationsByIdMessages",
        "description": "**Corpo:** `SendBody`\n\n**Resposta:** `201 Message` com `status: \"pending\"` (ou `held` no local). Mensagem que inicia conversa passa pelo ritmo do número: `409 outside_window`, `daily_limit` ou `daily_new_limit` (mensagens.md); com a trava de contato novo do WhatsApp valendo, `409 reachout_locked` (com `details.until`) para quem não escreveu nos últimos 30 dias (trava). Quem só vê as operações da conversa (e não é o dono): `403 view_only`. Só a dona da conversa envia: na fila, com `status: \"bot\"` ou com outro usuário, `403 not_owner`. A conversa fechada aceita e reabre com quem mandou (a Nova conversa)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendBody"
              }
            }
          },
          "description": "`SendBody`"
        },
        "responses": {
          "201": {
            "description": "`201 Message` com `status: \"pending\"` (ou `held` no local). Mensagem que inicia conversa passa pelo ritmo do número: `409 outside_window`, `daily_limit` ou `daily_new_limit` (mensagens.md); com a trava de contato novo do WhatsApp valendo, `409 reachout_locked` (com `details.until`) para quem não escreveu nos últimos 30 dias (trava). Quem só vê as operações da conversa (e não é o dono): `403 view_only`. Só a dona da conversa envia: na fila, com `status: \"bot\"` ou com outro usuário, `403 not_owner`. A conversa fechada aceita e reabre com quem mandou (a Nova conversa)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`view_only`, `not_owner`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`outside_window`, `reachout_locked`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/messages\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"kind\":\"text|image|video|gif|audio|voice|document|sticker|location|contact|poll\",\"text\":\"texto ou legenda\",\"fileId\":\"id de POST /files (para tipos com arquivo)\",\"quotedId\":\"id da mensagem respondida\",\"location\":{\"lat\":0,\"lng\":0,\"name\":\"\",\"address\":\"\"},\"contacts\":[{\"name\":\"\",\"vcard\":\"\"}],\"poll\":{\"question\":\"\",\"options\":[\"\",\"\"],\"selectable\":1},\"viewOnce\":false,\"noPreview\":false,\"template\":{\"id\":\"id do Template\",\"params\":{\"header\":[],\"body\":[\"Marina\",\"R$ 120,00\"],\"buttons\":[\"\"]},\"headerFileId\":\"id de POST /files\"}}'"
          }
        ]
      }
    },
    "/api/v1/link-preview": {
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Buscar a prévia de um link",
        "operationId": "postLinkPreview",
        "description": "**Corpo:** `{ url }` (o texto da caixa; vale o primeiro link)\n\n**Resposta:** `{ preview: ChatPreview | null }` — a prévia que vai junto com a mensagem, com `image` de 1 hora; `null` quando a página não tem título nem texto ou não respondeu (midia.md)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "example": "https://exemplo.com.br"
                  }
                },
                "required": [
                  "url"
                ],
                "description": "(o texto da caixa; vale o primeiro link)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ preview: ChatPreview | null }` — a prévia que vai junto com a mensagem, com `image` de 1 hora; `null` quando a página não tem título nem texto ou não respondeu (midia.md)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "preview": {
                      "description": "ChatPreview Pode vir null."
                    }
                  },
                  "required": [
                    "preview"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/link-preview\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"url\":\"https://exemplo.com.br\"}'"
          }
        ]
      }
    },
    "/api/v1/messages/{id}/react": {
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Reagir à mensagem",
        "operationId": "postMessagesByIdReact",
        "description": "**Corpo:** `{ emoji, conversationId }` (emoji vazio tira; a conversa acha a mensagem com mais de 90 dias, no arquivo frio)\n\n**Resposta:** `204`; `409 not_sent` se a mensagem ainda não chegou ao WhatsApp; `403 not_owner` se a conversa não está com a pessoa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "emoji": {},
                  "conversationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "emoji",
                  "conversationId"
                ],
                "description": "(emoji vazio tira; a conversa acha a mensagem com mais de 90 dias, no arquivo frio)"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "`204`; `409 not_sent` se a mensagem ainda não chegou ao WhatsApp; `403 not_owner` se a conversa não está com a pessoa"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`not_owner`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_sent`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/messages/6750a1c2e4b0a1b2c3d4e5f1/react\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/messages/{id}": {
      "patch": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Editar mensagem enviada",
        "operationId": "patchMessagesById",
        "description": "**Corpo:** `{ text }` (até 65.536 letras)\n\n**Resposta:** `Message` — editar, só texto enviado por nós, até 15 min. Texto igual ao atual: devolve a mensagem sem mexer (não ganha \"editada\"). `422 text` vazio ou longo demais; `403 not_owner` se a conversa não está com a pessoa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  }
                },
                "required": [
                  "text"
                ],
                "description": "(até 65.536 letras)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Message` — editar, só texto enviado por nós, até 15 min. Texto igual ao atual: devolve a mensagem sem mexer (não ganha \"editada\"). `422 text` vazio ou longo demais; `403 not_owner` se a conversa não está com a pessoa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`not_owner`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`text`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/messages/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\"}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Apagar mensagem",
        "operationId": "deleteMessagesById",
        "description": "**Resposta:** `204` — apagar para todos, só enviada por nós, até 2 dias; `403 not_owner` se a conversa não está com a pessoa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204` — apagar para todos, só enviada por nós, até 2 dias; `403 not_owner` se a conversa não está com a pessoa"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`not_owner`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/messages/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/messages/{id}/retry": {
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Tentar enviar a mensagem de novo",
        "operationId": "postMessagesByIdRetry",
        "description": "**Resposta:** `Message` — reenvia a que falhou; `403 not_owner` se a conversa não está com a pessoa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Message` — reenvia a que falhou; `403 not_owner` se a conversa não está com a pessoa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`not_owner`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/messages/6750a1c2e4b0a1b2c3d4e5f1/retry\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/messages/{id}/transcribe": {
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Transcrever a mensagem de voz",
        "operationId": "postMessagesByIdTranscribe",
        "description": "**Corpo:** `{ conversationId? }` (acha a mensagem antiga, no arquivo)\n\n**Resposta:** `Message` com `aiText` — transcreve a voz ou o áudio (botão Transcrever) com o modelo de transcrição de áudio do Admin (e a reserva) e grava na mensagem; quem está com a conversa aberta recebe por `message.update`. Já transcrita: devolve sem chamar a IA. `(sem fala)` quando não há fala. Quem vê a conversa. `409`: `not_audio`, `no_media`, `media_missing`, `media_pending`, `too_large` (mais de 25 MB), `infected`, `transcribe_off` (sem modelo de transcrição de áudio ou com a IA desligada), `ai_limit`; `502 transcribe_failed`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "conversationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "description": "(acha a mensagem antiga, no arquivo)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Message` com `aiText` — transcreve a voz ou o áudio (botão Transcrever) com o modelo de transcrição de áudio do Admin (e a reserva) e grava na mensagem; quem está com a conversa aberta recebe por `message.update`. Já transcrita: devolve sem chamar a IA. `(sem fala)` quando não há fala. Quem vê a conversa. `409`: `not_audio`, `no_media`, `media_missing`, `media_pending`, `too_large` (mais de 25 MB), `infected`, `transcribe_off` (sem modelo de transcrição de áudio ou com a IA desligada), `ai_limit`; `502 transcribe_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "502": {
            "description": "`transcribe_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/messages/6750a1c2e4b0a1b2c3d4e5f1/transcribe\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/messages/{id}/media/retry": {
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Baixar o arquivo da mensagem de novo",
        "operationId": "postMessagesByIdMediaRetry",
        "description": "**Resposta:** `Message` com `media.retry.at` — pede ao Conector que peça de novo ao celular de quem mandou o arquivo que não chegou (`media.missing`); o resultado chega por `message.update` (`media` com o arquivo, ou `media.retry.error`). Pedido há menos de 2 minutos: devolve a mensagem sem pedir de novo. `409`: `no_media`, `too_large`, `no_wa_id`, `no_number`, `official`, `no_conector`, `conector_offline`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Message` com `media.retry.at` — pede ao Conector que peça de novo ao celular de quem mandou o arquivo que não chegou (`media.missing`); o resultado chega por `message.update` (`media` com o arquivo, ou `media.retry.error`). Pedido há menos de 2 minutos: devolve a mensagem sem pedir de novo. `409`: `no_media`, `too_large`, `no_wa_id`, `no_number`, `official`, `no_conector`, `conector_offline`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/messages/6750a1c2e4b0a1b2c3d4e5f1/media/retry\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conversations/{id}/notes": {
      "get": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Listar notas da conversa",
        "operationId": "getConversationsByIdNotes",
        "description": "**Resposta:** `{ data: [Note] }`, a mais nova primeiro",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [Note] }`, a mais nova primeiro",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Note"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/notes\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Criar nota na conversa",
        "operationId": "postConversationsByIdNotes",
        "description": "**Corpo:** `{ text }` (até 2.000 letras)\n\n**Resposta:** `201 Note`; `422` sem texto ou longo demais; `409 notes_full` com 200 anotações na conversa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  }
                },
                "required": [
                  "text"
                ],
                "description": "(até 2.000 letras)"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Note`; `422` sem texto ou longo demais; `409 notes_full` com 200 anotações na conversa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Note"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`notes_full`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/notes\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\"}'"
          }
        ]
      }
    },
    "/api/v1/conversations/{id}/notes/summary": {
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Resumir as notas da conversa",
        "operationId": "postConversationsByIdNotesSummary",
        "description": "**Resposta:** `201 Note` (`kind: \"summary\"`, o resumo em `summary`, quem pediu em `author`) — a IA resume as mensagens mais novas da conversa (agentes-ia.md). Espera o modelo (até 1 min). `409 ai_off`, `ai_limit`, `ai_failed`, `nothing_to_summarize` ou `notes_full`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "`201 Note` (`kind: \"summary\"`, o resumo em `summary`, quem pediu em `author`) — a IA resume as mensagens mais novas da conversa (agentes-ia.md). Espera o modelo (até 1 min). `409 ai_off`, `ai_limit`, `ai_failed`, `nothing_to_summarize` ou `notes_full`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Note"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`ai_off`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/notes/summary\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conversations/{id}/notes/{noteId}": {
      "patch": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Alterar nota da conversa",
        "operationId": "patchConversationsByIdNotesByNoteId",
        "description": "**Corpo:** `{ text }`\n\n**Resposta:** `Note` com `editedAt`; só quem escreveu (`403`), só anotação `text`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "noteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Note` com `editedAt`; só quem escreveu (`403`), só anotação `text`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Note"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/notes/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\"}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Apagar nota da conversa",
        "operationId": "deleteConversationsByIdNotesByNoteId",
        "description": "**Resposta:** `204`; quem escreveu (ou pediu o resumo) apaga as suas, o administrador apaga qualquer uma (inclusive a da ligação)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "noteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; quem escreveu (ou pediu o resumo) apaga as suas, o administrador apaga qualquer uma (inclusive a da ligação)"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/notes/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/conversations/{id}/call-permission": {
      "post": {
        "tags": [
          "Conversas e mensagens"
        ],
        "summary": "Pedir permissão para ligar ao contato",
        "operationId": "postConversationsByIdCallPermission",
        "description": "**Resposta:** `201 Message` — número oficial: manda o pedido de permissão para ligar. `409 not_official`, `calling_off`, `window_closed`, `permission_limit` (1 por dia e 2 por semana); `403 not_owner` se a conversa não está com a pessoa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "`201 Message` — número oficial: manda o pedido de permissão para ligar. `409 not_official`, `calling_off`, `window_closed`, `permission_limit` (1 por dia e 2 por semana); `403 not_owner` se a conversa não está com a pessoa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`not_owner`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_official`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/conversations/6750a1c2e4b0a1b2c3d4e5f1/call-permission\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/media/limits": {
      "get": {
        "tags": [
          "Arquivos"
        ],
        "summary": "Ver os limites de arquivos",
        "operationId": "getMediaLimits",
        "description": "**Resposta:** `{ data: [{ kind, mimes: [...], maxBytes, note }] }` — a tabela de midia.md",
        "responses": {
          "200": {
            "description": "`{ data: [{ kind, mimes: [...], maxBytes, note }] }` — a tabela de midia.md",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "mimes": {
                            "type": "array",
                            "items": {
                              "description": "..."
                            }
                          },
                          "maxBytes": {},
                          "note": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "kind",
                          "mimes",
                          "maxBytes",
                          "note"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/media/limits\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/files": {
      "post": {
        "tags": [
          "Arquivos"
        ],
        "summary": "Enviar arquivo",
        "operationId": "postFiles",
        "description": "**Corpo:** multipart: `file`; opcionais `kind`, `thumb` (jpeg), `width`, `height`, `seconds`, `waveform` (JSON)\n\n**Resposta:** `201 File` — confere tipo e tamanho; `voice` em webm vira ogg/opus; passa no antivírus antes de guardar: com vírus, `422 infected` (`details.virus`) e nada fica guardado",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "description": "multipart: `file`; opcionais `kind`, `thumb` (jpeg), `width`, `height`, `seconds`, `waveform` (JSON)"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 File` — confere tipo e tamanho; `voice` em webm vira ogg/opus; passa no antivírus antes de guardar: com vírus, `422 infected` (`details.virus`) e nada fica guardado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/File"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`infected`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/files\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -F \"file=@arquivo.pdf\""
          }
        ]
      }
    },
    "/api/v1/files/{id}/url": {
      "get": {
        "tags": [
          "Arquivos"
        ],
        "summary": "Pegar o endereço do arquivo",
        "operationId": "getFilesByIdUrl",
        "description": "**Resposta:** `{ url }` (1 hora); `409 infected` se o antivírus achou vírus (nele ou noutra cópia do mesmo conteúdo); `409 scanning` se ainda está na fila do antivírus",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ url }` (1 hora); `409 infected` se o antivírus achou vírus (nele ou noutra cópia do mesmo conteúdo); `409 scanning` se ainda está na fila do antivírus",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "example": "https://exemplo.com.br"
                    }
                  },
                  "required": [
                    "url"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`infected`, `scanning`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/files/6750a1c2e4b0a1b2c3d4e5f1/url\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/operations": {
      "get": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Listar operações",
        "operationId": "getOperations",
        "description": "**Quem:** todos (com `allOperations`, todas; os outros, as que veem)\n\n**Resposta:** `{ data: [Operation] }`",
        "responses": {
          "200": {
            "description": "`{ data: [Operation] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Operation"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos (com `allOperations`, todas; os outros, as que veem)",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/operations\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Criar operação",
        "operationId": "postOperations",
        "description": "**Quem:** `operations`\n\n**Corpo:** `{ name, areaId, icon?, protocolPrefix?, cardLabel, cardPlural?, cardGender?, money, access?, areaRole?, people?, flowId?, hideInMenu?, surveyId?, ownNumbers, numberIds, stages: [...], returnToLastOwner? }` (`icon`: nome do ícone, só `a-z`, `0-9` e `-`; vazio usa o da área. `protocolPrefix`: até 6 letras ou números, em maiúsculas; vazio usa o padrão)\n\n**Resposta:** `201 Operation`; acima do limite de operações do plano: `409 plan_limit`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "areaId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "icon": {
                    "type": "string"
                  },
                  "protocolPrefix": {},
                  "cardLabel": {},
                  "cardPlural": {},
                  "cardGender": {},
                  "money": {},
                  "access": {},
                  "areaRole": {},
                  "people": {},
                  "flowId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "hideInMenu": {},
                  "surveyId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "ownNumbers": {},
                  "numberIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "stages": {
                    "type": "array",
                    "items": {
                      "description": "..."
                    }
                  },
                  "returnToLastOwner": {}
                },
                "required": [
                  "name",
                  "areaId",
                  "cardLabel",
                  "money",
                  "ownNumbers",
                  "numberIds",
                  "stages"
                ],
                "description": "(`icon`: nome do ícone, só `a-z`, `0-9` e `-`; vazio usa o da área. `protocolPrefix`: até 6 letras ou números, em maiúsculas; vazio usa o padrão)"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Operation`; acima do limite de operações do plano: `409 plan_limit`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Operation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`plan_limit`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`operations`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/operations\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"areaId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"icon\":\"texto\",\"flowId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"surveyId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"numberIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"stages\":[]}'"
          }
        ]
      }
    },
    "/api/v1/operations/flows": {
      "get": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Listar fluxos das operações",
        "operationId": "getOperationsFlows",
        "description": "**Quem:** `operations` ou gestor de uma operação\n\n**Resposta:** `{ data: [{ id, name, active }] }`: os fluxos para o \"Fluxo ao entrar\"",
        "responses": {
          "200": {
            "description": "`{ data: [{ id, name, active }] }`: os fluxos para o \"Fluxo ao entrar\"",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "active": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "active"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`operations` ou gestor de uma operação",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/operations/flows\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/operations/{id}": {
      "patch": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Alterar operação",
        "operationId": "patchOperationsById",
        "description": "**Quem:** `operations`, ou gestor da operação\n\n**Corpo:** campos\n\n**Resposta:** `Operation`; tirar etapa com cartão dá `409 stage_in_use`. Mudar `access`, `areaRole`, `people` ou a área refaz quem participa. `ownNumbers: false` faz a operação seguir as conexões da área (`numberIds` não vale); `true`, ter as de `numberIds`; sem área, sempre as próprias. Tirar a conexão em que a operação é a principal dá `409 principal_lost`. O gestor sem a permissão não muda `areaId`, `ownNumbers` nem `numberIds` (`403`); quem não é gestor nem tem a permissão, `403`; operação que a pessoa não vê, `404`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "campos"
              }
            }
          },
          "description": "campos"
        },
        "responses": {
          "200": {
            "description": "`Operation`; tirar etapa com cartão dá `409 stage_in_use`. Mudar `access`, `areaRole`, `people` ou a área refaz quem participa. `ownNumbers: false` faz a operação seguir as conexões da área (`numberIds` não vale); `true`, ter as de `numberIds`; sem área, sempre as próprias. Tirar a conexão em que a operação é a principal dá `409 principal_lost`. O gestor sem a permissão não muda `areaId`, `ownNumbers` nem `numberIds` (`403`); quem não é gestor nem tem a permissão, `403`; operação que a pessoa não vê, `404`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Operation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`stage_in_use`, `principal_lost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`operations`, ou gestor da operação",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/operations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Apagar operação",
        "operationId": "deleteOperationsById",
        "description": "**Quem:** `operations`\n\n**Resposta:** `204`; `409 operation_in_use` se tem cartão aberto; as conversas dela voltam para a fila do número, sem etiquetas; sai das operações das pessoas",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; `409 operation_in_use` se tem cartão aberto; as conversas dela voltam para a fila do número, sem etiquetas; sai das operações das pessoas"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`operation_in_use`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`operations`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/operations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/operations/{id}/tags/usage": {
      "get": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Ver o uso das etiquetas da operação",
        "operationId": "getOperationsByIdTagsUsage",
        "description": "**Quem:** `operations`\n\n**Resposta:** `{ data: { \"<nome>\": n } }`: quantos cartões abertos têm cada etiqueta da operação",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: { \"<nome>\": n } }`: quantos cartões abertos têm cada etiqueta da operação",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "<nome>": {
                          "description": "n"
                        }
                      },
                      "required": [
                        "<nome>"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`operations`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/operations/6750a1c2e4b0a1b2c3d4e5f1/tags/usage\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/operations/{id}/cards": {
      "get": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Listar cartões da operação",
        "operationId": "getOperationsByIdCards",
        "description": "**Quem:** quem vê a operação\n\n**Resposta:** `{ data: [Card] }`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "stageId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [Card] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Card"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê a operação",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/operations/6750a1c2e4b0a1b2c3d4e5f1/cards\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Criar cartão na operação",
        "operationId": "postOperationsByIdCards",
        "description": "**Quem:** quem atende a operação\n\n**Corpo:** `{ title, stageId, contactId?, conversationId?, valueCents?, ownerId?, note?, dueAt?, tags? }`\n\n**Resposta:** `201 Card` (criar numa etapa não manda a mensagem dela)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "stageId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "contactId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "conversationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "valueCents": {
                    "type": "integer"
                  },
                  "ownerId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "note": {
                    "type": "string"
                  },
                  "dueAt": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  },
                  "tags": {}
                },
                "required": [
                  "title",
                  "stageId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Card` (criar numa etapa não manda a mensagem dela)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Card"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem atende a operação",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/operations/6750a1c2e4b0a1b2c3d4e5f1/cards\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Pedido 48211\",\"stageId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"contactId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"valueCents\":0,\"ownerId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"note\":\"texto\",\"dueAt\":\"2026-12-01T12:12:00Z\"}'"
          }
        ]
      }
    },
    "/api/v1/cards/{id}": {
      "patch": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Alterar cartão",
        "operationId": "patchCardsById",
        "description": "**Quem:** quem atende a operação\n\n**Corpo:** campos, `closed` e `sendStageMessage` (mudar `stageId` move; etapa com `message` manda a mensagem pela conversa do cartão, veja acima)\n\n**Resposta:** `Card`, com `stageMessage` quando a etapa nova tem mensagem",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "campos, `closed` e `sendStageMessage` (mudar `stageId` move; etapa com `message` manda a mensagem pela conversa do cartão, veja acima)"
              }
            }
          },
          "description": "campos, `closed` e `sendStageMessage` (mudar `stageId` move; etapa com `message` manda a mensagem pela conversa do cartão, veja acima)"
        },
        "responses": {
          "200": {
            "description": "`Card`, com `stageMessage` quando a etapa nova tem mensagem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Card"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem atende a operação",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/cards/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Operações e cartões"
        ],
        "summary": "Apagar cartão",
        "operationId": "deleteCardsById",
        "description": "**Quem:** quem atende a operação\n\n**Resposta:** `204`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem atende a operação",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/cards/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar meus canais",
        "operationId": "getChatChannels",
        "description": "**Resposta:** `{ data: [ChatChannel] }`\n\n**Regra:** os de que participa, pela última mensagem; põe no `#geral` quem falta e cria os canais das operações que faltam",
        "responses": {
          "200": {
            "description": "`{ data: [ChatChannel] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatChannel"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/channels\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Criar canal",
        "operationId": "postChatChannels",
        "description": "**Corpo:** `{ kind: \"open\"|\"closed\", name, topic?, memberIds?, mode?, readOnly?, listed? }`\n\n**Resposta:** `201 ChatChannel`\n\n**Regra:** nome `a-z0-9-` (2 a 40); `409 name_taken` se já existe; `mode`: `\"\"` ou `\"questions\"`; `readOnly`: canal de avisos; `listed` só no fechado",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "open",
                      "closed"
                    ],
                    "example": "open"
                  },
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "topic": {},
                  "memberIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "mode": {},
                  "readOnly": {},
                  "listed": {}
                },
                "required": [
                  "kind",
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"kind\":\"open\",\"name\":\"Ana Prado\",\"memberIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}'"
          }
        ]
      }
    },
    "/api/v1/chat/channels/browse": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Procurar canais",
        "operationId": "getChatChannelsBrowse",
        "description": "**Resposta:** `{ data: [ChatChannel] }`\n\n**Regra:** canais abertos (com os arquivados) e os fechados com `listed` (não arquivados), com `requested` para quem já pediu para entrar",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [ChatChannel] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatChannel"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/channels/browse\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/direct": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Abrir conversa direta",
        "operationId": "postChatDirect",
        "description": "**Corpo:** `{ memberIds }`\n\n**Resposta:** `ChatChannel`\n\n**Regra:** até 8 pessoas contando quem cria; devolve a direta que já existe com as mesmas pessoas",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "memberIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  }
                },
                "required": [
                  "memberIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/direct\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"memberIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}'"
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ver um canal",
        "operationId": "getChatChannelsById",
        "description": "**Resposta:** `ChatChannel`\n\n**Regra:** aberto: todos; fechado e direta: só quem está nele (`404` para os outros)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Alterar canal",
        "operationId": "patchChatChannelsById",
        "description": "**Corpo:** `{ name?, topic?, mode?, admins?, subjects?, readOnly?, listed?, welcome? }`\n\n**Resposta:** `ChatChannel`\n\n**Regra:** quem está no canal muda a descrição; nome, `mode`, `admins` (ids de quem está no canal, até 10), `subjects` (assuntos do canal de perguntas: até 20, de até 30 letras; `[]` tira), `readOnly` (canal de avisos) e `listed` (só fechado), quem cuida; `welcome` (quem entra na empresa já entra no canal), só administrador e não na direta; `#geral` e canal de operação não mudam de nome. Mudar modo, quem cuida, avisos e Procurar canais deixa registro no canal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "topic": {},
                  "mode": {},
                  "admins": {},
                  "subjects": {},
                  "readOnly": {},
                  "listed": {},
                  "welcome": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\"}'"
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/prefs": {
      "patch": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Alterar minhas preferências do canal",
        "operationId": "patchChatChannelsByIdPrefs",
        "description": "**Corpo:** `{ favorite?, muted?, notify?, ignoreAll?, group? }`\n\n**Resposta:** `ChatChannel`\n\n**Regra:** só quem está no canal (`409 not_member`); `group` existe em `ChatPrefs.groups` ou `\"\"`; avisa as outras abas (`chat.member`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "favorite": {},
                  "muted": {},
                  "notify": {},
                  "ignoreAll": {},
                  "group": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/prefs\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/join": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Entrar no canal",
        "operationId": "postChatChannelsByIdJoin",
        "description": "**Resposta:** `ChatChannel`\n\n**Regra:** só canal aberto e não arquivado",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/join\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/leave": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Sair do canal",
        "operationId": "postChatChannelsByIdLeave",
        "description": "**Resposta:** `204`\n\n**Regra:** não sai do `#geral`, do canal da operação de que participa nem da direta a dois",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/leave\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/members": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Adicionar pessoas ao canal",
        "operationId": "postChatChannelsByIdMembers",
        "description": "**Corpo:** `{ memberIds }`\n\n**Resposta:** `ChatChannel`\n\n**Regra:** quem está no canal chama; não vale na direta",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "memberIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  }
                },
                "required": [
                  "memberIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/members\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"memberIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}'"
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/members/{accountId}": {
      "delete": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Tirar pessoa do canal",
        "operationId": "deleteChatChannelsByIdMembersByAccountId",
        "description": "**Resposta:** `ChatChannel`\n\n**Regra:** quem cuida",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/members/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/archive": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Arquivar ou desarquivar o canal",
        "operationId": "postChatChannelsByIdArchive",
        "description": "**Resposta:** `ChatChannel`\n\n**Regra:** quem cuida; direta, `#geral` e canal de operação não arquivam",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/archive\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/unarchive": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Arquivar ou desarquivar o canal",
        "operationId": "postChatChannelsByIdUnarchive",
        "description": "**Resposta:** `ChatChannel`\n\n**Regra:** quem cuida; direta, `#geral` e canal de operação não arquivam",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/unarchive\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/close": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Fechar o canal",
        "operationId": "postChatChannelsByIdClose",
        "description": "**Resposta:** `ChatChannel`\n\n**Regra:** aberto vira fechado; quem cuida; não o `#geral` nem canal de operação (`409 fixed`). Quem não participa recebe `chat.channel.gone`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/close\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/open": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Abrir o canal",
        "operationId": "postChatChannelsByIdOpen",
        "description": "**Resposta:** `ChatChannel`\n\n**Regra:** fechado vira aberto (sai de `listed`; os pedidos para entrar continuam); quem cuida; não arquivado nem a direta (`409 direct`). Registro \"tornou o canal aberto.\" e `chat.channel` para a empresa toda",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/open\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/convert": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Transformar a conversa direta em canal",
        "operationId": "postChatChannelsByIdConvert",
        "description": "**Corpo:** `{ name, topic? }`\n\n**Resposta:** `ChatChannel`\n\n**Regra:** direta com 3 pessoas ou mais vira canal fechado com o histórico; quem pede vira quem criou (`409 direct_pair` a dois, `409 name_taken`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "topic": {}
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/convert\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\"}'"
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/bookmarks": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Criar atalho no canal",
        "operationId": "postChatChannelsByIdBookmarks",
        "description": "**Corpo:** `{ title, emoji?, url?, fileId? }`\n\n**Resposta:** `201 ChatChannel`\n\n**Regra:** um dos dois: `url` http/https ou arquivo da própria pessoa (`POST /files`); título 1 a 60; até 20 (`409 too_many`); quem está no canal e pode escrever",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "emoji": {},
                  "url": {
                    "type": "string",
                    "example": "https://exemplo.com.br"
                  },
                  "fileId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "title"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/bookmarks\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Pedido 48211\",\"url\":\"https://exemplo.com.br\",\"fileId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/bookmarks/{bid}": {
      "patch": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Alterar atalho do canal",
        "operationId": "patchChatChannelsByIdBookmarksByBid",
        "description": "**Corpo:** `{ title?, emoji?, url? }`\n\n**Resposta:** `ChatChannel`\n\n**Regra:** quem pôs ou quem cuida",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "bid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "emoji": {},
                  "url": {
                    "type": "string",
                    "example": "https://exemplo.com.br"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/bookmarks/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Pedido 48211\",\"url\":\"https://exemplo.com.br\"}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Apagar atalho do canal",
        "operationId": "deleteChatChannelsByIdBookmarksByBid",
        "description": "**Resposta:** `ChatChannel`\n\n**Regra:** quem pôs ou quem cuida",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "bid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/bookmarks/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/read": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Marcar o canal como lido",
        "operationId": "postChatChannelsByIdRead",
        "description": "**Resposta:** `204`\n\n**Regra:** zera as não lidas e as menções do canal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/read\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/posts": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar mensagens do canal",
        "operationId": "getChatChannelsByIdPosts",
        "description": "**Resposta:** `{ data: [ChatPost], nextCursor }`\n\n**Regra:** as do canal (sem as respostas das conversas), da mais antiga para a mais nova; 50 por vez. No canal de perguntas, `filter`: `pending` (não resolvidas), `unanswered` (sem resposta e não resolvida), `open` (com resposta e não resolvida), `solved`; `subject` (pode repetir: `subject=A&subject=B`): só as perguntas com qualquer um desses assuntos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subject",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [ChatPost], nextCursor }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPost"
                      }
                    },
                    "nextCursor": {}
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/posts\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Mandar mensagem no canal",
        "operationId": "postChatChannelsByIdPosts",
        "description": "**Corpo:** `{ text?, rootId?, also?, fileIds?, conversationId?, mentionIds?, priority?, ack?, poll? }`\n\n**Resposta:** `201 ChatPost` (com `notInChannel`)\n\n**Regra:** só quem está no canal e não arquivado (`409 not_member`, `409 archived`); até 8000 caracteres e 10 arquivos (de `POST /files`, da própria pessoa). `priority` (`urgent` liga `ack`), `ack` e `poll: { question?, options, multi?, anonymous?, blind?, closeAt?, open?, dates? }` só sem `rootId`; enquete de 2 a 10 opções (1 a 80 letras, sem repetir), `closeAt` de 1 minuto a 1 ano; `open`: qualquer pessoa do canal põe opção; `dates` (um dia e hora por opção, na ordem de `options`) faz a enquete de datas (sempre de várias escolhas, com os nomes). Também sem `rootId`, um só entre `poll`, `event: { title, start, end?, place? }` (título até 120 letras, de agora a 1 ano, fim até 7 dias depois), `form: { title, fields: [{ kind, label, options?, required? }], closeAt? }` (até 20 perguntas; `choice` com 2 a 10 opções) e `kudosTo` (elogio: id de outra pessoa do canal, texto é o motivo; não na direta). `subjects`: assuntos da pergunta, dos do canal (só sem `rootId`, no canal de perguntas). Canal de avisos: a mensagem nova (fora da conversa) é só de quem cuida (`403 read_only`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "rootId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "also": {},
                  "fileIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "conversationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "mentionIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "priority": {},
                  "ack": {},
                  "poll": {}
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 ChatPost` (com `notInChannel`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/posts\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\",\"rootId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"fileIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"mentionIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}'"
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/questions/counts": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Contar perguntas do canal",
        "operationId": "getChatChannelsByIdQuestionsCounts",
        "description": "**Resposta:** `{ pending, unanswered, open, solved }`\n\n**Regra:** quantas perguntas em cada situação; `subject` como na lista. Só no canal de perguntas (`409 not_questions`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "subject",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ pending, unanswered, open, solved }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pending": {},
                    "unanswered": {},
                    "open": {},
                    "solved": {}
                  },
                  "required": [
                    "pending",
                    "unanswered",
                    "open",
                    "solved"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/questions/counts\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/pinned": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar mensagens fixadas do canal",
        "operationId": "getChatChannelsByIdPinned",
        "description": "**Resposta:** `{ data: [ChatPost] }`\n\n**Regra:** a fixada por último primeiro (`pinnedAt`), até 100",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [ChatPost] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPost"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/pinned\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ver uma mensagem do chat",
        "operationId": "getChatPostsById",
        "description": "**Resposta:** `ChatPost` (com `channel`)\n\n**Regra:** quem vê o canal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatPost` (com `channel`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Editar mensagem do chat",
        "operationId": "patchChatPostsById",
        "description": "**Corpo:** `{ text }` (até 8.000 letras)\n\n**Resposta:** `ChatPost`; texto igual ao atual não muda nada (não ganha \"editada\"); `409 post_deleted` na mensagem apagada\n\n**Regra:** só quem escreveu; a versão anterior vai para o histórico (até 20); link novo refaz a prévia",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  }
                },
                "required": [
                  "text"
                ],
                "description": "(até 8.000 letras)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`; texto igual ao atual não muda nada (não ganha \"editada\"); `409 post_deleted` na mensagem apagada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`post_deleted`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\"}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Apagar mensagem do chat",
        "operationId": "deleteChatPostsById",
        "description": "**Resposta:** `ChatPost` apagado\n\n**Regra:** quem escreveu ou admin; a resposta marcada como a que resolveu desmarca a pergunta",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatPost` apagado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/thread": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ver a conversa da mensagem",
        "operationId": "getChatPostsByIdThread",
        "description": "**Resposta:** `{ data: [ChatPost] }`\n\n**Regra:** a primeira da conversa e as respostas; pedida pela resposta, devolve a conversa dela",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [ChatPost] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPost"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/thread\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/thread/read": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Marcar a conversa como lida",
        "operationId": "postChatPostsByIdThreadRead",
        "description": "**Resposta:** `204`\n\n**Regra:** tira a bolinha de resposta nova",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/thread/read\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/thread/follow": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Seguir ou deixar de seguir a conversa",
        "operationId": "postChatPostsByIdThreadFollow",
        "description": "**Corpo:** `{ following }`\n\n**Resposta:** `ChatPost`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "following": {}
                },
                "required": [
                  "following"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/thread/follow\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/reactions": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Reagir à mensagem",
        "operationId": "postChatPostsByIdReactions",
        "description": "**Corpo:** `{ emoji }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** põe ou tira a reação de quem pediu",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "emoji": {}
                },
                "required": [
                  "emoji"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/reactions\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/pin": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Fixar ou desafixar a mensagem",
        "operationId": "postChatPostsByIdPin",
        "description": "**Corpo:** `{ pinned }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** quem está no canal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pinned": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "pinned"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/pin\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"pinned\":true}'"
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/save": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Salvar ou tirar dos salvos a mensagem",
        "operationId": "postChatPostsByIdSave",
        "description": "**Corpo:** `{ saved }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** só para quem salvou",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "saved": {}
                },
                "required": [
                  "saved"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/save\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/ack": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Confirmar a leitura da mensagem",
        "operationId": "postChatPostsByIdAck",
        "description": "**Corpo:** `{ ack }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** confirma a leitura da mensagem que pede; desfazer só até 5 minutos depois (`409 ack_locked`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ack": {}
                },
                "required": [
                  "ack"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/ack\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/poll/vote": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Votar na enquete",
        "operationId": "postChatPostsByIdPollVote",
        "description": "**Corpo:** `{ options: [id] }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** troca os votos de quem pede (vazio tira); sem `multi`, uma só; fechada: `409 poll_closed`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "options": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "options"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/poll/vote\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"options\":[\"texto\"]}'"
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/poll/close": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Fechar ou reabrir a enquete",
        "operationId": "postChatPostsByIdPollClose",
        "description": "**Corpo:** `{ closed }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** fecha ou reabre (reabrir tira `closeAt` que já passou); quem fez a enquete ou quem cuida",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "closed": {}
                },
                "required": [
                  "closed"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/poll/close\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/forward": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Encaminhar a mensagem",
        "operationId": "postChatPostsByIdForward",
        "description": "**Corpo:** `{ channelId?, memberIds?, comment? }`\n\n**Resposta:** `201 ChatPost` (no destino)\n\n**Regra:** um dos dois (`memberIds` abre ou reaproveita a direta); copia texto e arquivos em `forward`; o comentário é o `text`; quem pede vê a original e pode escrever no destino",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channelId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "memberIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "comment": {}
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 ChatPost` (no destino)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/forward\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"channelId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"memberIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}'"
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/history": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ver as versões da mensagem",
        "operationId": "getChatPostsByIdHistory",
        "description": "**Resposta:** `{ data: [ChatEdit] }`\n\n**Regra:** só quem escreveu; `{ text, at, current? }` da atual para a mais velha",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [ChatEdit] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatEdit"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/history\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/preview": {
      "delete": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Tirar a prévia do link",
        "operationId": "deleteChatPostsByIdPreview",
        "description": "**Resposta:** `ChatPost`\n\n**Regra:** quem escreveu tira a prévia do link (não volta)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/preview\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/files/{file}/transcribe": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Transcrever o áudio do arquivo",
        "operationId": "postChatPostsByIdFilesByFileTranscribe",
        "description": "**Resposta:** `ChatPost` com `files[].aiText`\n\n**Regra:** quem vê o canal; transcreve a voz ou o áudio do arquivo (botão Transcrever), como em `POST /messages/{id}/transcribe`, e avisa o canal por `chat.post.update`. Já transcrito: devolve sem chamar a IA. `404` arquivo fora do post; `409`: `not_audio`, `too_large`, `infected`, `transcribe_off`, `ai_limit`; `502 transcribe_failed`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "file",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatPost` com `files[].aiText`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/files/<file>/transcribe\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/unread": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Marcar a mensagem como não lida",
        "operationId": "postChatPostsByIdUnread",
        "description": "**Resposta:** `ChatChannel`\n\n**Regra:** marca como não lida a partir da mensagem (lido até 1 ms antes; não lidas e menções contadas de novo); resposta de conversa marca a conversa; avisa as outras abas (`chat.unread`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/unread\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/remind": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Criar lembrete da mensagem",
        "operationId": "postChatPostsByIdRemind",
        "description": "**Corpo:** `{ at }`\n\n**Resposta:** `204`\n\n**Regra:** de agora a 1 ano; na hora, item `reminder` na Atividade; até 200 marcados",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "at": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  }
                },
                "required": [
                  "at"
                ]
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "`204`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/remind\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"at\":\"2026-12-01T12:12:00Z\"}'"
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/solve": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Marcar a pergunta como resolvida",
        "operationId": "postChatPostsByIdSolve",
        "description": "**Corpo:** `{ answerId?: id | null, solved?: bool }`\n\n**Resposta:** `ChatPost` (a pergunta)\n\n**Regra:** canal de perguntas, na primeira mensagem da conversa; quem perguntou ou quem cuida; arquivado não muda. Com `answerId`, a resposta (da conversa) resolve a pergunta e quem respondeu é avisado (Atividade `solved`); sem `answerId`, `solved: true` resolve sem resposta e `false` (ou `answerId: null`) reabre",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "answerId": {
                    "type": "string",
                    "nullable": true,
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "solved": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost` (a pergunta)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/solve\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"answerId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"solved\":true}'"
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/vote": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Votar na resposta da pergunta",
        "operationId": "postChatPostsByIdVote",
        "description": "**Corpo:** `{ vote: 1|0|-1 }`\n\n**Resposta:** `ChatPost` (com `myVote`)\n\n**Regra:** resposta de uma pergunta no canal de perguntas (`409 not_questions`, `409 not_answer`); não na própria resposta (`409 own_answer`); `0` tira o voto. A conversa mostra a resolvida primeiro e depois as mais votadas",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "vote": {
                    "oneOf": [
                      {
                        "type": "number",
                        "example": 1
                      },
                      {
                        "type": "number",
                        "example": 0
                      },
                      {
                        "type": "number",
                        "example": -1
                      }
                    ]
                  }
                },
                "required": [
                  "vote"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost` (com `myVote`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/vote\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"vote\":1}'"
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/subjects": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Trocar os assuntos da pergunta",
        "operationId": "postChatPostsByIdSubjects",
        "description": "**Corpo:** `{ subjects }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** troca a lista de assuntos da pergunta (`[]` tira todos); só os do canal, mais os que a pergunta já tinha; quem perguntou ou quem cuida (`409 not_question` fora da primeira da conversa)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subjects": {}
                },
                "required": [
                  "subjects"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/subjects\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/poll/options": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Adicionar opção na enquete",
        "operationId": "postChatPostsByIdPollOptions",
        "description": "**Corpo:** `{ text, at? }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** põe uma opção na enquete aberta a opções (`open`; senão `409 poll_not_open`); até 10 (`409 poll_full`), sem repetir; na de datas, `at` de hoje a 1 ano",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "at": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/poll/options\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\",\"at\":\"2026-12-01T12:12:00Z\"}'"
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/poll/options/{optionId}": {
      "delete": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Tirar opção da enquete",
        "operationId": "deleteChatPostsByIdPollOptionsByOptionId",
        "description": "**Resposta:** `ChatPost`\n\n**Regra:** tira a opção que a pessoa pôs (ou quem fez a enquete e quem cuida); as de quem fez ficam (`409 poll_original`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "optionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/poll/options/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/rsvp": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Responder se vai ao evento",
        "operationId": "postChatPostsByIdRsvp",
        "description": "**Corpo:** `{ answer: \"yes\"|\"maybe\"|\"no\"|\"\" }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** responde o evento (`\"\"` tira); `409 event_canceled`, `409 no_event`. Na véspera, quem vai ou talvez vá recebe o lembrete na Atividade (`event`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "answer": {
                    "type": "string",
                    "enum": [
                      "yes",
                      "maybe",
                      "no",
                      ""
                    ],
                    "example": "yes"
                  }
                },
                "required": [
                  "answer"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/rsvp\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"answer\":\"yes\"}'"
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/event/cancel": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Cancelar ou reativar o evento",
        "operationId": "postChatPostsByIdEventCancel",
        "description": "**Corpo:** `{ canceled }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** quem fez o evento ou quem cuida; cancelar avisa quem disse que vai ou talvez vá",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "canceled": {}
                },
                "required": [
                  "canceled"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/event/cancel\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/form/answer": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ver minha resposta do formulário",
        "operationId": "getChatPostsByIdFormAnswer",
        "description": "**Resposta:** `{ answer: ChatFormAnswer | null }`\n\n**Regra:** a resposta de quem pede",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ answer: ChatFormAnswer | null }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "answer": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ChatFormAnswer"
                        }
                      ],
                      "type": "object",
                      "nullable": true
                    }
                  },
                  "required": [
                    "answer"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/form/answer\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Responder o formulário",
        "operationId": "postChatPostsByIdFormAnswer",
        "description": "**Corpo:** `{ values: [{ field, text?, fileId? }] }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** responde ou troca a resposta enquanto aberto (`409 form_closed`); obrigatórias, tipo de cada campo (data `AAAA-MM-DD`, nota 1 a 5, `sim`/`nao`, opção da lista, foto de `POST /files` da própria pessoa)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "values": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "field": {},
                        "text": {
                          "type": "string",
                          "example": "Bom dia, o pedido já saiu?"
                        },
                        "fileId": {
                          "type": "string",
                          "example": "6750a1c2e4b0a1b2c3d4e5f1"
                        }
                      },
                      "required": [
                        "field"
                      ]
                    }
                  }
                },
                "required": [
                  "values"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/form/answer\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"values\":[{\"text\":\"Bom dia, o pedido já saiu?\",\"fileId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}]}'"
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/form/answers": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ver as respostas do formulário",
        "operationId": "getChatPostsByIdFormAnswers",
        "description": "**Resposta:** `ChatFormResult` (`{ form, answers: [ChatFormAnswer], missing: [Ref] }`)\n\n**Regra:** quem fez o formulário ou quem cuida do canal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ChatFormResult` (`{ form, answers: [ChatFormAnswer], missing: [Ref] }`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatFormResult"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/form/answers\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/form/remind": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Lembrar quem não respondeu o formulário",
        "operationId": "postChatPostsByIdFormRemind",
        "description": "**Resposta:** `{ count }`\n\n**Regra:** quem fez ou quem cuida avisa na Atividade (`form`) quem do canal ainda não respondeu",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ count }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "count"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/form/remind\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/form/close": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Fechar ou reabrir o formulário",
        "operationId": "postChatPostsByIdFormClose",
        "description": "**Corpo:** `{ closed }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** fecha ou reabre; fecha sozinho no `closeAt`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "closed": {}
                },
                "required": [
                  "closed"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/form/close\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/posts/{id}/cards": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ligar um cartão à mensagem",
        "operationId": "postChatPostsByIdCards",
        "description": "**Corpo:** `{ cardId }`\n\n**Resposta:** `ChatPost`\n\n**Regra:** liga à mensagem o cartão criado por `POST /operations/{id}/cards` (de operação da pessoa); até 10 (`409 too_many_cards`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cardId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "cardId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/posts/6750a1c2e4b0a1b2c3d4e5f1/cards\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"cardId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/chat/acks": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar confirmações de leitura pendentes",
        "operationId": "getChatAcks",
        "description": "**Resposta:** `{ data: [ChatPost] }`\n\n**Regra:** mensagens dos canais da pessoa que pedem confirmação de leitura e ela não confirmou (últimos 30 dias, até 30, a mais nova primeiro); 30 minutos depois, quem falta recebe o lembrete na Atividade (`reminder`, uma vez)",
        "responses": {
          "200": {
            "description": "`{ data: [ChatPost] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPost"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/acks\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/files": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar arquivos do canal",
        "operationId": "getChatChannelsByIdFiles",
        "description": "**Resposta:** `{ data: [ChatPost], nextCursor }`\n\n**Regra:** mensagens com arquivo do canal e das conversas, a mais nova primeiro (aba Arquivos)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [ChatPost], nextCursor }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPost"
                      }
                    },
                    "nextCursor": {}
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/files\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/request": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Pedir ou desistir de entrar no canal",
        "operationId": "postChatChannelsByIdRequest",
        "description": "**Corpo:** `{ want }`\n\n**Resposta:** `ChatChannel` (com `requested`)\n\n**Regra:** pede (ou desiste de) entrar no canal fechado com `listed`; até 50 esperando (`409 too_many_requests`); `409 already_member`. Quem cuida recebe na Atividade (`request`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "want": {}
                },
                "required": [
                  "want"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatChannel` (com `requested`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/request\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/channels/{id}/requests/{accountId}": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Aprovar ou recusar pedido de entrada",
        "operationId": "postChatChannelsByIdRequestsByAccountId",
        "description": "**Corpo:** `{ approve }`\n\n**Resposta:** `ChatChannel`\n\n**Regra:** quem cuida aprova (a pessoa entra) ou recusa; quem pediu recebe a resposta na Atividade; `409 no_request` se já respondido",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "approve": {}
                },
                "required": [
                  "approve"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatChannel`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatChannel"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/channels/6750a1c2e4b0a1b2c3d4e5f1/requests/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/people/{id}/kudos": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ver os elogios da pessoa",
        "operationId": "getChatPeopleByIdKudos",
        "description": "**Resposta:** `{ count, last? }`\n\n**Regra:** elogios que a pessoa recebeu nos últimos 12 meses (cartão da pessoa)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ count, last? }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "last": {}
                  },
                  "required": [
                    "count"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/people/6750a1c2e4b0a1b2c3d4e5f1/kudos\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/threads": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar conversas que sigo",
        "operationId": "getChatThreads",
        "description": "**Resposta:** `{ data: [ChatPost] }`\n\n**Regra:** conversas que segue, pela resposta mais nova",
        "responses": {
          "200": {
            "description": "`{ data: [ChatPost] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPost"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/threads\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/mentions": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar minhas menções",
        "operationId": "getChatMentions",
        "description": "**Resposta:** `{ data: [ChatPost] }`\n\n**Regra:** mensagens que avisaram a pessoa (citação, `@canal`, `@aqui`, grupo, palavra própria, urgente)",
        "responses": {
          "200": {
            "description": "`{ data: [ChatPost] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPost"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/mentions\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/saved": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar mensagens salvas",
        "operationId": "getChatSaved",
        "description": "**Resposta:** `{ data: [ChatPost] }`",
        "responses": {
          "200": {
            "description": "`{ data: [ChatPost] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPost"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/saved\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/search": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Buscar mensagens no chat",
        "operationId": "getChatSearch",
        "description": "**Resposta:** `{ data: [ChatPost] }`\n\n**Regra:** até 50, nos canais que a pessoa vê; `old=1` procura também nas mensagens com mais de 90 dias que estão no arquivo frio; `q` aceita `de:ana`, `em:suporte`, `antes:`/`depois:`/`no:` (dd/mm ou dd/mm/aaaa), `\"frase exata\"` e `-palavra`; os parâmetros (`from` e `in` são ids; datas AAAA-MM-DD) mandam sobre o texto; texto vazio com filtro vale",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "in",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "on",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "old",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [ChatPost] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPost"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/search\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/search/files": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Buscar arquivos no chat",
        "operationId": "getChatSearchFiles",
        "description": "**Resposta:** `{ data: [{ file, post }] }`\n\n**Regra:** os mesmos filtros, pelo nome do arquivo (da mensagem e da encaminhada); até 50",
        "parameters": [
          {
            "name": "…",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [{ file, post }] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "file": {},
                          "post": {}
                        },
                        "required": [
                          "file",
                          "post"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/search/files\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/people": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar pessoas do chat",
        "operationId": "getChatPeople",
        "description": "**Resposta:** `{ data: [ChatPerson] }`\n\n**Regra:** a equipe ativa; `handle` é o apelido das menções (`Ana` ou `Ana.Souza`); expediente da pessoa ou o padrão da empresa",
        "responses": {
          "200": {
            "description": "`{ data: [ChatPerson] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatPerson"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/people\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/groups": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar grupos do chat interno",
        "operationId": "getChatGroups",
        "description": "**Resposta:** `{ data: [{ id, handle, name, memberIds }] }`\n\n**Regra:** um grupo por operação; `handle` é o nome como o do canal (com `-equipe` se bater com o apelido de uma pessoa)",
        "responses": {
          "200": {
            "description": "`{ data: [{ id, handle, name, memberIds }] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "handle": {
                            "type": "string",
                            "example": "boas-vindas"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "memberIds": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "6750a1c2e4b0a1b2c3d4e5f1"
                            }
                          }
                        },
                        "required": [
                          "id",
                          "handle",
                          "name",
                          "memberIds"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/groups\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/prefs": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ver preferências do chat interno",
        "operationId": "getChatPrefs",
        "description": "**Resposta:** `ChatPrefs`\n\n**Regra:** vazio: `{ groups: [], keywords: [], recentEmojis: [], skinTone: 0 }`",
        "responses": {
          "200": {
            "description": "`ChatPrefs`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPrefs"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/prefs\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Alterar preferências do chat interno",
        "operationId": "patchChatPrefs",
        "description": "**Corpo:** `{ groups?, keywords?, recentEmojis?, skinTone? }`\n\n**Resposta:** `ChatPrefs`\n\n**Regra:** até 20 grupos (nome 1 a 30), 20 palavras (2 a 30 letras), 24 emojis, tom 0 a 5; grupo tirado sai dos canais; avisa as outras abas (`chat.prefs`); `409 no_membership` no acesso de suporte",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "groups": {},
                  "keywords": {},
                  "recentEmojis": {},
                  "skinTone": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPrefs`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPrefs"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/chat/prefs\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/chat/status": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Mudar meu status no chat interno",
        "operationId": "postChatStatus",
        "description": "**Corpo:** `{ presence?: \"\"|\"away\"|\"dnd\"|\"offline\", dndUntil?, status?: { emoji?, text, until? } | null }`\n\n**Resposta:** `ChatPrefs`\n\n**Regra:** `\"\"` volta ao automático; datas de agora a 1 ano; texto até 100; avisa a pessoa (`chat.prefs`) e a empresa (`chat.presence`)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "presence": {
                    "type": "string",
                    "enum": [
                      "",
                      "away",
                      "dnd",
                      "offline"
                    ],
                    "example": ""
                  },
                  "dndUntil": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  },
                  "status": {
                    "type": "object",
                    "properties": {
                      "emoji": {},
                      "text": {
                        "type": "string",
                        "example": "Bom dia, o pedido já saiu?"
                      },
                      "until": {}
                    },
                    "required": [
                      "text"
                    ],
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatPrefs`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPrefs"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/status\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"presence\":\"\",\"dndUntil\":\"2026-12-01T12:12:00Z\",\"status\":{\"text\":\"Bom dia, o pedido já saiu?\"}}'"
          }
        ]
      }
    },
    "/api/v1/chat/drafts": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Listar rascunhos do chat interno",
        "operationId": "getChatDrafts",
        "description": "**Resposta:** `{ drafts: [ChatDraft], scheduled: [ChatDraft] }`\n\n**Regra:** rascunhos pelo mais recente, agendadas pela próxima",
        "responses": {
          "200": {
            "description": "`{ drafts: [ChatDraft], scheduled: [ChatDraft] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "drafts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatDraft"
                      }
                    },
                    "scheduled": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatDraft"
                      }
                    }
                  },
                  "required": [
                    "drafts",
                    "scheduled"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/drafts\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "put": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Salvar rascunho de mensagem",
        "operationId": "putChatDrafts",
        "description": "**Corpo:** `{ channelId, rootId?, text, fileIds? }`\n\n**Resposta:** `ChatDraft` ou `204`\n\n**Regra:** um por canal e conversa; texto e arquivos vazios apagam; avisa as abas (`chat.drafts`)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channelId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "rootId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "fileIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  }
                },
                "required": [
                  "channelId",
                  "text"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatDraft` ou `204`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatDraft"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/chat/drafts\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"channelId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"rootId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"text\":\"Bom dia, o pedido já saiu?\",\"fileIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}'"
          }
        ]
      }
    },
    "/api/v1/chat/drafts/{id}": {
      "delete": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Apagar rascunho",
        "operationId": "deleteChatDraftsById",
        "description": "**Resposta:** `204`\n\n**Regra:** rascunho ou agendada da pessoa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/chat/drafts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/scheduled": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Agendar mensagem no chat interno",
        "operationId": "postChatScheduled",
        "description": "**Corpo:** `{ channelId, rootId?, text, fileIds?, mentionIds?, also?, priority?, ack?, subjects?, sendAt }`\n\n**Resposta:** `201 ChatDraft`\n\n**Regra:** `sendAt` de 1 minuto a 1 ano; até 100; apaga o rascunho daquele canal ou conversa. `subjects` como em `POST .../posts`; ao sair, fica só com os que o canal ainda tem",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channelId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "rootId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "fileIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "mentionIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "also": {},
                  "priority": {},
                  "ack": {},
                  "subjects": {},
                  "sendAt": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  }
                },
                "required": [
                  "channelId",
                  "text",
                  "sendAt"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 ChatDraft`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatDraft"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/scheduled\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"channelId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"rootId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"text\":\"Bom dia, o pedido já saiu?\",\"fileIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"mentionIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"sendAt\":\"2026-12-01T12:12:00Z\"}'"
          }
        ]
      }
    },
    "/api/v1/chat/scheduled/{id}": {
      "patch": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Alterar mensagem agendada",
        "operationId": "patchChatScheduledById",
        "description": "**Corpo:** `{ sendAt?, text? }`\n\n**Resposta:** `ChatDraft`\n\n**Regra:** hora nova tira o erro; `409 sending` se já está saindo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sendAt": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  },
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`ChatDraft`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatDraft"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/chat/scheduled/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"sendAt\":\"2026-12-01T12:12:00Z\",\"text\":\"Bom dia, o pedido já saiu?\"}'"
          }
        ]
      }
    },
    "/api/v1/chat/scheduled/{id}/send": {
      "post": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Enviar mensagem agendada agora",
        "operationId": "postChatScheduledByIdSend",
        "description": "**Resposta:** `201 ChatPost`\n\n**Regra:** manda agora",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "`201 ChatPost`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatPost"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/chat/scheduled/6750a1c2e4b0a1b2c3d4e5f1/send\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/unread": {
      "get": {
        "tags": [
          "Chat interno"
        ],
        "summary": "Ver mensagens não lidas do chat interno",
        "operationId": "getChatUnread",
        "description": "**Resposta:** `{ total, mentions, direct, threads, channels: [{ id, unread, mentions }] }`\n\n**Regra:** `total` é o número do menu: menções nos canais + não lidas nas diretas + conversas com resposta nova; direta silenciada soma só as menções",
        "responses": {
          "200": {
            "description": "`{ total, mentions, direct, threads, channels: [{ id, unread, mentions }] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "mentions": {},
                    "direct": {},
                    "threads": {},
                    "channels": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "unread": {},
                          "mentions": {}
                        },
                        "required": [
                          "id",
                          "unread",
                          "mentions"
                        ]
                      }
                    }
                  },
                  "required": [
                    "total",
                    "mentions",
                    "direct",
                    "threads",
                    "channels"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/unread\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/tags": {
      "get": {
        "tags": [
          "Etiquetas e respostas rápidas"
        ],
        "summary": "Listar etiquetas",
        "operationId": "getTags",
        "description": "**Resposta:** `{ data: [{ id, name, color, usage? }] }`, as etiquetas gerais. `usage=1` (só com a permissão `tags`; sem ela, é ignorado) traz `usage: { contacts, organizations, flows, campaigns }`",
        "parameters": [
          {
            "name": "usage",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [{ id, name, color, usage? }] }`, as etiquetas gerais. `usage=1` (só com a permissão `tags`; sem ela, é ignorado) traz `usage: { contacts, organizations, flows, campaigns }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "color": {},
                          "usage": {}
                        },
                        "required": [
                          "id",
                          "name",
                          "color"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/tags\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Etiquetas e respostas rápidas"
        ],
        "summary": "Criar etiqueta",
        "operationId": "postTags",
        "description": "**Corpo:** `{ name }`\n\n**Resposta:** `201 Tag` (permissão `tags`). Nome de 1 a 30 letras (`422` em `name`); repetido, sem diferença de maiúsculas: `409 tag_exists`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Tag` (permissão `tags`). Nome de 1 a 30 letras (`422` em `name`); repetido, sem diferença de maiúsculas: `409 tag_exists`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tag"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`tag_exists`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/tags\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\"}'"
          }
        ]
      }
    },
    "/api/v1/tags/{id}": {
      "patch": {
        "tags": [
          "Etiquetas e respostas rápidas"
        ],
        "summary": "Renomear etiqueta",
        "operationId": "patchTagsById",
        "description": "**Corpo:** `{ name }`\n\n**Resposta:** `Tag` (`tags`). Mesmas regras do `POST`. Renomeia em contatos, empresas, público das campanhas e rascunho dos fluxos, numa transação; guarda o nome antigo para os fluxos publicados",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Tag` (`tags`). Mesmas regras do `POST`. Renomeia em contatos, empresas, público das campanhas e rascunho dos fluxos, numa transação; guarda o nome antigo para os fluxos publicados",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tag"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/tags/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\"}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Etiquetas e respostas rápidas"
        ],
        "summary": "Apagar etiqueta",
        "operationId": "deleteTagsById",
        "description": "**Resposta:** `204` (`tags`). Tira de contatos, empresas, público das campanhas e blocos Etiquetar dos rascunhos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204` (`tags`). Tira de contatos, empresas, público das campanhas e blocos Etiquetar dos rascunhos"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/tags/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/tags/{id}/merge": {
      "post": {
        "tags": [
          "Etiquetas e respostas rápidas"
        ],
        "summary": "Juntar etiqueta com outra",
        "operationId": "postTagsByIdMerge",
        "description": "**Corpo:** `{ intoId }`\n\n**Resposta:** `Tag` que ficou (`tags`). Passa tudo para `intoId` e apaga esta; `intoId` vazio ou igual: `422`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "intoId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "intoId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Tag` que ficou (`tags`). Passa tudo para `intoId` e apaga esta; `intoId` vazio ou igual: `422`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tag"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/tags/6750a1c2e4b0a1b2c3d4e5f1/merge\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"intoId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/quick-replies": {
      "get": {
        "tags": [
          "Etiquetas e respostas rápidas"
        ],
        "summary": "Listar respostas rápidas",
        "operationId": "getQuickReplies",
        "description": "**Resposta:** `{ data: [{ id, shortcut, text, fileId? }] }`",
        "responses": {
          "200": {
            "description": "`{ data: [{ id, shortcut, text, fileId? }] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "shortcut": {},
                          "text": {
                            "type": "string",
                            "example": "Bom dia, o pedido já saiu?"
                          },
                          "fileId": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          }
                        },
                        "required": [
                          "id",
                          "shortcut",
                          "text"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/quick-replies\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Etiquetas e respostas rápidas"
        ],
        "summary": "Criar resposta rápida",
        "operationId": "postQuickReplies",
        "description": "**Corpo:** `{ shortcut, text, fileId? }`\n\n**Resposta:** `201 QuickReply`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "shortcut": {},
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "fileId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "shortcut",
                  "text"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 QuickReply`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuickReply"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/quick-replies\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\",\"fileId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/quick-replies/{id}": {
      "patch": {
        "tags": [
          "Etiquetas e respostas rápidas"
        ],
        "summary": "Alterar resposta rápida",
        "operationId": "patchQuickRepliesById",
        "description": "**Corpo:** campos\n\n**Resposta:** `QuickReply`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "campos"
              }
            }
          },
          "description": "campos"
        },
        "responses": {
          "200": {
            "description": "`QuickReply`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuickReply"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/quick-replies/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Etiquetas e respostas rápidas"
        ],
        "summary": "Apagar resposta rápida",
        "operationId": "deleteQuickRepliesById",
        "description": "**Resposta:** `204`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/quick-replies/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/surveys": {
      "get": {
        "tags": [
          "Modelos de avaliação"
        ],
        "summary": "Listar modelos de avaliação",
        "operationId": "getSurveys",
        "description": "**Resposta:** `{ data: [Survey] }`, o Padrão primeiro e os outros pelo nome",
        "responses": {
          "200": {
            "description": "`{ data: [Survey] }`, o Padrão primeiro e os outros pelo nome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Survey"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/surveys\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Modelos de avaliação"
        ],
        "summary": "Criar modelo de avaliação",
        "operationId": "postSurveys",
        "description": "**Corpo:** `{ name, question, hours?, thanks?, askComment? }`\n\n**Resposta:** `201 Survey`. Nome de 1 a 40 letras e pergunta de 1 a 255 (`422` no campo); agradecimento até 500 (`\"\"` não manda nada); `hours` fora da lista, `422`. Nome repetido, sem diferença de maiúsculas nem de acentos: `409 survey_exists`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "question": {},
                  "hours": {
                    "type": "integer"
                  },
                  "thanks": {},
                  "askComment": {}
                },
                "required": [
                  "name",
                  "question"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Survey`. Nome de 1 a 40 letras e pergunta de 1 a 255 (`422` no campo); agradecimento até 500 (`\"\"` não manda nada); `hours` fora da lista, `422`. Nome repetido, sem diferença de maiúsculas nem de acentos: `409 survey_exists`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Survey"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`survey_exists`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/surveys\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"hours\":0}'"
          }
        ]
      }
    },
    "/api/v1/surveys/{id}": {
      "patch": {
        "tags": [
          "Modelos de avaliação"
        ],
        "summary": "Alterar modelo de avaliação",
        "operationId": "patchSurveysById",
        "description": "**Corpo:** campos\n\n**Resposta:** `Survey`. Mesmas regras do `POST`. A avaliação que já foi ao contato continua com o agradecimento e o comentário da época",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "campos"
              }
            }
          },
          "description": "campos"
        },
        "responses": {
          "200": {
            "description": "`Survey`. Mesmas regras do `POST`. A avaliação que já foi ao contato continua com o agradecimento e o comentário da época",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Survey"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/surveys/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Modelos de avaliação"
        ],
        "summary": "Apagar modelo de avaliação",
        "operationId": "deleteSurveysById",
        "description": "**Resposta:** `204`. Em uso numa operação: `409 survey_in_use`, com o nome das operações na mensagem",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`. Em uso numa operação: `409 survey_in_use`, com o nome das operações na mensagem"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`survey_in_use`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/surveys/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/calls": {
      "get": {
        "tags": [
          "Ligações"
        ],
        "summary": "Listar ligações da conversa",
        "operationId": "getCalls",
        "description": "**Resposta:** `{ data: [Call] }`, até 100, da mais nova",
        "parameters": [
          {
            "name": "conversationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [Call] }`, até 100, da mais nova",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Call"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/calls\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Ligações"
        ],
        "summary": "Ligar para o contato da conversa",
        "operationId": "postCalls",
        "description": "**Corpo:** `{ conversationId }`\n\n**Resposta:** `201 CallStart`. Os erros estão logo abaixo",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "conversationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "conversationId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 CallStart`. Os erros estão logo abaixo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallStart"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/calls\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/calls/{id}/answer": {
      "post": {
        "tags": [
          "Ligações"
        ],
        "summary": "Atender ligação",
        "operationId": "postCallsByIdAnswer",
        "description": "**Resposta:** `CallStart` com `conversationId`: pega a ligação para quem clicou. No número oficial vem também `sdp` (a oferta de quem ligou): o navegador responde pelo `call.sdp` com o SDP completo e a API faz o `pre_accept` e o `accept`. No Conector, o navegador manda a oferta pelo mesmo `call.sdp`. Recusa com `409 call_taken` (número oficial) ou `409 call_unavailable` e `reason` `taken` (outra pessoa atendeu), `ended`, `no_conector`, `conector_offline`, `other_call_number`, `not_ready` ou `busy` (ligacoes.md)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`CallStart` com `conversationId`: pega a ligação para quem clicou. No número oficial vem também `sdp` (a oferta de quem ligou): o navegador responde pelo `call.sdp` com o SDP completo e a API faz o `pre_accept` e o `accept`. No Conector, o navegador manda a oferta pelo mesmo `call.sdp`. Recusa com `409 call_taken` (número oficial) ou `409 call_unavailable` e `reason` `taken` (outra pessoa atendeu), `ended`, `no_conector`, `conector_offline`, `other_call_number`, `not_ready` ou `busy` (ligacoes.md)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallStart"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`call_taken`, `call_unavailable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/calls/6750a1c2e4b0a1b2c3d4e5f1/answer\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/calls/{id}/reject": {
      "post": {
        "tags": [
          "Ligações"
        ],
        "summary": "Recusar ligação",
        "operationId": "postCallsByIdReject",
        "description": "**Resposta:** `204`; recusa na Meta. Só no número oficial (`409 not_official`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; recusa na Meta. Só no número oficial (`409 not_official`)"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_official`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/calls/6750a1c2e4b0a1b2c3d4e5f1/reject\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/calls/{id}/recording": {
      "post": {
        "tags": [
          "Ligações"
        ],
        "summary": "Enviar gravação da ligação",
        "operationId": "postCallsByIdRecording",
        "description": "**Corpo:** multipart: `me` e `them` (`audio/webm` ou `audio/ogg`, até 20 MB cada), `seconds`, `cut` (`true` quando passou de 90 min)\n\n**Resposta:** `202 { status: \"pending\" }`; a transcrição vai para a fila do worker. Só quem fez ou atendeu (`403`), uma vez por ligação (`409 already_recorded`), ligação atendida (`409 not_answered`) e com a gravação ligada (`409 record_off`, com o motivo). `413 too_large`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "description": "multipart: `me` e `them` (`audio/webm` ou `audio/ogg`, até 20 MB cada), `seconds`, `cut` (`true` quando passou de 90 min)"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "`202 { status: \"pending\" }`; a transcrição vai para a fila do worker. Só quem fez ou atendeu (`403`), uma vez por ligação (`409 already_recorded`), ligação atendida (`409 not_answered`) e com a gravação ligada (`409 record_off`, com o motivo). `413 too_large`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending"
                      ],
                      "example": "pending"
                    }
                  },
                  "required": [
                    "status"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`already_recorded`, `not_answered`, `record_off`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "413": {
            "description": "`too_large`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/calls/6750a1c2e4b0a1b2c3d4e5f1/recording\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -F \"file=@arquivo.pdf\""
          }
        ]
      }
    },
    "/api/v1/calls/{id}/transcript": {
      "get": {
        "tags": [
          "Ligações"
        ],
        "summary": "Ver transcrição da ligação",
        "operationId": "getCallsByIdTranscript",
        "description": "**Resposta:** `{ status: \"pending\"|\"done\"|\"failed\", reason?, text, seconds?, cut?, at, doneAt? }` para quem vê a conversa. `text` traz uma fala por linha, `[mm:ss] Nome: fala` (quem fala pela empresa leva \"(empresa)\"), ou um lado depois do outro quando o modelo não dá o tempo. `409 no_transcript`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ status: \"pending\"|\"done\"|\"failed\", reason?, text, seconds?, cut?, at, doneAt? }` para quem vê a conversa. `text` traz uma fala por linha, `[mm:ss] Nome: fala` (quem fala pela empresa leva \"(empresa)\"), ou um lado depois do outro quando o modelo não dá o tempo. `409 no_transcript`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "done",
                        "failed"
                      ],
                      "example": "pending"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "text": {
                      "type": "string",
                      "example": "Bom dia, o pedido já saiu?"
                    },
                    "seconds": {
                      "type": "integer"
                    },
                    "cut": {},
                    "at": {
                      "type": "string",
                      "format": "date-time",
                      "example": "2026-12-01T12:12:00Z"
                    },
                    "doneAt": {
                      "type": "string",
                      "format": "date-time",
                      "example": "2026-12-01T12:12:00Z"
                    }
                  },
                  "required": [
                    "status",
                    "text",
                    "at"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`no_transcript`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/calls/6750a1c2e4b0a1b2c3d4e5f1/transcript\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/reports": {
      "get": {
        "tags": [
          "Relatórios"
        ],
        "summary": "Ver os números do atendimento",
        "operationId": "getReports",
        "description": "**Resposta:** `Report`. Os filtros e os erros estão logo abaixo",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "+5554999990000"
            }
          },
          {
            "name": "operationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "numberId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "userId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Report`. Os filtros e os erros estão logo abaixo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/reports\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/reports/chat": {
      "get": {
        "tags": [
          "Relatórios"
        ],
        "summary": "Ver o uso do chat interno",
        "operationId": "getReportsChat",
        "description": "**Resposta:** `ReportChat` (só o perfil Administrador; `403` para os outros)",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "+5554999990000"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`ReportChat` (só o perfil Administrador; `403` para os outros)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportChat"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/reports/chat\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/settings": {
      "get": {
        "tags": [
          "Configurações e novidades"
        ],
        "summary": "Ver configurações da empresa",
        "operationId": "getSettings",
        "description": "**Quem:** todos\n\n**Resposta:** `Settings`",
        "responses": {
          "200": {
            "description": "`Settings`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Settings"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/settings\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Configurações e novidades"
        ],
        "summary": "Alterar configurações da empresa",
        "operationId": "patchSettings",
        "description": "**Quem:** cada campo com a sua permissão: `qrLimits` com `connections`, `attendance` com `attendance`, `twoFactor` com `team`, `companyName` só o Administrador (campo sem a permissão: `403`, nada é gravado)\n\n**Corpo:** `{ qrLimits?: { minDelayMs?, maxDelayMs?, perDay?, newPerDay?, windowStart?, windowEnd?, typingPreSec? }, companyName?, attendance?, twoFactor? }`\n\n**Resposta:** `Settings`; os Conectores recebem o ritmo novo na hora",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "qrLimits": {
                    "type": "object",
                    "properties": {
                      "minDelayMs": {},
                      "maxDelayMs": {},
                      "perDay": {},
                      "newPerDay": {},
                      "windowStart": {},
                      "windowEnd": {},
                      "typingPreSec": {}
                    }
                  },
                  "companyName": {
                    "type": "string",
                    "example": "Padaria Bom Grão"
                  },
                  "attendance": {},
                  "twoFactor": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Settings`; os Conectores recebem o ritmo novo na hora",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Settings"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "cada campo com a sua permissão: `qrLimits` com `connections`, `attendance` com `attendance`, `twoFactor` com `team`, `companyName` só o Administrador (campo sem a permissão: `403`, nada é gravado)",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/settings\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"qrLimits\":{},\"companyName\":\"Padaria Bom Grão\"}'"
          }
        ]
      }
    },
    "/api/v1/activity": {
      "get": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Listar atividades",
        "operationId": "getActivity",
        "description": "**Quem:** todos\n\n**Resposta:** `{ data: Activity[], nextCursor }`, do mais novo ao mais antigo (30 por vez, até 100); `kinds` separados por vírgula; `unseen=1`, só os não vistos. A primeira página começa pelos fixos (`pinned`), vistos ou não",
        "parameters": [
          {
            "name": "kinds",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "unseen",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: Activity[], nextCursor }`, do mais novo ao mais antigo (30 por vez, até 100); `kinds` separados por vírgula; `unseen=1`, só os não vistos. A primeira página começa pelos fixos (`pinned`), vistos ou não",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/Activity"
                        },
                        {
                          "type": "array",
                          "items": {}
                        }
                      ]
                    },
                    "nextCursor": {}
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/activity\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Limpar atividades",
        "operationId": "deleteActivity",
        "description": "**Quem:** todos\n\n**Resposta:** `ActivityPrefs` com `clearedAt`: apaga todos os itens da pessoa, menos os fixos, e manda `activity.cleared`",
        "responses": {
          "200": {
            "description": "`ActivityPrefs` com `clearedAt`: apaga todos os itens da pessoa, menos os fixos, e manda `activity.cleared`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityPrefs"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/activity\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/activity/count": {
      "get": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Contar atividades não vistas",
        "operationId": "getActivityCount",
        "description": "**Quem:** todos\n\n**Resposta:** `{ total, kinds: { message?, handoff?, … } }`: itens não vistos",
        "responses": {
          "200": {
            "description": "`{ total, kinds: { message?, handoff?, … } }`: itens não vistos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "kinds": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "example": "Bom dia, o pedido já saiu?"
                        },
                        "handoff": {}
                      }
                    }
                  },
                  "required": [
                    "total",
                    "kinds"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/activity/count\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/activity/seen": {
      "post": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Marcar atividades como vistas",
        "operationId": "postActivitySeen",
        "description": "**Quem:** todos\n\n**Corpo:** `{ ids?, keys?, all? }`\n\n**Resposta:** `204`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {},
                  "keys": {},
                  "all": {}
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "`204`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/activity/seen\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/me/activity-prefs": {
      "get": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Ver preferências de atividade",
        "operationId": "getMeActivityPrefs",
        "description": "**Quem:** todos\n\n**Resposta:** `ActivityPrefs`",
        "responses": {
          "200": {
            "description": "`ActivityPrefs`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityPrefs"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/me/activity-prefs\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "put": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Alterar preferências de atividade",
        "operationId": "putMeActivityPrefs",
        "description": "**Quem:** todos\n\n**Corpo:** `ActivityPrefs`\n\n**Resposta:** `ActivityPrefs` (tipos desconhecidos saem; `digest` desconhecido vira `\"\"`; `clearedAt` fica o gravado). `notifyOff`, `soundOff` e `hoursOnly` são as chaves da aba Geral da janela Notificações. A resposta (e a do `GET`) traz também `hours` e `hoursText`, o horário de atendimento da pessoa, só para leitura",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActivityPrefs"
              }
            }
          },
          "description": "`ActivityPrefs`"
        },
        "responses": {
          "200": {
            "description": "`ActivityPrefs` (tipos desconhecidos saem; `digest` desconhecido vira `\"\"`; `clearedAt` fica o gravado). `notifyOff`, `soundOff` e `hoursOnly` são as chaves da aba Geral da janela Notificações. A resposta (e a do `GET`) traz também `hours` e `hoursText`, o horário de atendimento da pessoa, só para leitura",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityPrefs"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/me/activity-prefs\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"sound\":[],\"notify\":[],\"clearedAt\":\"2026-12-01T12:12:00Z\"}'"
          }
        ]
      }
    },
    "/api/v1/me/delivery": {
      "get": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Ver como recebo avisos",
        "operationId": "getMeDelivery",
        "description": "**Quem:** todos\n\n**Resposta:** `Delivery`: os avisos fora do painel",
        "responses": {
          "200": {
            "description": "`Delivery`: os avisos fora do painel",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Delivery"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/me/delivery\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/me/push": {
      "put": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Ativar avisos no navegador",
        "operationId": "putMePush",
        "description": "**Quem:** todos\n\n**Corpo:** `{ endpoint, keys: { p256dh, auth } }` (o `toJSON()` da assinatura do navegador)\n\n**Resposta:** `PushDevice`; grava ou atualiza pelo `endpoint`. `409 push_off` (aviso no aparelho indisponível no servidor), `422 validation` com `details.endpoint` (fora dos serviços de aviso conhecidos) ou `details.keys`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "endpoint": {},
                  "keys": {
                    "type": "object",
                    "properties": {
                      "p256dh": {},
                      "auth": {}
                    },
                    "required": [
                      "p256dh",
                      "auth"
                    ]
                  }
                },
                "required": [
                  "endpoint",
                  "keys"
                ],
                "description": "(o `toJSON()` da assinatura do navegador)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`PushDevice`; grava ou atualiza pelo `endpoint`. `409 push_off` (aviso no aparelho indisponível no servidor), `422 validation` com `details.endpoint` (fora dos serviços de aviso conhecidos) ou `details.keys`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushDevice"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`push_off`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/me/push\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"keys\":{}}'"
          }
        ]
      }
    },
    "/api/v1/me/push/{id}": {
      "delete": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Desativar avisos no navegador",
        "operationId": "deleteMePushById",
        "description": "**Quem:** todos\n\n**Resposta:** `204`; `404 push_not_found`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; `404 push_not_found`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`push_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/me/push/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/me/push/test": {
      "post": {
        "tags": [
          "Painel de atividade"
        ],
        "summary": "Testar aviso no navegador",
        "operationId": "postMePushTest",
        "description": "**Quem:** todos\n\n**Resposta:** `{ sent, failed }`: notificação de teste a todos os aparelhos da pessoa. `409 push_off` ou `409 push_none` (nenhum aparelho)",
        "responses": {
          "200": {
            "description": "`{ sent, failed }`: notificação de teste a todos os aparelhos da pessoa. `409 push_off` ou `409 push_none` (nenhum aparelho)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sent": {},
                    "failed": {}
                  },
                  "required": [
                    "sent",
                    "failed"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`push_off`, `push_none`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/me/push/test\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Listar espaços do Conhecimento",
        "operationId": "getKb",
        "description": "**Quem:** todos\n\n**Resposta:** `{ spaces: [KBSpace], pages: [KBPage sem body], central: { slug, url }, gaps, viewer? }` — `gaps` é o total de perguntas sem resposta abertas; `viewer` (`{ id, name, admin }`) com `as`. Empresa sem espaços ganha os três padrão aqui",
        "parameters": [
          {
            "name": "as",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ spaces: [KBSpace], pages: [KBPage sem body], central: { slug, url }, gaps, viewer? }` — `gaps` é o total de perguntas sem resposta abertas; `viewer` (`{ id, name, admin }`) com `as`. Empresa sem espaços ganha os três padrão aqui",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "spaces": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KBSpace"
                      }
                    },
                    "pages": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/KBPage"
                          }
                        ],
                        "description": "sem body"
                      }
                    },
                    "central": {
                      "type": "object",
                      "properties": {
                        "slug": {
                          "type": "string",
                          "example": "boas-vindas"
                        },
                        "url": {
                          "type": "string",
                          "example": "https://exemplo.com.br"
                        }
                      },
                      "required": [
                        "slug",
                        "url"
                      ]
                    },
                    "gaps": {},
                    "viewer": {}
                  },
                  "required": [
                    "spaces",
                    "pages",
                    "central",
                    "gaps"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/search": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Buscar no Conhecimento",
        "operationId": "getKbSearch",
        "description": "**Quem:** todos\n\n**Resposta:** `{ data: [{ id, kind, spaceId, parentId?, title, snippet, slug? }] }` (até 30; quem tem a palavra no título vem antes)",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "as",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [{ id, kind, spaceId, parentId?, title, snippet, slug? }] }` (até 30; quem tem a palavra no título vem antes)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "spaceId": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "parentId": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "title": {
                            "type": "string",
                            "example": "Pedido 48211"
                          },
                          "snippet": {},
                          "slug": {
                            "type": "string",
                            "example": "boas-vindas"
                          }
                        },
                        "required": [
                          "id",
                          "kind",
                          "spaceId",
                          "title",
                          "snippet"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/search\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/archived": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Listar itens arquivados do Conhecimento",
        "operationId": "getKbArchived",
        "description": "**Quem:** `knowledge`\n\n**Resposta:** `{ spaces: [KBSpace], pages: [KBPage + spaceTitle] }`",
        "responses": {
          "200": {
            "description": "`{ spaces: [KBSpace], pages: [KBPage + spaceTitle] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "spaces": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KBSpace"
                      }
                    },
                    "pages": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/KBPage"
                          }
                        ],
                        "description": "+ spaceTitle"
                      }
                    }
                  },
                  "required": [
                    "spaces",
                    "pages"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`knowledge`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/archived\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/central": {
      "put": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Definir a Central de ajuda",
        "operationId": "putKbCentral",
        "description": "**Quem:** `knowledge`\n\n**Corpo:** `{ slug }`\n\n**Resposta:** `{ slug, url }`; `409 slug_taken` se é de outra empresa",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "slug": {
                    "type": "string",
                    "example": "boas-vindas"
                  }
                },
                "required": [
                  "slug"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ slug, url }`; `409 slug_taken` se é de outra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "slug": {
                      "type": "string",
                      "example": "boas-vindas"
                    },
                    "url": {
                      "type": "string",
                      "example": "https://exemplo.com.br"
                    }
                  },
                  "required": [
                    "slug",
                    "url"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`slug_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`knowledge`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/kb/central\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"slug\":\"boas-vindas\"}'"
          }
        ]
      }
    },
    "/api/v1/kb/spaces": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Criar espaço do Conhecimento",
        "operationId": "postKbSpaces",
        "description": "**Quem:** `knowledge`\n\n**Corpo:** `{ title, icon, layout, visibility, areaIds? }`\n\n**Resposta:** `201 KBSpace`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "icon": {
                    "type": "string"
                  },
                  "layout": {},
                  "visibility": {},
                  "areaIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  }
                },
                "required": [
                  "title",
                  "icon",
                  "layout",
                  "visibility"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 KBSpace`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBSpace"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`knowledge`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/spaces\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Pedido 48211\",\"icon\":\"texto\",\"areaIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}'"
          }
        ]
      }
    },
    "/api/v1/kb/spaces/{id}": {
      "patch": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Alterar espaço do Conhecimento",
        "operationId": "patchKbSpacesById",
        "description": "**Quem:** `knowledge`\n\n**Corpo:** `{ title?, icon?, visibility?, areaIds?, archived?, index? }`\n\n**Resposta:** `KBSpace`; `index` muda a posição na lista",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "icon": {
                    "type": "string"
                  },
                  "visibility": {},
                  "areaIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "archived": {
                    "type": "boolean"
                  },
                  "index": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`KBSpace`; `index` muda a posição na lista",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBSpace"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`knowledge`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/kb/spaces/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Pedido 48211\",\"icon\":\"texto\",\"areaIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"archived\":true}'"
          }
        ]
      }
    },
    "/api/v1/kb/spaces/{id}/news": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Ver novidades do espaço",
        "operationId": "getKbSpacesByIdNews",
        "description": "**Quem:** todos\n\n**Resposta:** `{ data: [KBPage], files }` — as novidades com texto, da mais nova para a mais antiga (até 200)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "as",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [KBPage], files }` — as novidades com texto, da mais nova para a mais antiga (até 200)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KBPage"
                      }
                    },
                    "files": {}
                  },
                  "required": [
                    "data",
                    "files"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/spaces/6750a1c2e4b0a1b2c3d4e5f1/news\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/pages": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Criar página do Conhecimento",
        "operationId": "postKbPages",
        "description": "**Quem:** todos\n\n**Corpo:** `{ kind?, spaceId, parentId?, title, body?, tag?, source?: { kind: \"chat\"|\"conversation\", id, name? }, publish? }`\n\n**Resposta:** `201 KBPage`; nasce com o padrão de quem vê do espaço. Sem `publish`, rascunho; com `publish` (exige `body`), já na versão 1. Novidade sempre publica. `422 spaceId` se o padrão do espaço é de áreas de que a pessoa não participa",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string"
                  },
                  "spaceId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "parentId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "body": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "tag": {},
                  "source": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "chat",
                          "conversation"
                        ],
                        "example": "chat"
                      },
                      "id": {
                        "type": "string",
                        "example": "6750a1c2e4b0a1b2c3d4e5f1"
                      },
                      "name": {
                        "type": "string",
                        "example": "Ana Prado"
                      }
                    },
                    "required": [
                      "kind",
                      "id"
                    ]
                  },
                  "publish": {}
                },
                "required": [
                  "spaceId",
                  "title"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 KBPage`; nasce com o padrão de quem vê do espaço. Sem `publish`, rascunho; com `publish` (exige `body`), já na versão 1. Novidade sempre publica. `422 spaceId` se o padrão do espaço é de áreas de que a pessoa não participa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPage"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/pages\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"kind\":\"texto\",\"spaceId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"parentId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"title\":\"Pedido 48211\",\"body\":\"Bom dia, o pedido já saiu?\",\"source\":{\"kind\":\"chat\",\"id\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"name\":\"Ana Prado\"}}'"
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Ver página do Conhecimento",
        "operationId": "getKbPagesById",
        "description": "**Quem:** quem vê\n\n**Resposta:** `KBPage` completa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "as",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`KBPage` completa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPage"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Alterar ajustes da página",
        "operationId": "patchKbPagesById",
        "description": "**Quem:** `knowledge`\n\n**Corpo:** `{ visibility?, areaIds?, ai?, aiLink?, archived? }`\n\n**Resposta:** `KBPage`; `aiLink` só em página pública com `ai`. `409 page_archived` (mudar arquivada), `page_has_children` (arquivar com páginas dentro), `space_archived` (restaurar em espaço arquivado). Restaurar página cuja mãe saiu a põe na raiz",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "visibility": {},
                  "areaIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "ai": {},
                  "aiLink": {},
                  "archived": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`KBPage`; `aiLink` só em página pública com `ai`. `409 page_archived` (mudar arquivada), `page_has_children` (arquivar com páginas dentro), `space_archived` (restaurar em espaço arquivado). Restaurar página cuja mãe saiu a põe na raiz",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPage"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`page_archived`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`knowledge`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"areaIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"archived\":true}'"
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/content": {
      "put": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Salvar conteúdo da página",
        "operationId": "putKbPagesByIdContent",
        "description": "**Quem:** quem vê\n\n**Corpo:** `{ title, body, tag?, note?, baseVersion, force?, draft? }` (`note`, o \"O que mudou\", até 200 letras)\n\n**Resposta:** `KBPage` na versão nova (o primeiro salvar do rascunho publica). Com `draft: true` numa página em rascunho, só guarda o título e o texto (\"Salvar rascunho\"): continua rascunho, sem versão nova, e aceita texto vazio; `409 version_conflict` se alguém publicou no meio. `422 body` em página (`page`) sem texto (\"Escreva o texto antes de publicar.\"; a novidade pode ir sem texto), `422 note` acima do limite; `409 version_conflict` (`details`: `version`, `by`) se outra pessoa salvou depois de `baseVersion`; `force` grava por cima",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "body": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "tag": {},
                  "note": {
                    "type": "string"
                  },
                  "baseVersion": {},
                  "force": {},
                  "draft": {}
                },
                "required": [
                  "title",
                  "body",
                  "baseVersion"
                ],
                "description": "(`note`, o \"O que mudou\", até 200 letras)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`KBPage` na versão nova (o primeiro salvar do rascunho publica). Com `draft: true` numa página em rascunho, só guarda o título e o texto (\"Salvar rascunho\"): continua rascunho, sem versão nova, e aceita texto vazio; `409 version_conflict` se alguém publicou no meio. `422 body` em página (`page`) sem texto (\"Escreva o texto antes de publicar.\"; a novidade pode ir sem texto), `422 note` acima do limite; `409 version_conflict` (`details`: `version`, `by`) se outra pessoa salvou depois de `baseVersion`; `force` grava por cima",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPage"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`version_conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`body`, `note`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/content\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Pedido 48211\",\"body\":\"Bom dia, o pedido já saiu?\",\"note\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/move": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Mover página",
        "operationId": "postKbPagesByIdMove",
        "description": "**Quem:** `knowledge`\n\n**Corpo:** `{ spaceId?, parentId?, index? }`\n\n**Resposta:** `KBPage`; as de dentro vão junto. Não entra nela mesma nem numa de dentro; página só em espaço `docs`, novidade só em `news`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "spaceId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "parentId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "index": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`KBPage`; as de dentro vão junto. Não entra nela mesma nem numa de dentro; página só em espaço `docs`, novidade só em `news`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPage"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "`knowledge`",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/move\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"spaceId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"parentId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/versions": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Listar versões da página",
        "operationId": "getKbPagesByIdVersions",
        "description": "**Quem:** quem vê\n\n**Resposta:** `{ data: [{ pageId, version, title, tag?, note?, author: Ref, at, restored? }] }` (sem texto, até 200)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [{ pageId, version, title, tag?, note?, author: Ref, at, restored? }] }` (sem texto, até 200)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "pageId": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "version": {
                            "type": "integer"
                          },
                          "title": {
                            "type": "string",
                            "example": "Pedido 48211"
                          },
                          "tag": {},
                          "note": {
                            "type": "string"
                          },
                          "author": {
                            "$ref": "#/components/schemas/Ref"
                          },
                          "at": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          },
                          "restored": {}
                        },
                        "required": [
                          "pageId",
                          "version",
                          "title",
                          "author",
                          "at"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/versions\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/versions/{n}": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Ver uma versão da página",
        "operationId": "getKbPagesByIdVersionsByN",
        "description": "**Quem:** quem vê\n\n**Resposta:** `KBPageVersion`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`KBPageVersion`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPageVersion"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/versions/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/versions/{n}/restore": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Restaurar versão da página",
        "operationId": "postKbPagesByIdVersionsByNRestore",
        "description": "**Quem:** quem vê\n\n**Resposta:** `KBPage` numa versão nova com o texto da `n` (`restored: n`); `409 version_current`; `422 body` se a versão `n` de uma página não tem texto",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`KBPage` numa versão nova com o texto da `n` (`restored: n`); `409 version_current`; `422 body` se a versão `n` de uma página não tem texto",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPage"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`version_current`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`body`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/versions/6750a1c2e4b0a1b2c3d4e5f1/restore\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/gaps": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Listar perguntas sem resposta",
        "operationId": "getKbGaps",
        "description": "**Quem:** todos\n\n**Resposta:** `{ data: [{ id, question, count, agent?, conversationIds, status, page?, createdAt, lastAt }], total, meta: { total, page, pageSize, pages } }`: as abertas, da mais recente para a mais antiga. `q` busca na pergunta; `total` é o de abertas sem a busca (o número do menu) e `meta.total`, o que a busca achou",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [{ id, question, count, agent?, conversationIds, status, page?, createdAt, lastAt }], total, meta: { total, page, pageSize, pages } }`: as abertas, da mais recente para a mais antiga. `q` busca na pergunta; `total` é o de abertas sem a busca (o número do menu) e `meta.total`, o que a busca achou",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "question": {},
                          "count": {
                            "type": "integer"
                          },
                          "agent": {},
                          "conversationIds": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "6750a1c2e4b0a1b2c3d4e5f1"
                            }
                          },
                          "status": {
                            "type": "string"
                          },
                          "page": {
                            "type": "integer",
                            "example": 1
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          },
                          "lastAt": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          }
                        },
                        "required": [
                          "id",
                          "question",
                          "count",
                          "conversationIds",
                          "status",
                          "createdAt",
                          "lastAt"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "page": {
                          "type": "integer",
                          "example": 1
                        },
                        "pageSize": {
                          "type": "integer",
                          "example": 50
                        },
                        "pages": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "total",
                        "page",
                        "pageSize",
                        "pages"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "total",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/gaps\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/gaps/{id}/write": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Escrever página para a pergunta",
        "operationId": "postKbGapsByIdWrite",
        "description": "**Quem:** todos\n\n**Corpo:** `{ spaceId?, title?, text?, pageId? }`\n\n**Resposta:** Sem `pageId`: `201 KBPage` rascunho com `title` (sem ele, a pergunta) e `text` (`source.kind: \"gap\"`); sem `spaceId`, o primeiro espaço de páginas público. `409 no_space`. Com `pageId`: `200 KBPage`, o `text` entra no fim do rascunho dessa página (e `title` troca o título); página já publicada: `409 page_published`. A pergunta fica escrita, com a página",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "spaceId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "title": {
                    "type": "string",
                    "example": "Pedido 48211"
                  },
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "pageId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sem `pageId`: `201 KBPage` rascunho com `title` (sem ele, a pergunta) e `text` (`source.kind: \"gap\"`); sem `spaceId`, o primeiro espaço de páginas público. `409 no_space`. Com `pageId`: `200 KBPage`, o `text` entra no fim do rascunho dessa página (e `title` troca o título); página já publicada: `409 page_published`. A pergunta fica escrita, com a página"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`no_space`, `page_published`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/gaps/6750a1c2e4b0a1b2c3d4e5f1/write\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"spaceId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"title\":\"Pedido 48211\",\"text\":\"Bom dia, o pedido já saiu?\",\"pageId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/kb/gaps/{id}": {
      "delete": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Descartar pergunta sem resposta",
        "operationId": "deleteKbGapsById",
        "description": "**Quem:** todos\n\n**Resposta:** `204` (dispensada)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204` (dispensada)"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/kb/gaps/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/required": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Listar leituras obrigatórias",
        "operationId": "getKbRequired",
        "description": "**Quem:** todos\n\n**Resposta:** `{ data: [{ id, kind, spaceId, title, by: Ref, at, until? }] }`: as leituras obrigatórias que faltam para a pessoa (a faixa do alto do painel), da mais antiga para a mais nova, só no prazo e só das páginas que ela vê. Vazio no acesso de suporte",
        "responses": {
          "200": {
            "description": "`{ data: [{ id, kind, spaceId, title, by: Ref, at, until? }] }`: as leituras obrigatórias que faltam para a pessoa (a faixa do alto do painel), da mais antiga para a mais nova, só no prazo e só das páginas que ela vê. Vazio no acesso de suporte",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "spaceId": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "title": {
                            "type": "string",
                            "example": "Pedido 48211"
                          },
                          "by": {
                            "$ref": "#/components/schemas/Ref"
                          },
                          "at": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          },
                          "until": {}
                        },
                        "required": [
                          "id",
                          "kind",
                          "spaceId",
                          "title",
                          "by",
                          "at"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/required\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/required": {
      "put": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Tornar página de leitura obrigatória",
        "operationId": "putKbPagesByIdRequired",
        "description": "**Quem:** quem vê\n\n**Corpo:** `{ audience: { kind, operationIds?, areaIds? }, until?: ISO | null }`\n\n**Resposta:** `KBPage` com `required`. Marca ou muda (mudar não zera quem leu). Ao marcar, quem pediu conta como lido e o lembrete sai no dia seguinte. `409 page_draft` (rascunho), `409 required_exists` (outra pessoa marcou ao mesmo tempo), `422 until` (passou ou passa de 2 anos)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "audience": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string"
                      },
                      "operationIds": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "example": "6750a1c2e4b0a1b2c3d4e5f1"
                        }
                      },
                      "areaIds": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "example": "6750a1c2e4b0a1b2c3d4e5f1"
                        }
                      }
                    },
                    "required": [
                      "kind"
                    ]
                  },
                  "until": {
                    "description": "ISO Pode vir null."
                  }
                },
                "required": [
                  "audience"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`KBPage` com `required`. Marca ou muda (mudar não zera quem leu). Ao marcar, quem pediu conta como lido e o lembrete sai no dia seguinte. `409 page_draft` (rascunho), `409 required_exists` (outra pessoa marcou ao mesmo tempo), `422 until` (passou ou passa de 2 anos)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPage"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`page_draft`, `required_exists`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`until`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/required\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"audience\":{\"kind\":\"texto\",\"operationIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"areaIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Tirar leitura obrigatória da página",
        "operationId": "deleteKbPagesByIdRequired",
        "description": "**Quem:** quem vê\n\n**Resposta:** `KBPage` sem `required`; quem leu é apagado e o lembrete sai da Atividade",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`KBPage` sem `required`; quem leu é apagado e o lembrete sai da Atividade",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPage"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/required\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/required/again": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Pedir nova leitura da página",
        "operationId": "postKbPagesByIdRequiredAgain",
        "description": "**Quem:** quem vê\n\n**Resposta:** `KBPage`: pede de novo (o texto mudou): `round` + 1, quem leu volta a ser só quem pediu, lembrete no dia seguinte. `409 not_required`, `409 required_changed` (outra pessoa pediu antes)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`KBPage`: pede de novo (o texto mudou): `round` + 1, quem leu volta a ser só quem pediu, lembrete no dia seguinte. `409 not_required`, `409 required_changed` (outra pessoa pediu antes)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBPage"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_required`, `required_changed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/required/again\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/required/remind": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Lembrar quem não leu a página",
        "operationId": "postKbPagesByIdRequiredRemind",
        "description": "**Quem:** quem vê\n\n**Resposta:** `{ sent }`: põe o lembrete na Atividade de quem falta. `409 reminded_recently` (1 por hora), `409 nobody_missing`, `409 not_required`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ sent }`: põe o lembrete na Atividade de quem falta. `409 reminded_recently` (1 por hora), `409 nobody_missing`, `409 not_required`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sent": {}
                  },
                  "required": [
                    "sent"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`reminded_recently`, `nobody_missing`, `not_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/required/remind\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/reads": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Ver quem leu a página",
        "operationId": "getKbPagesByIdReads",
        "description": "**Quem:** quem vê\n\n**Resposta:** `{ total, read: [{ id, name, at }], missing: [{ id, name }] }` (só quem está no público e vê a página; `read` do mais recente, `missing` pelo nome). `404 not_required`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ total, read: [{ id, name, at }], missing: [{ id, name }] }` (só quem está no público e vê a página; `read` do mais recente, `missing` pelo nome). `404 not_required`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "read": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "at": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "at"
                        ]
                      }
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          }
                        },
                        "required": [
                          "id",
                          "name"
                        ]
                      }
                    }
                  },
                  "required": [
                    "total",
                    "read",
                    "missing"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`not_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/reads\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/pages/{id}/read": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Marcar página como lida",
        "operationId": "postKbPagesByIdRead",
        "description": "**Quem:** quem vê\n\n**Resposta:** `204` (\"Li e entendi\"). `409 not_required` (tirada ou fora do prazo), `409 not_for_you` (fora do público), `409 required_changed` (pedida de novo no meio)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204` (\"Li e entendi\"). `409 not_required` (tirada ou fora do prazo), `409 not_for_you` (fora do público), `409 required_changed` (pedida de novo no meio)"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_required`, `not_for_you`, `required_changed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "quem vê",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/pages/6750a1c2e4b0a1b2c3d4e5f1/read\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/trails": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Listar trilhas",
        "operationId": "getKbTrails",
        "description": "**Quem:** todos\n\n**Resposta:** `{ data: [KBTrailItem] }` (as 200 mais novas, arquivadas junto): `{ id, title, description, steps, questions, audience, archived, mine, status, people, completed, updatedAt }`",
        "responses": {
          "200": {
            "description": "`{ data: [KBTrailItem] }` (as 200 mais novas, arquivadas junto): `{ id, title, description, steps, questions, audience, archived, mine, status, people, completed, updatedAt }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "description": "KBTrailItem"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/trails\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Criar trilha",
        "operationId": "postKbTrails",
        "description": "**Quem:** todos\n\n**Corpo:** `KBTrailBody`\n\n**Resposta:** `201 KBTrail` (com `answers`); avisa \"Trilha nova\" a quem está no público",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KBTrailBody"
              }
            }
          },
          "description": "`KBTrailBody`"
        },
        "responses": {
          "201": {
            "description": "`201 KBTrail` (com `answers`); avisa \"Trilha nova\" a quem está no público",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBTrail"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/trails\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Pedido 48211\",\"description\":\"texto\",\"pageIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"questions\":[{\"text\":\"Bom dia, o pedido já saiu?\"}],\"audience\":{\"kind\":\"texto\",\"operationIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"areaIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}}'"
          }
        ]
      }
    },
    "/api/v1/kb/trails/{id}": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Ver uma trilha",
        "operationId": "getKbTrailsById",
        "description": "**Quem:** todos\n\n**Resposta:** `KBTrail`; `answers` (a posição da opção certa de cada pergunta) só com `edit=1`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "edit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`KBTrail`; `answers` (a posição da opção certa de cada pergunta) só com `edit=1`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBTrail"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/trails/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "put": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Alterar trilha",
        "operationId": "putKbTrailsById",
        "description": "**Quem:** todos\n\n**Corpo:** `KBTrailBody`\n\n**Resposta:** `KBTrail`; o progresso de cada pessoa fica. `409 trail_archived`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KBTrailBody"
              }
            }
          },
          "description": "`KBTrailBody`"
        },
        "responses": {
          "200": {
            "description": "`KBTrail`; o progresso de cada pessoa fica. `409 trail_archived`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBTrail"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`trail_archived`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/kb/trails/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Pedido 48211\",\"description\":\"texto\",\"pageIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"questions\":[{\"text\":\"Bom dia, o pedido já saiu?\"}],\"audience\":{\"kind\":\"texto\",\"operationIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"],\"areaIds\":[\"6750a1c2e4b0a1b2c3d4e5f1\"]}}'"
          }
        ]
      },
      "patch": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Arquivar ou desarquivar a trilha",
        "operationId": "patchKbTrailsById",
        "description": "**Quem:** todos\n\n**Corpo:** `{ archived }`\n\n**Resposta:** `KBTrail`; restaurar avisa quem está no público e ainda não recebeu",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "archived": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "archived"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`KBTrail`; restaurar avisa quem está no público e ainda não recebeu",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBTrail"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/kb/trails/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"archived\":true}'"
          }
        ]
      }
    },
    "/api/v1/kb/trails/{id}/people": {
      "get": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Ver progresso das pessoas na trilha",
        "operationId": "getKbTrailsByIdPeople",
        "description": "**Quem:** todos\n\n**Resposta:** `{ data: [{ id, name, done, total, attempts, startedAt?, completedAt? }] }`: \"Quem fez a trilha\", as pessoas do público pelo nome",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [{ id, name, done, total, attempts, startedAt?, completedAt? }] }`: \"Quem fez a trilha\", as pessoas do público pelo nome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "done": {},
                          "total": {
                            "type": "integer"
                          },
                          "attempts": {},
                          "startedAt": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          },
                          "completedAt": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "done",
                          "total",
                          "attempts"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/kb/trails/6750a1c2e4b0a1b2c3d4e5f1/people\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/trails/{id}/steps/{page}": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Concluir etapa da trilha",
        "operationId": "postKbTrailsByIdStepsByPage",
        "description": "**Quem:** todos\n\n**Resposta:** `KBTrail`: o passo da página ficou feito (\"Próximo\"). `404 not_found` (a página não está na trilha ou a pessoa não vê), `409 trail_archived`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "page",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`KBTrail`: o passo da página ficou feito (\"Próximo\"). `404 not_found` (a página não está na trilha ou a pessoa não vê), `409 trail_archived`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KBTrail"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`trail_archived`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/trails/6750a1c2e4b0a1b2c3d4e5f1/steps/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/kb/trails/{id}/answers": {
      "post": {
        "tags": [
          "Conhecimento"
        ],
        "summary": "Enviar respostas da trilha",
        "operationId": "postKbTrailsByIdAnswers",
        "description": "**Quem:** todos\n\n**Corpo:** `{ answers: [n] }`\n\n**Resposta:** `{ passed, right, total, wrong: [n], completedAt? }` (`wrong`: as perguntas erradas, sem dizer a certa). Sem perguntas, `answers: []` conclui. `409 steps_missing`, `422 answers`, `409 trail_archived`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "answers": {
                    "type": "array",
                    "items": {
                      "description": "n"
                    }
                  }
                },
                "required": [
                  "answers"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ passed, right, total, wrong: [n], completedAt? }` (`wrong`: as perguntas erradas, sem dizer a certa). Sem perguntas, `answers: []` conclui. `409 steps_missing`, `422 answers`, `409 trail_archived`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "passed": {},
                    "right": {},
                    "total": {
                      "type": "integer"
                    },
                    "wrong": {
                      "type": "array",
                      "items": {
                        "description": "n"
                      }
                    },
                    "completedAt": {
                      "type": "string",
                      "format": "date-time",
                      "example": "2026-12-01T12:12:00Z"
                    }
                  },
                  "required": [
                    "passed",
                    "right",
                    "total",
                    "wrong"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`steps_missing`, `trail_archived`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`answers`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-quem": "todos",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/kb/trails/6750a1c2e4b0a1b2c3d4e5f1/answers\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"answers\":[]}'"
          }
        ]
      }
    },
    "/api/v1/public/kb/{company}": {
      "get": {
        "tags": [
          "Central de ajuda (sem login)"
        ],
        "summary": "Abrir a Central de ajuda",
        "operationId": "getPublicKbByCompany",
        "description": "**Resposta:** `{ company: { name, slug }, spaces: [{ id, title, icon, layout, pages: [{ slug, title, parent? }], count }], news: [{ id, title, tag, body, publishedAt }], newsTotal, files }` (as 3 novidades mais novas; `parent` é o `slug` da página-mãe)",
        "parameters": [
          {
            "name": "company",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Padaria Bom Grão"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ company: { name, slug }, spaces: [{ id, title, icon, layout, pages: [{ slug, title, parent? }], count }], news: [{ id, title, tag, body, publishedAt }], newsTotal, files }` (as 3 novidades mais novas; `parent` é o `slug` da página-mãe)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "company": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "example": "Ana Prado"
                        },
                        "slug": {
                          "type": "string",
                          "example": "boas-vindas"
                        }
                      },
                      "required": [
                        "name",
                        "slug"
                      ]
                    },
                    "spaces": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "title": {
                            "type": "string",
                            "example": "Pedido 48211"
                          },
                          "icon": {
                            "type": "string"
                          },
                          "layout": {},
                          "pages": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "slug": {
                                  "type": "string",
                                  "example": "boas-vindas"
                                },
                                "title": {
                                  "type": "string",
                                  "example": "Pedido 48211"
                                },
                                "parent": {}
                              },
                              "required": [
                                "slug",
                                "title"
                              ]
                            }
                          },
                          "count": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "icon",
                          "layout",
                          "pages",
                          "count"
                        ]
                      }
                    },
                    "news": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "title": {
                            "type": "string",
                            "example": "Pedido 48211"
                          },
                          "tag": {},
                          "body": {
                            "type": "string",
                            "example": "Bom dia, o pedido já saiu?"
                          },
                          "publishedAt": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "tag",
                          "body",
                          "publishedAt"
                        ]
                      }
                    },
                    "newsTotal": {},
                    "files": {}
                  },
                  "required": [
                    "company",
                    "spaces",
                    "news",
                    "newsTotal",
                    "files"
                  ]
                }
              }
            }
          }
        },
        "security": [],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/public/kb/<company>\""
          }
        ]
      }
    },
    "/api/v1/public/kb/{company}/pages/{slug}": {
      "get": {
        "tags": [
          "Central de ajuda (sem login)"
        ],
        "summary": "Ver página da Central de ajuda",
        "operationId": "getPublicKbByCompanyPagesBySlug",
        "description": "**Resposta:** `{ company, page: { slug, title, body, updatedAt, space (nome do espaço), crumb: [{ slug, title }], children: [{ slug, title }] }, files }`",
        "parameters": [
          {
            "name": "company",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Padaria Bom Grão"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "boas-vindas"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ company, page: { slug, title, body, updatedAt, space (nome do espaço), crumb: [{ slug, title }], children: [{ slug, title }] }, files }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "company": {},
                    "page": {
                      "type": "object",
                      "properties": {
                        "slug": {
                          "type": "string",
                          "example": "boas-vindas"
                        },
                        "title": {
                          "type": "string",
                          "example": "Pedido 48211"
                        },
                        "body": {
                          "type": "string",
                          "example": "Bom dia, o pedido já saiu?"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "example": "2026-12-01T12:12:00Z"
                        },
                        "space": {
                          "description": "(nome"
                        },
                        "do": {
                          "description": "espaço)"
                        },
                        "crumb": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "slug": {
                                "type": "string",
                                "example": "boas-vindas"
                              },
                              "title": {
                                "type": "string",
                                "example": "Pedido 48211"
                              }
                            },
                            "required": [
                              "slug",
                              "title"
                            ]
                          }
                        },
                        "children": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "slug": {
                                "type": "string",
                                "example": "boas-vindas"
                              },
                              "title": {
                                "type": "string",
                                "example": "Pedido 48211"
                              }
                            },
                            "required": [
                              "slug",
                              "title"
                            ]
                          }
                        }
                      },
                      "required": [
                        "slug",
                        "title",
                        "body",
                        "updatedAt",
                        "space",
                        "do",
                        "crumb",
                        "children"
                      ]
                    },
                    "files": {}
                  },
                  "required": [
                    "company",
                    "page",
                    "files"
                  ]
                }
              }
            }
          }
        },
        "security": [],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/public/kb/<company>/pages/<slug>\""
          }
        ]
      }
    },
    "/api/v1/public/kb/{company}/search": {
      "get": {
        "tags": [
          "Central de ajuda (sem login)"
        ],
        "summary": "Buscar na Central de ajuda",
        "operationId": "getPublicKbByCompanySearch",
        "description": "**Resposta:** `{ company, data: [{ slug, title, snippet }] }` (até 20)",
        "parameters": [
          {
            "name": "company",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Padaria Bom Grão"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ company, data: [{ slug, title, snippet }] }` (até 20)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "company": {},
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "slug": {
                            "type": "string",
                            "example": "boas-vindas"
                          },
                          "title": {
                            "type": "string",
                            "example": "Pedido 48211"
                          },
                          "snippet": {}
                        },
                        "required": [
                          "slug",
                          "title",
                          "snippet"
                        ]
                      }
                    }
                  },
                  "required": [
                    "company",
                    "data"
                  ]
                }
              }
            }
          }
        },
        "security": [],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/public/kb/<company>/search\""
          }
        ]
      }
    },
    "/api/v1/public/kb/{company}/news": {
      "get": {
        "tags": [
          "Central de ajuda (sem login)"
        ],
        "summary": "Ver novidades da Central de ajuda",
        "operationId": "getPublicKbByCompanyNews",
        "description": "**Resposta:** `{ company, data: [{ id, title, tag, body, publishedAt }], total, files }` (até 100)",
        "parameters": [
          {
            "name": "company",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Padaria Bom Grão"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ company, data: [{ id, title, tag, body, publishedAt }], total, files }` (até 100)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "company": {},
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "title": {
                            "type": "string",
                            "example": "Pedido 48211"
                          },
                          "tag": {},
                          "body": {
                            "type": "string",
                            "example": "Bom dia, o pedido já saiu?"
                          },
                          "publishedAt": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "tag",
                          "body",
                          "publishedAt"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "files": {}
                  },
                  "required": [
                    "company",
                    "data",
                    "total",
                    "files"
                  ]
                }
              }
            }
          }
        },
        "security": [],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/public/kb/<company>/news\""
          }
        ]
      }
    },
    "/api/v1/public/kb/{company}/pages/{slug}/feedback": {
      "post": {
        "tags": [
          "Central de ajuda (sem login)"
        ],
        "summary": "Avaliar página da Central de ajuda",
        "operationId": "postPublicKbByCompanyPagesBySlugFeedback",
        "description": "**Resposta:** `204`; corpo `{ helpful: true|false }` (soma em `helpful`)",
        "parameters": [
          {
            "name": "company",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "Padaria Bom Grão"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "boas-vindas"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; corpo `{ helpful: true|false }` (soma em `helpful`)"
          }
        },
        "security": [],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/public/kb/<company>/pages/<slug>/feedback\""
          }
        ]
      }
    },
    "/api/v1/ai/status": {
      "get": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Ver situação da IA",
        "operationId": "getAiStatus",
        "description": "**Resposta:** `{ enabled, reason?, semantic, models: [{ id, name, hint?, provider, providerName, kind? }], defaultModel, defaultProvider, agents: [{ id, name, active, autoStart, suggest, operationIds, numberIds }], calls: { enabled, available, reason? }, audios: { enabled, available, reason? } }` (qualquer pessoa da empresa; a chave da conversa usa). Tudo pela IA em vigor para a empresa (IA da empresa): `models` são os de conversa com chave, `defaultModel` e `defaultProvider` o do atendimento dos agentes (o **Padrão da empresa**). `calls` é a gravação das ligações: `enabled` a empresa ligou, `available` a empresa grava agora (transcrição ligada no Admin, modelo da transcrição das ligações com chave e IA ligada), `reason` por que não. `audios` é a transcrição de áudio: `enabled` a empresa ligou a automática, `available` a empresa tem o modelo de transcrição de áudio com chave e a IA ligada (o painel só mostra o botão Transcrever com ele), `reason` por que não",
        "responses": {
          "200": {
            "description": "`{ enabled, reason?, semantic, models: [{ id, name, hint?, provider, providerName, kind? }], defaultModel, defaultProvider, agents: [{ id, name, active, autoStart, suggest, operationIds, numberIds }], calls: { enabled, available, reason? }, audios: { enabled, available, reason? } }` (qualquer pessoa da empresa; a chave da conversa usa). Tudo pela IA em vigor para a empresa (IA da empresa): `models` são os de conversa com chave, `defaultModel` e `defaultProvider` o do atendimento dos agentes (o **Padrão da empresa**). `calls` é a gravação das ligações: `enabled` a empresa ligou, `available` a empresa grava agora (transcrição ligada no Admin, modelo da transcrição das ligações com chave e IA ligada), `reason` por que não. `audios` é a transcrição de áudio: `enabled` a empresa ligou a automática, `available` a empresa tem o modelo de transcrição de áudio com chave e a IA ligada (o painel só mostra o botão Transcrever com ele), `reason` por que não",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "semantic": {},
                    "models": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "hint": {},
                          "provider": {},
                          "providerName": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "provider",
                          "providerName"
                        ]
                      }
                    },
                    "defaultModel": {},
                    "defaultProvider": {},
                    "agents": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "active": {
                            "type": "boolean"
                          },
                          "autoStart": {},
                          "suggest": {},
                          "operationIds": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "6750a1c2e4b0a1b2c3d4e5f1"
                            }
                          },
                          "numberIds": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "6750a1c2e4b0a1b2c3d4e5f1"
                            }
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "active",
                          "autoStart",
                          "suggest",
                          "operationIds",
                          "numberIds"
                        ]
                      }
                    },
                    "calls": {
                      "type": "object",
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "available": {},
                        "reason": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "enabled",
                        "available"
                      ]
                    },
                    "audios": {
                      "type": "object",
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "available": {},
                        "reason": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "enabled",
                        "available"
                      ]
                    }
                  },
                  "required": [
                    "enabled",
                    "semantic",
                    "models",
                    "defaultModel",
                    "defaultProvider",
                    "agents",
                    "calls",
                    "audios"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/ai/status\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/agents": {
      "get": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Listar agentes de IA",
        "operationId": "getAgents",
        "description": "**Resposta:** `{ data: [Agent] }` por nome",
        "responses": {
          "200": {
            "description": "`{ data: [Agent] }` por nome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Agent"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/agents\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Criar agente de IA",
        "operationId": "postAgents",
        "description": "**Corpo:** `Agent` sem `id` e datas\n\n**Resposta:** `201 Agent`; `422` no campo (`name`, `objective`, `hours`, `handoff.rules`...)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Agent"
              }
            }
          },
          "description": "`Agent` sem `id` e datas"
        },
        "responses": {
          "201": {
            "description": "`201 Agent`; `422` no campo (`name`, `objective`, `hours`, `handoff.rules`...)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/agents\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"id\":\"...\",\"name\":\"Bia\",\"tone\":\"proximo\",\"provider\":\"anthropic\",\"model\":\"claude-haiku-5-5\",\"objective\":\"Tirar dúvidas sobre planos e agendar visitas técnicas\",\"instructions\":\"Chame o cliente pelo nome.\",\"operationIds\":[\"...\"],\"numberIds\":[],\"hours\":{\"always\":false,\"days\":[{\"day\":1,\"start\":\"08:00\",\"end\":\"18:00\"}]},\"kbSpaceIds\":[\"...\"],\"kbPageIds\":[],\"tools\":{\"link\":true,\"tag\":false,\"card\":false,\"resolve\":true},\"handoff\":{\"asksPerson\":true,\"angry\":true,\"valueAboveCents\":50000,\"noAnswer\":true,\"afterMessages\":15,\"rules\":[\"Pedido de reembolso\"],\"message\":\"\"},\"autoStart\":true,\"suggest\":true,\"dailyLimit\":200,\"active\":true,\"createdAt\":\"...\",\"updatedAt\":\"...\"}'"
          }
        ]
      }
    },
    "/api/v1/agents/usage": {
      "get": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Ver uso dos agentes de IA",
        "operationId": "getAgentsUsage",
        "description": "**Resposta:** `{ month, today, total: Uso, agents: { \"<id>\": { today: Uso, month: Uso } }, days: [{ day, answers, costMicros }] (30 dias), limits: { dayLimit, usedToday } }`; o id zerado são os resumos",
        "responses": {
          "200": {
            "description": "`{ month, today, total: Uso, agents: { \"<id>\": { today: Uso, month: Uso } }, days: [{ day, answers, costMicros }] (30 dias), limits: { dayLimit, usedToday } }`; o id zerado são os resumos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "month": {},
                    "today": {},
                    "total": {
                      "$ref": "#/components/schemas/Uso"
                    },
                    "agents": {
                      "type": "object",
                      "properties": {
                        "<id>": {
                          "type": "object",
                          "properties": {
                            "today": {
                              "$ref": "#/components/schemas/Uso"
                            },
                            "month": {
                              "$ref": "#/components/schemas/Uso"
                            }
                          },
                          "required": [
                            "today",
                            "month"
                          ]
                        }
                      },
                      "required": [
                        "<id>"
                      ]
                    },
                    "days": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "day": {},
                          "answers": {},
                          "costMicros": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "day",
                          "answers",
                          "costMicros"
                        ]
                      },
                      "description": "(30 dias)"
                    },
                    "limits": {
                      "type": "object",
                      "properties": {
                        "dayLimit": {},
                        "usedToday": {}
                      },
                      "required": [
                        "dayLimit",
                        "usedToday"
                      ]
                    }
                  },
                  "required": [
                    "month",
                    "today",
                    "total",
                    "agents",
                    "days",
                    "limits"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/agents/usage\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/agents/{id}": {
      "get": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Ver um agente de IA",
        "operationId": "getAgentsById",
        "description": "**Resposta:** `Agent`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Agent`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/agents/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "put": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Alterar agente de IA",
        "operationId": "putAgentsById",
        "description": "**Corpo:** `Agent` sem `id` e datas\n\n**Resposta:** `Agent`; desligar devolve à fila as conversas com ele",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Agent"
              }
            }
          },
          "description": "`Agent` sem `id` e datas"
        },
        "responses": {
          "200": {
            "description": "`Agent`; desligar devolve à fila as conversas com ele",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/agents/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"id\":\"...\",\"name\":\"Bia\",\"tone\":\"proximo\",\"provider\":\"anthropic\",\"model\":\"claude-haiku-5-5\",\"objective\":\"Tirar dúvidas sobre planos e agendar visitas técnicas\",\"instructions\":\"Chame o cliente pelo nome.\",\"operationIds\":[\"...\"],\"numberIds\":[],\"hours\":{\"always\":false,\"days\":[{\"day\":1,\"start\":\"08:00\",\"end\":\"18:00\"}]},\"kbSpaceIds\":[\"...\"],\"kbPageIds\":[],\"tools\":{\"link\":true,\"tag\":false,\"card\":false,\"resolve\":true},\"handoff\":{\"asksPerson\":true,\"angry\":true,\"valueAboveCents\":50000,\"noAnswer\":true,\"afterMessages\":15,\"rules\":[\"Pedido de reembolso\"],\"message\":\"\"},\"autoStart\":true,\"suggest\":true,\"dailyLimit\":200,\"active\":true,\"createdAt\":\"...\",\"updatedAt\":\"...\"}'"
          }
        ]
      },
      "patch": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Ligar ou desligar agente de IA",
        "operationId": "patchAgentsById",
        "description": "**Corpo:** `{ active }`\n\n**Resposta:** `Agent` — liga ou desliga",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "active"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Agent` — liga ou desliga",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/agents/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"active\":true}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Apagar agente de IA",
        "operationId": "deleteAgentsById",
        "description": "**Resposta:** `204`; as conversas com ele voltam para a fila",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; as conversas com ele voltam para a fila"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/agents/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/agents/{id}/conversations": {
      "get": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Listar conversas do agente de IA",
        "operationId": "getAgentsByIdConversations",
        "description": "**Resposta:** `{ total }`: quantas conversas estão com o agente agora (com o bot); o painel diz o número antes de desligar ou apagar",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ total }`: quantas conversas estão com o agente agora (com o bot); o painel diz o número antes de desligar ou apagar",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "total"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/agents/6750a1c2e4b0a1b2c3d4e5f1/conversations\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/agents/test": {
      "post": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Testar agente de IA sem salvar",
        "operationId": "postAgentsTest",
        "description": "**Corpo:** `{ agent: <corpo do POST /agents>, id?, messages }`\n\n**Resposta:** O mesmo de `POST /agents/{id}/test`, com o agente como está na tela, sem gravar nada. `agent` passa pelas conferências do cadastro (`422` no campo). Com `id`, o uso e o limite do dia contam para o agente; sem ele, só os limites da empresa",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agent": {
                    "description": "<corpo do POST /agents>"
                  },
                  "id": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "messages": {}
                },
                "required": [
                  "agent",
                  "messages"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "O mesmo de `POST /agents/{id}/test`, com o agente como está na tela, sem gravar nada. `agent` passa pelas conferências do cadastro (`422` no campo). Com `id`, o uso e o limite do dia contam para o agente; sem ele, só os limites da empresa"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/agents/test\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"id\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/agents/{id}/test": {
      "post": {
        "tags": [
          "Agentes de IA"
        ],
        "summary": "Testar agente de IA",
        "operationId": "postAgentsByIdTest",
        "description": "**Corpo:** `{ messages: [{ role: \"user\"|\"assistant\", text }] }` (1 a 20, começa e termina em `user`)\n\n**Resposta:** `{ reply, sources: [{ id, title, public }], actions: [texto], handoff?, gaps: [texto], usage: { input, output, cacheRead, cacheWrite }, costMicros, model, provider, providerName }` (`provider` e `model` de quem respondeu: o do agente ou a reserva do atendimento). Nada é enviado; conta no uso. `409 ai_off`, `ai_limit` ou `ai_failed`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "type": "string",
                          "enum": [
                            "user",
                            "assistant"
                          ],
                          "example": "user"
                        },
                        "text": {
                          "type": "string",
                          "example": "Bom dia, o pedido já saiu?"
                        }
                      },
                      "required": [
                        "role",
                        "text"
                      ]
                    }
                  }
                },
                "required": [
                  "messages"
                ],
                "description": "(1 a 20, começa e termina em `user`)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ reply, sources: [{ id, title, public }], actions: [texto], handoff?, gaps: [texto], usage: { input, output, cacheRead, cacheWrite }, costMicros, model, provider, providerName }` (`provider` e `model` de quem respondeu: o do agente ou a reserva do atendimento). Nada é enviado; conta no uso. `409 ai_off`, `ai_limit` ou `ai_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "reply": {},
                    "sources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "title": {
                            "type": "string",
                            "example": "Pedido 48211"
                          },
                          "public": {}
                        },
                        "required": [
                          "id",
                          "title",
                          "public"
                        ]
                      }
                    },
                    "actions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "handoff": {},
                    "gaps": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "input": {},
                        "output": {},
                        "cacheRead": {},
                        "cacheWrite": {}
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite"
                      ]
                    },
                    "costMicros": {
                      "type": "integer"
                    },
                    "model": {},
                    "provider": {},
                    "providerName": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "reply",
                    "sources",
                    "actions",
                    "gaps",
                    "usage",
                    "costMicros",
                    "model",
                    "provider",
                    "providerName"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`ai_off`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/agents/6750a1c2e4b0a1b2c3d4e5f1/test\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"messages\":[{\"role\":\"user\",\"text\":\"Bom dia, o pedido já saiu?\"}]}'"
          }
        ]
      }
    },
    "/api/v1/ai/company": {
      "get": {
        "tags": [
          "IA da empresa"
        ],
        "summary": "Ver IA da empresa",
        "operationId": "getAiCompany",
        "description": "**Resposta:** `CompanyAI`",
        "responses": {
          "200": {
            "description": "`CompanyAI`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyAI"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/ai/company\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/ai/company/providers/{provider}": {
      "put": {
        "tags": [
          "IA da empresa"
        ],
        "summary": "Salvar chave do provedor de IA",
        "operationId": "putAiCompanyProvidersByProvider",
        "description": "**Corpo:** `{ key }`\n\n**Resposta:** `CompanyAI` com `test`: guarda a chave (põe o provedor na lista) e consulta o provedor na hora; a chave recusada fica guardada, com `lastTest.ok` falso. `key` vazio apaga a chave e deixa o provedor na lista. `422` em `key` (faltando ou incompleta) ou `provider` (desligado no Admin); `404` provedor desconhecido; `409 no_secrets_key` sem `SECRETS_KEY`",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {}
                },
                "required": [
                  "key"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`CompanyAI` com `test`: guarda a chave (põe o provedor na lista) e consulta o provedor na hora; a chave recusada fica guardada, com `lastTest.ok` falso. `key` vazio apaga a chave e deixa o provedor na lista. `422` em `key` (faltando ou incompleta) ou `provider` (desligado no Admin); `404` provedor desconhecido; `409 no_secrets_key` sem `SECRETS_KEY`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyAI"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`no_secrets_key`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/ai/company/providers/<provider>\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "IA da empresa"
        ],
        "summary": "Apagar chave do provedor de IA",
        "operationId": "deleteAiCompanyProvidersByProvider",
        "description": "**Resposta:** `CompanyAI`: tira o provedor da lista, com a chave. Sem chave nenhuma, a empresa volta para as chaves do WhatzaBot",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`CompanyAI`: tira o provedor da lista, com a chave. Sem chave nenhuma, a empresa volta para as chaves do WhatzaBot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyAI"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/ai/company/providers/<provider>\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/ai/company/providers/{provider}/test": {
      "post": {
        "tags": [
          "IA da empresa"
        ],
        "summary": "Testar chave do provedor de IA",
        "operationId": "postAiCompanyProvidersByProviderTest",
        "description": "**Resposta:** `CompanyAI` com `test`: consulta o provedor com a chave guardada (lista os modelos, sem gastar tokens). `409 no_key` sem chave; `409 key_unreadable` com a chave que não abre",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`CompanyAI` com `test`: consulta o provedor com a chave guardada (lista os modelos, sem gastar tokens). `409 no_key` sem chave; `409 key_unreadable` com a chave que não abre",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyAI"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`no_key`, `key_unreadable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/ai/company/providers/<provider>/test\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/ai/company/uses": {
      "put": {
        "tags": [
          "IA da empresa"
        ],
        "summary": "Escolher usos da IA",
        "operationId": "putAiCompanyUses",
        "description": "**Corpo:** `{ uses }` (os 8 usos, como em `CompanyAI`)\n\n**Resposta:** `CompanyAI`; `422` em `uses.<uso>` ou `uses.<uso>.fallback` com a mensagem para a pessoa (modelo que não serve para o uso, fora da lista, sem a chave da empresa, reserva igual ao modelo ou, no embedding, vetor de outro tamanho). Trocar o modelo de embedding em vigor refaz os vetores do Conhecimento em segundo plano. As transcrições seguem o modelo: `audio` com modelo liga a transcrição automática dos áudios recebidos (`settings.audioTranscribe`), e `transcribe` com modelo liga a gravação, a transcrição e o resumo das ligações (`settings.callTranscribe`); sem modelo, desligam. Ligar sem a transcrição pronta na plataforma: `409 transcribe_unavailable` ou `409 record_unavailable`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "uses": {}
                },
                "required": [
                  "uses"
                ],
                "description": "(os 8 usos, como em `CompanyAI`)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`CompanyAI`; `422` em `uses.<uso>` ou `uses.<uso>.fallback` com a mensagem para a pessoa (modelo que não serve para o uso, fora da lista, sem a chave da empresa, reserva igual ao modelo ou, no embedding, vetor de outro tamanho). Trocar o modelo de embedding em vigor refaz os vetores do Conhecimento em segundo plano. As transcrições seguem o modelo: `audio` com modelo liga a transcrição automática dos áudios recebidos (`settings.audioTranscribe`), e `transcribe` com modelo liga a gravação, a transcrição e o resumo das ligações (`settings.callTranscribe`); sem modelo, desligam. Ligar sem a transcrição pronta na plataforma: `409 transcribe_unavailable` ou `409 record_unavailable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyAI"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`transcribe_unavailable`, `record_unavailable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/ai/company/uses\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/flows": {
      "get": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Listar fluxos",
        "operationId": "getFlows",
        "description": "**Resposta:** `{ data: [Flow sem draft] }`",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ],
              "example": "active"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [Flow sem draft] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/Flow"
                          }
                        ],
                        "description": "sem draft"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/flows\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Criar fluxo",
        "operationId": "postFlows",
        "description": "**Corpo:** `{ name, description? }`\n\n**Resposta:** `201 Flow` com o bloco Gatilho (mensagem nova, 12 h sem repetir)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "description": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Flow` com o bloco Gatilho (mensagem nova, 12 h sem repetir)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/flows\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"description\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/flows/options": {
      "get": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Ver opções para montar fluxos",
        "operationId": "getFlowsOptions",
        "description": "**Resposta:** `{ agents: [Ref], channels: [Ref], models: [AIModel], secrets: [FlowSecret], ai, reason?, default: { provider, model } }`: o que os blocos escolhem (canais do Chat, modelos liberados, credenciais)",
        "responses": {
          "200": {
            "description": "`{ agents: [Ref], channels: [Ref], models: [AIModel], secrets: [FlowSecret], ai, reason?, default: { provider, model } }`: o que os blocos escolhem (canais do Chat, modelos liberados, credenciais)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agents": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ref"
                      }
                    },
                    "channels": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ref"
                      }
                    },
                    "models": {
                      "type": "array",
                      "items": {
                        "description": "AIModel"
                      }
                    },
                    "secrets": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FlowSecret"
                      }
                    },
                    "ai": {},
                    "reason": {
                      "type": "string"
                    },
                    "default": {
                      "type": "object",
                      "properties": {
                        "provider": {},
                        "model": {}
                      },
                      "required": [
                        "provider",
                        "model"
                      ]
                    }
                  },
                  "required": [
                    "agents",
                    "channels",
                    "models",
                    "secrets",
                    "ai",
                    "default"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/flows/options\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/flow-secrets": {
      "get": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Listar segredos dos fluxos",
        "operationId": "getFlowSecrets",
        "description": "**Resposta:** `{ data: [FlowSecret] }` (até 50)",
        "responses": {
          "200": {
            "description": "`{ data: [FlowSecret] }` (até 50)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FlowSecret"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/flow-secrets\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Criar segredo de fluxo",
        "operationId": "postFlowSecrets",
        "description": "**Corpo:** `{ type?, name, header?, value, db? }`\n\n**Resposta:** `201 FlowSecret`; `type` `header` (padrão) ou `database`. No `header`, `header` padrão `Authorization` e `value` obrigatório. No `database`, `db: { engine, host, port?, database?, user?, ssl?, via?, conector?: { id } }` e `value` é a senha (opcional); `port` vazio é a do banco; `via` `server` (padrão: o servidor conecta, só banco na internet) ou `conector` (o Conector `conector.id`, da empresa, conecta da rede dela); `engine: odbc` só com `via: conector`, com o nome da fonte de dados em `database` (sem `PWD=`); endereço do MongoDB com usuário e senha é recusado. O valor e a senha são cifrados. `422` em `name`, `header`, `value`, `type`, `db.engine`, `db.via`, `db.conector`, `db.host`, `db.port`, `db.database`, `db.user`. `409 secrets_full` com 50",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "header": {},
                  "value": {},
                  "db": {}
                },
                "required": [
                  "name",
                  "value"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 FlowSecret`; `type` `header` (padrão) ou `database`. No `header`, `header` padrão `Authorization` e `value` obrigatório. No `database`, `db: { engine, host, port?, database?, user?, ssl?, via?, conector?: { id } }` e `value` é a senha (opcional); `port` vazio é a do banco; `via` `server` (padrão: o servidor conecta, só banco na internet) ou `conector` (o Conector `conector.id`, da empresa, conecta da rede dela); `engine: odbc` só com `via: conector`, com o nome da fonte de dados em `database` (sem `PWD=`); endereço do MongoDB com usuário e senha é recusado. O valor e a senha são cifrados. `422` em `name`, `header`, `value`, `type`, `db.engine`, `db.via`, `db.conector`, `db.host`, `db.port`, `db.database`, `db.user`. `409 secrets_full` com 50",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowSecret"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`secrets_full`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/flow-secrets\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"type\":\"texto\",\"name\":\"Ana Prado\"}'"
          }
        ]
      }
    },
    "/api/v1/flow-secrets/{id}": {
      "patch": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Alterar segredo de fluxo",
        "operationId": "patchFlowSecretsById",
        "description": "**Corpo:** `{ name, header?, value?, db? }`\n\n**Resposta:** `FlowSecret`; o tipo fica o de quando foi criada; `value` vazio mantém o valor ou a senha guardada; o nome novo vai para os rascunhos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "header": {},
                  "value": {},
                  "db": {}
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`FlowSecret`; o tipo fica o de quando foi criada; `value` vazio mantém o valor ou a senha guardada; o nome novo vai para os rascunhos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowSecret"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/flow-secrets/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\"}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Apagar segredo de fluxo",
        "operationId": "deleteFlowSecretsById",
        "description": "**Resposta:** `204`; `409 secret_in_use` se a versão no ar de um fluxo ligado usa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; `409 secret_in_use` se a versão no ar de um fluxo ligado usa"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`secret_in_use`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/flow-secrets/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/flows/{id}": {
      "get": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Ver um fluxo",
        "operationId": "getFlowsById",
        "description": "**Resposta:** `Flow`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Flow`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Alterar fluxo",
        "operationId": "patchFlowsById",
        "description": "**Corpo:** `{ name?, description?, draft?, draftRev?, active? }`\n\n**Resposta:** `Flow` com `dropped?: [{ from, port, to, reason }]` (as ligações que o rascunho tirou); `draft` grava o rascunho (arrumado) e sobe `draftRev`; com `draftRev` diferente do gravado (outro usuário salvou antes), nada é gravado: `409 draft_conflict` com `details.by` e `details.draftRev`; `active: true` sem publicar: `409 flow_unpublished`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "description": {
                    "type": "string"
                  },
                  "draft": {},
                  "draftRev": {},
                  "active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Flow` com `dropped?: [{ from, port, to, reason }]` (as ligações que o rascunho tirou); `draft` grava o rascunho (arrumado) e sobe `draftRev`; com `draftRev` diferente do gravado (outro usuário salvou antes), nada é gravado: `409 draft_conflict` com `details.by` e `details.draftRev`; `active: true` sem publicar: `409 flow_unpublished`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`draft_conflict`, `flow_unpublished`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"description\":\"texto\",\"active\":true}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Apagar fluxo",
        "operationId": "deleteFlowsById",
        "description": "**Resposta:** `204`; para o que anda (a conversa volta para a equipe) e apaga versões e execuções",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; para o que anda (a conversa volta para a equipe) e apaga versões e execuções"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/flows/{id}/duplicate": {
      "post": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Duplicar fluxo",
        "operationId": "postFlowsByIdDuplicate",
        "description": "**Resposta:** `201 Flow` (rascunho \"Cópia de …\", desligado)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "`201 Flow` (rascunho \"Cópia de …\", desligado)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1/duplicate\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/flows/{id}/check": {
      "post": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Conferir fluxo sem publicar",
        "operationId": "postFlowsByIdCheck",
        "description": "**Corpo:** `{ graph? }` (sem ele, o rascunho gravado)\n\n**Resposta:** `{ ok, problems: [{ nodeId?, message }], dropped: [{ from, port, to, reason }] }`: todos os problemas de uma vez, sem gravar nem publicar",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "graph": {}
                },
                "description": "(sem ele, o rascunho gravado)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ ok, problems: [{ nodeId?, message }], dropped: [{ from, port, to, reason }] }`: todos os problemas de uma vez, sem gravar nem publicar",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {},
                    "problems": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "nodeId": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "message": {
                            "type": "string",
                            "example": "Bom dia, o pedido já saiu?"
                          }
                        },
                        "required": [
                          "message"
                        ]
                      }
                    },
                    "dropped": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "from": {},
                          "port": {},
                          "to": {
                            "type": "string",
                            "example": "+5554999990000"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "from",
                          "port",
                          "to",
                          "reason"
                        ]
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "problems",
                    "dropped"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1/check\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/flows/{id}/arrange": {
      "post": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Arrumar os blocos do fluxo",
        "operationId": "postFlowsByIdArrange",
        "description": "**Corpo:** `{ graph? }` (sem ele, o rascunho gravado)\n\n**Resposta:** `{ graph }` com os blocos arrumados em colunas (`ArrangeGraph`), sem gravar",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "graph": {}
                },
                "description": "(sem ele, o rascunho gravado)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ graph }` com os blocos arrumados em colunas (`ArrangeGraph`), sem gravar",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "graph": {}
                  },
                  "required": [
                    "graph"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1/arrange\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/flows/{id}/publish": {
      "post": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Publicar fluxo",
        "operationId": "postFlowsByIdPublish",
        "description": "**Corpo:** `{ note? }`\n\n**Resposta:** `Flow` na versão nova; a primeira liga. `409 flow_invalid` com `details.node` (o primeiro bloco com problema) e `details.problems` (`[{ nodeId?, message }]`, todos)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "note": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Flow` na versão nova; a primeira liga. `409 flow_invalid` com `details.node` (o primeiro bloco com problema) e `details.problems` (`[{ nodeId?, message }]`, todos)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`flow_invalid`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1/publish\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"note\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/flows/{id}/simulate": {
      "post": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Simular fluxo",
        "operationId": "postFlowsByIdSimulate",
        "description": "**Corpo:** `{ graph?, state?, text, timeout?, real?, node?, vars?, contact?: { name, tags } }`\n\n**Resposta:** `{ outputs: [{ kind: \"bot\"|\"note\"|\"error\", text, options?, file?, request? }], steps, state: { node, vars, tags, waiting, steps, done, log } }`; sem `state`, começa pelo gatilho com `text`; `real` chama a IA e os endereços de verdade; `node` testa só aquele bloco com `vars`; sem `real`, o bloco Chamar endereço vem com `request: { method, url, headers, body?, problem? }` (a chamada que faria, com a credencial mascarada); nada é gravado nem mandado ao WhatsApp",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "graph": {},
                  "state": {},
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "timeout": {},
                  "real": {},
                  "node": {},
                  "vars": {},
                  "contact": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "example": "Ana Prado"
                      },
                      "tags": {}
                    },
                    "required": [
                      "name",
                      "tags"
                    ]
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ outputs: [{ kind: \"bot\"|\"note\"|\"error\", text, options?, file?, request? }], steps, state: { node, vars, tags, waiting, steps, done, log } }`; sem `state`, começa pelo gatilho com `text`; `real` chama a IA e os endereços de verdade; `node` testa só aquele bloco com `vars`; sem `real`, o bloco Chamar endereço vem com `request: { method, url, headers, body?, problem? }` (a chamada que faria, com a credencial mascarada); nada é gravado nem mandado ao WhatsApp",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "outputs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "bot",
                              "note",
                              "error"
                            ],
                            "example": "bot"
                          },
                          "text": {
                            "type": "string",
                            "example": "Bom dia, o pedido já saiu?"
                          },
                          "options": {},
                          "file": {},
                          "request": {}
                        },
                        "required": [
                          "kind",
                          "text"
                        ]
                      }
                    },
                    "steps": {},
                    "state": {
                      "type": "object",
                      "properties": {
                        "node": {},
                        "vars": {},
                        "tags": {},
                        "waiting": {},
                        "steps": {},
                        "done": {},
                        "log": {}
                      },
                      "required": [
                        "node",
                        "vars",
                        "tags",
                        "waiting",
                        "steps",
                        "done",
                        "log"
                      ]
                    }
                  },
                  "required": [
                    "outputs",
                    "steps",
                    "state"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1/simulate\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\",\"contact\":{\"name\":\"Ana Prado\"}}'"
          }
        ]
      }
    },
    "/api/v1/flows/{id}/versions": {
      "get": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Listar versões do fluxo",
        "operationId": "getFlowsByIdVersions",
        "description": "**Resposta:** `{ data: [{ id, flowId, version, name, note?, author, at }] }` (até 100, sem o desenho)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [{ id, flowId, version, name, note?, author, at }] }` (até 100, sem o desenho)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "flowId": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          },
                          "version": {
                            "type": "integer"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "note": {
                            "type": "string"
                          },
                          "author": {},
                          "at": {
                            "type": "string",
                            "format": "date-time",
                            "example": "2026-12-01T12:12:00Z"
                          }
                        },
                        "required": [
                          "id",
                          "flowId",
                          "version",
                          "name",
                          "author",
                          "at"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1/versions\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/flows/{id}/versions/{n}": {
      "get": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Ver uma versão do fluxo",
        "operationId": "getFlowsByIdVersionsByN",
        "description": "**Resposta:** `FlowVersion`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`FlowVersion`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowVersion"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1/versions/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/flows/{id}/versions/{n}/restore": {
      "post": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Restaurar versão do fluxo",
        "operationId": "postFlowsByIdVersionsByNRestore",
        "description": "**Resposta:** `Flow` com o desenho da versão no rascunho",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Flow` com o desenho da versão no rascunho",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1/versions/6750a1c2e4b0a1b2c3d4e5f1/restore\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/flows/{id}/runs": {
      "get": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Listar execuções do fluxo",
        "operationId": "getFlowsByIdRuns",
        "description": "**Resposta:** paginada, `FlowRun` sem `vars` e `steps`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "live",
                "done",
                "stopped",
                "failed"
              ],
              "example": "live"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "paginada, `FlowRun` sem `vars` e `steps`",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Paginada"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/FlowRun"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/flows/6750a1c2e4b0a1b2c3d4e5f1/runs\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/flow-runs/{id}": {
      "get": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Ver uma execução de fluxo",
        "operationId": "getFlowRunsById",
        "description": "**Resposta:** `FlowRun`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`FlowRun`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowRun"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/flow-runs/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/flow-runs/{id}/stop": {
      "post": {
        "tags": [
          "Fluxos"
        ],
        "summary": "Parar execução de fluxo",
        "operationId": "postFlowRunsByIdStop",
        "description": "**Resposta:** `FlowRun` parada; a conversa volta para a equipe",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`FlowRun` parada; a conversa volta para a equipe",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowRun"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/flow-runs/6750a1c2e4b0a1b2c3d4e5f1/stop\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/automations": {
      "get": {
        "tags": [
          "Automações"
        ],
        "summary": "Listar automações",
        "operationId": "getAutomations",
        "description": "**Resposta:** `{ data: [Automation sem draft] }`",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ],
              "example": "active"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [Automation sem draft] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/Automation"
                          }
                        ],
                        "description": "sem draft"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/automations\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Automações"
        ],
        "summary": "Criar automação",
        "operationId": "postAutomations",
        "description": "**Corpo:** `{ name, description?, start?: \"event\"|\"hook\" }`\n\n**Resposta:** `201 Automation` com o bloco de começo (mensagem no chat interno, ou o endereço próprio com o token)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "description": {
                    "type": "string"
                  },
                  "start": {
                    "type": "string",
                    "enum": [
                      "event",
                      "hook"
                    ],
                    "example": "event"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Automation` com o bloco de começo (mensagem no chat interno, ou o endereço próprio com o token)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Automation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/automations\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"description\":\"texto\",\"start\":\"event\"}'"
          }
        ]
      }
    },
    "/api/v1/automations/options": {
      "get": {
        "tags": [
          "Automações"
        ],
        "summary": "Ver opções para montar automações",
        "operationId": "getAutomationsOptions",
        "description": "**Resposta:** `{ channels, numbers, operations, keys, users, areas, profiles, secrets, mail, hookBase }`: o que os blocos escolhem",
        "responses": {
          "200": {
            "description": "`{ channels, numbers, operations, keys, users, areas, profiles, secrets, mail, hookBase }`: o que os blocos escolhem",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "channels": {},
                    "numbers": {},
                    "operations": {},
                    "keys": {},
                    "users": {},
                    "areas": {},
                    "profiles": {},
                    "secrets": {},
                    "mail": {},
                    "hookBase": {}
                  },
                  "required": [
                    "channels",
                    "numbers",
                    "operations",
                    "keys",
                    "users",
                    "areas",
                    "profiles",
                    "secrets",
                    "mail",
                    "hookBase"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/automations/options\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/automations/{id}": {
      "get": {
        "tags": [
          "Automações"
        ],
        "summary": "Ver uma automação",
        "operationId": "getAutomationsById",
        "description": "**Resposta:** `Automation`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Automation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Automation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/automations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Automações"
        ],
        "summary": "Alterar automação",
        "operationId": "patchAutomationsById",
        "description": "**Corpo:** `{ name?, description?, draft?, active? }`\n\n**Resposta:** `Automation`; `draft` grava o rascunho (arrumado; o bloco do endereço ganha o token); `active: true` sem publicar: `409 automation_unpublished`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "description": {
                    "type": "string"
                  },
                  "draft": {},
                  "active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Automation`; `draft` grava o rascunho (arrumado; o bloco do endereço ganha o token); `active: true` sem publicar: `409 automation_unpublished`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Automation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`automation_unpublished`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/automations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"description\":\"texto\",\"active\":true}'"
          }
        ]
      },
      "delete": {
        "tags": [
          "Automações"
        ],
        "summary": "Apagar automação",
        "operationId": "deleteAutomationsById",
        "description": "**Resposta:** `204`; apaga versões e execuções",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; apaga versões e execuções"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/automations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/automations/{id}/duplicate": {
      "post": {
        "tags": [
          "Automações"
        ],
        "summary": "Duplicar automação",
        "operationId": "postAutomationsByIdDuplicate",
        "description": "**Resposta:** `201 Automation` (rascunho \"Cópia de …\", com outro endereço e outro robô)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "`201 Automation` (rascunho \"Cópia de …\", com outro endereço e outro robô)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Automation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/automations/6750a1c2e4b0a1b2c3d4e5f1/duplicate\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/automations/{id}/publish": {
      "post": {
        "tags": [
          "Automações"
        ],
        "summary": "Publicar automação",
        "operationId": "postAutomationsByIdPublish",
        "description": "**Corpo:** `{ note? }`\n\n**Resposta:** `Automation` na versão nova; a primeira liga. `409 automation_invalid` com `details.node`; `409 hook_taken`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "note": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Automation` na versão nova; a primeira liga. `409 automation_invalid` com `details.node`; `409 hook_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Automation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`automation_invalid`, `hook_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/automations/6750a1c2e4b0a1b2c3d4e5f1/publish\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"note\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/automations/{id}/test": {
      "post": {
        "tags": [
          "Automações"
        ],
        "summary": "Testar automação",
        "operationId": "postAutomationsByIdTest",
        "description": "**Corpo:** `{ vars? }`\n\n**Resposta:** `201 AutoRun`: roda a versão publicada com os dados de exemplo do evento, de verdade",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "vars": {}
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 AutoRun`: roda a versão publicada com os dados de exemplo do evento, de verdade",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutoRun"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/automations/6750a1c2e4b0a1b2c3d4e5f1/test\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/automations/{id}/versions": {
      "get": {
        "tags": [
          "Automações"
        ],
        "summary": "Listar versões da automação",
        "operationId": "getAutomationsByIdVersions",
        "description": "**Resposta:** `{ data: [FlowVersion sem graph] }`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [FlowVersion sem graph] }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/FlowVersion"
                          }
                        ],
                        "description": "sem graph"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/automations/6750a1c2e4b0a1b2c3d4e5f1/versions\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/automations/{id}/versions/{n}/restore": {
      "post": {
        "tags": [
          "Automações"
        ],
        "summary": "Restaurar versão da automação",
        "operationId": "postAutomationsByIdVersionsByNRestore",
        "description": "**Resposta:** `Automation` com o desenho da versão no rascunho",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Automation` com o desenho da versão no rascunho",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Automation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/automations/6750a1c2e4b0a1b2c3d4e5f1/versions/6750a1c2e4b0a1b2c3d4e5f1/restore\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/automations/{id}/runs": {
      "get": {
        "tags": [
          "Automações"
        ],
        "summary": "Listar execuções da automação",
        "operationId": "getAutomationsByIdRuns",
        "description": "**Resposta:** paginada, `AutoRun` sem `vars`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "live",
                "done",
                "stopped",
                "failed"
              ],
              "example": "live"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "paginada, `AutoRun` sem `vars`",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Paginada"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/AutoRun"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/automations/6750a1c2e4b0a1b2c3d4e5f1/runs\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/automation-runs/{id}": {
      "get": {
        "tags": [
          "Automações"
        ],
        "summary": "Ver uma execução de automação",
        "operationId": "getAutomationRunsById",
        "description": "**Resposta:** `AutoRun`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`AutoRun`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutoRun"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/automation-runs/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/automation-runs/{id}/stop": {
      "post": {
        "tags": [
          "Automações"
        ],
        "summary": "Parar execução de automação",
        "operationId": "postAutomationRunsByIdStop",
        "description": "**Resposta:** `AutoRun` parada; `409 run_ended` se já terminou",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`AutoRun` parada; `409 run_ended` se já terminou",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutoRun"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`run_ended`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/automation-runs/6750a1c2e4b0a1b2c3d4e5f1/stop\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/chat/bots": {
      "get": {
        "tags": [
          "Automações"
        ],
        "summary": "Listar robôs do chat interno",
        "operationId": "getChatBots",
        "description": "**Corpo:** — (todos)\n\n**Resposta:** `{ data: [{ bot, name, word }] }`: os robôs ligados, para a lista de menções do chat interno",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "— (todos)"
              }
            }
          },
          "description": "— (todos)"
        },
        "responses": {
          "200": {
            "description": "`{ data: [{ bot, name, word }] }`: os robôs ligados, para a lista de menções do chat interno",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "bot": {},
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "word": {}
                        },
                        "required": [
                          "bot",
                          "name",
                          "word"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/chat/bots\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/hooks/{token}": {
      "post": {
        "tags": [
          "Automações"
        ],
        "summary": "Disparar automação por endereço próprio",
        "operationId": "postHooksByToken",
        "description": "**Corpo:** qualquer JSON (até 64 KB), com `Authorization: Bearer wzb_…` (sem sessão)\n\n**Resposta:** `202 { runId, status: \"accepted\" }`; `401` chave inválida, `403 key_not_allowed`, `404 hook_not_found`, `422` corpo inválido, `429` limite por minuto (`Retry-After: 60`)",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "qualquer JSON (até 64 KB), com `Authorization: Bearer wzb_…` (sem sessão)"
              }
            }
          },
          "description": "qualquer JSON (até 64 KB), com `Authorization: Bearer wzb_…` (sem sessão)"
        },
        "responses": {
          "202": {
            "description": "`202 { runId, status: \"accepted\" }`; `401` chave inválida, `403 key_not_allowed`, `404 hook_not_found`, `422` corpo inválido, `429` limite por minuto (`Retry-After: 60`)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "runId": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "accepted"
                      ],
                      "example": "accepted"
                    }
                  },
                  "required": [
                    "runId",
                    "status"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`key_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`hook_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "429": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/hooks/<token>\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/campaigns": {
      "get": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Listar campanhas e avisos",
        "operationId": "getCampaigns",
        "description": "**Resposta:** paginada, `Campaign`; `active` = enviando, agendada ou pausada",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "notice",
                "campaign"
              ],
              "example": "notice"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "paginada, `Campaign`; `active` = enviando, agendada ou pausada",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Paginada"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Campaign"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/campaigns\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Criar campanha ou aviso",
        "operationId": "postCampaigns",
        "description": "**Corpo:** `{ notice?, name, numberId?, audience?, message?, pace? }`\n\n**Resposta:** `201 Campaign` em rascunho (ritmo padrão, linha de saída ligada)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "notice": {},
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "numberId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "audience": {},
                  "message": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "pace": {}
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Campaign` em rascunho (ritmo padrão, linha de saída ligada)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/campaigns\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"numberId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"message\":\"Bom dia, o pedido já saiu?\"}'"
          }
        ]
      }
    },
    "/api/v1/campaigns/summary": {
      "get": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Ver resumo das campanhas",
        "operationId": "getCampaignsSummary",
        "description": "**Resposta:** `{ sentMonth, readMonth, repliedMonth, running, scheduled, optOuts }`",
        "responses": {
          "200": {
            "description": "`{ sentMonth, readMonth, repliedMonth, running, scheduled, optOuts }`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sentMonth": {},
                    "readMonth": {},
                    "repliedMonth": {},
                    "running": {},
                    "scheduled": {},
                    "optOuts": {}
                  },
                  "required": [
                    "sentMonth",
                    "readMonth",
                    "repliedMonth",
                    "running",
                    "scheduled",
                    "optOuts"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/campaigns/summary\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/audience": {
      "post": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Calcular público da campanha",
        "operationId": "postCampaignsAudience",
        "description": "**Corpo:** `{ audience }`\n\n**Resposta:** `{ total, optedOut }` (quem recebe e quantos ficaram de fora por ter pedido para sair)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "audience": {}
                },
                "required": [
                  "audience"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ total, optedOut }` (quem recebe e quantos ficaram de fora por ter pedido para sair)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "optedOut": {}
                  },
                  "required": [
                    "total",
                    "optedOut"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/campaigns/audience\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/campaigns/import": {
      "post": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Importar contatos para campanha",
        "operationId": "postCampaignsImport",
        "description": "**Corpo:** `{ rows: [{ name, phone, email?, city? }], tag? }` (`tag` até 40 letras, cortada no resto)\n\n**Resposta:** `{ contactIds, created, existing, optedOut, invalid: [{ line, reason }] }` (até 5.000 linhas)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "example": "Ana Prado"
                        },
                        "phone": {
                          "type": "string",
                          "example": "5554999990000"
                        },
                        "email": {
                          "type": "string",
                          "example": "ana@exemplo.com.br"
                        },
                        "city": {}
                      },
                      "required": [
                        "name",
                        "phone"
                      ]
                    }
                  },
                  "tag": {}
                },
                "required": [
                  "rows"
                ],
                "description": "(`tag` até 40 letras, cortada no resto)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ contactIds, created, existing, optedOut, invalid: [{ line, reason }] }` (até 5.000 linhas)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contactIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "example": "6750a1c2e4b0a1b2c3d4e5f1"
                      }
                    },
                    "created": {},
                    "existing": {},
                    "optedOut": {},
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "line": {},
                          "reason": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "line",
                          "reason"
                        ]
                      }
                    }
                  },
                  "required": [
                    "contactIds",
                    "created",
                    "existing",
                    "optedOut",
                    "invalid"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/campaigns/import\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"rows\":[{\"name\":\"Ana Prado\",\"phone\":\"5554999990000\",\"email\":\"ana@exemplo.com.br\"}]}'"
          }
        ]
      }
    },
    "/api/v1/campaigns/templates": {
      "get": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Listar modelos de mensagem da conexão",
        "operationId": "getCampaignsTemplates",
        "description": "**Resposta:** `{ data: [{ name, language, category, body, vars }] }`: os modelos aprovados do número oficial com variáveis só no corpo (número por QR: lista vazia)",
        "parameters": [
          {
            "name": "numberId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [{ name, language, category, body, vars }] }`: os modelos aprovados do número oficial com variáveis só no corpo (número por QR: lista vazia)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "language": {},
                          "category": {},
                          "body": {
                            "type": "string",
                            "example": "Bom dia, o pedido já saiu?"
                          },
                          "vars": {}
                        },
                        "required": [
                          "name",
                          "language",
                          "category",
                          "body",
                          "vars"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/campaigns/templates\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/opt-outs": {
      "get": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Listar contatos que pediram para sair",
        "operationId": "getCampaignsOptOuts",
        "description": "**Resposta:** paginada, `CampaignOptOut`, do mais novo",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "paginada, `CampaignOptOut`, do mais novo",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Paginada"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/CampaignOptOut"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/campaigns/opt-outs\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/opt-outs/{id}": {
      "delete": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Tirar contato da lista de saída",
        "operationId": "deleteCampaignsOptOutsById",
        "description": "**Resposta:** `204` (o contato volta a receber)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204` (o contato volta a receber)"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/campaigns/opt-outs/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/{id}": {
      "get": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Ver uma campanha",
        "operationId": "getCampaignsById",
        "description": "**Resposta:** `Campaign`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Campaign`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Alterar campanha",
        "operationId": "patchCampaignsById",
        "description": "**Corpo:** os campos do `POST`\n\n**Resposta:** `Campaign`. Rascunho e agendada mudam tudo; pausada depois de começar só `name`, `message` e `pace` (`409 campaign_started`); enviando, `409 campaign_running`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "os campos do `POST`"
              }
            }
          },
          "description": "os campos do `POST`"
        },
        "responses": {
          "200": {
            "description": "`Campaign`. Rascunho e agendada mudam tudo; pausada depois de começar só `name`, `message` e `pace` (`409 campaign_started`); enviando, `409 campaign_running`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`campaign_started`, `campaign_running`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Apagar campanha",
        "operationId": "deleteCampaignsById",
        "description": "**Resposta:** `204`; só rascunho, concluída ou cancelada (`409 campaign_running`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; só rascunho, concluída ou cancelada (`409 campaign_running`)"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`campaign_running`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/{id}/duplicate": {
      "post": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Duplicar campanha",
        "operationId": "postCampaignsByIdDuplicate",
        "description": "**Resposta:** `201 Campaign` em rascunho",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "`201 Campaign` em rascunho",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1/duplicate\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/{id}/check": {
      "post": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Conferir campanha sem começar",
        "operationId": "postCampaignsByIdCheck",
        "description": "**Resposta:** `{ ok, problems: [{ field, message }], recipients, optedOut }`: confere a campanha gravada sem começar (todos os problemas, inclusive já começada e público vazio) e quantos contatos vão receber",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ ok, problems: [{ field, message }], recipients, optedOut }`: confere a campanha gravada sem começar (todos os problemas, inclusive já começada e público vazio) e quantos contatos vão receber",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {},
                    "problems": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {},
                          "message": {
                            "type": "string",
                            "example": "Bom dia, o pedido já saiu?"
                          }
                        },
                        "required": [
                          "field",
                          "message"
                        ]
                      }
                    },
                    "recipients": {},
                    "optedOut": {}
                  },
                  "required": [
                    "ok",
                    "problems",
                    "recipients",
                    "optedOut"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1/check\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/{id}/start": {
      "post": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Iniciar campanha",
        "operationId": "postCampaignsByIdStart",
        "description": "**Corpo:** `{ at? }`\n\n**Resposta:** `Campaign` enviando (ou agendada, com `at`). `at` que já passou dá `422` em `at` (\"Escolha uma hora daqui para a frente.\"); `at` ilegível, `422` em `at`. Na agendada, chamar de novo com outro `at` reagenda. `422` no campo que falta; `409 audience_empty`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "at": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Campaign` enviando (ou agendada, com `at`). `at` que já passou dá `422` em `at` (\"Escolha uma hora daqui para a frente.\"); `at` ilegível, `422` em `at`. Na agendada, chamar de novo com outro `at` reagenda. `422` no campo que falta; `409 audience_empty`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`audience_empty`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1/start\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"at\":\"2026-12-01T12:12:00Z\"}'"
          }
        ]
      }
    },
    "/api/v1/campaigns/{id}/pause": {
      "post": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Pausar campanha",
        "operationId": "postCampaignsByIdPause",
        "description": "**Resposta:** `Campaign` pausada",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Campaign` pausada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1/pause\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/{id}/resume": {
      "post": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Retomar campanha",
        "operationId": "postCampaignsByIdResume",
        "description": "**Resposta:** `Campaign` enviando",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Campaign` enviando",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1/resume\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/{id}/cancel": {
      "post": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Cancelar campanha",
        "operationId": "postCampaignsByIdCancel",
        "description": "**Resposta:** `Campaign` cancelada (quem faltava fica sem receber)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Campaign` cancelada (quem faltava fica sem receber)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1/cancel\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/campaigns/{id}/sends": {
      "get": {
        "tags": [
          "Campanhas e avisos"
        ],
        "summary": "Listar envios da campanha",
        "operationId": "getCampaignsByIdSends",
        "description": "**Resposta:** paginada, `CampaignSend` na ordem da fila",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "sent",
                "delivered",
                "read",
                "replied",
                "failed",
                "skipped",
                "optout",
                "canceled"
              ],
              "example": "pending"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "example": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "paginada, `CampaignSend` na ordem da fila",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Paginada"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/CampaignSend"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/campaigns/6750a1c2e4b0a1b2c3d4e5f1/sends\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/imports": {
      "get": {
        "tags": [
          "Importar dados"
        ],
        "summary": "Listar importações",
        "operationId": "getImports",
        "description": "**Resposta:** `[Import]`, as 50 mais novas, sem `numbers`, `users`, `departments`, `tags`, `customFields` e `skipped`",
        "responses": {
          "200": {
            "description": "`[Import]`, as 50 mais novas, sem `numbers`, `users`, `departments`, `tags`, `customFields` e `skipped`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Import"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/imports\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Importar dados"
        ],
        "summary": "Criar importação",
        "operationId": "postImports",
        "description": "**Corpo:** `{ address, token }`\n\n**Resposta:** `201 Import` em `reading`. `422` em `address` (fora do Digisac ou sem resposta) ou `token` (recusado); `409 import_running` com outra em andamento",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {},
                  "token": {
                    "type": "string"
                  }
                },
                "required": [
                  "address",
                  "token"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 Import` em `reading`. `422` em `address` (fora do Digisac ou sem resposta) ou `token` (recusado); `409 import_running` com outra em andamento",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Import"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`import_running`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/imports\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"token\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/imports/{id}": {
      "get": {
        "tags": [
          "Importar dados"
        ],
        "summary": "Ver uma importação",
        "operationId": "getImportsById",
        "description": "**Resposta:** `Import`. `404 import_not_found`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Import`. `404 import_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Import"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`import_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/imports/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "put": {
        "tags": [
          "Importar dados"
        ],
        "summary": "Ajustar correspondência dos dados importados",
        "operationId": "putImportsById",
        "description": "**Corpo:** `{ numbers?, users?, departments?, tags?, customFields? }` (a lista que mudou)\n\n**Resposta:** `Import`. Só em `review` (`409 import_changed`). `422` no campo da lista (escolha sem o item daqui, conexão sem telefone para criar, usuário sem e-mail para criar)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "numbers": {},
                  "users": {},
                  "departments": {},
                  "tags": {},
                  "customFields": {}
                },
                "description": "(a lista que mudou)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Import`. Só em `review` (`409 import_changed`). `422` no campo da lista (escolha sem o item daqui, conexão sem telefone para criar, usuário sem e-mail para criar)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Import"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`import_changed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/imports/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/imports/{id}/selection": {
      "put": {
        "tags": [
          "Importar dados"
        ],
        "summary": "Escolher o que importar",
        "operationId": "putImportsByIdSelection",
        "description": "**Corpo:** `{ kinds?, since?, files?, complete?, load? }` (só o que mudou; `since` zero ou antes do primeiro chamado traz todos; `load: true` começa a leitura)\n\n**Resposta:** `Import`. Só em `choose` (`409 import_changed`). `422` em `kinds` com nada marcado",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kinds": {},
                  "since": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2026-12-01T12:12:00Z"
                  },
                  "files": {},
                  "complete": {},
                  "load": {}
                },
                "description": "(só o que mudou; `since` zero ou antes do primeiro chamado traz todos; `load: true` começa a leitura)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Import`. Só em `choose` (`409 import_changed`). `422` em `kinds` com nada marcado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Import"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`import_changed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/imports/6750a1c2e4b0a1b2c3d4e5f1/selection\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"since\":\"2026-12-01T12:12:00Z\"}'"
          }
        ]
      }
    },
    "/api/v1/imports/{id}/records": {
      "get": {
        "tags": [
          "Importar dados"
        ],
        "summary": "Listar registros da importação",
        "operationId": "getImportsByIdRecords",
        "description": "**Corpo:** `?kind=&action=&q=&page=&pageSize=` (sem `kind`: todos)\n\n**Resposta:** `{ data: [ImportRecord], meta }`. O chamado mais novo primeiro; os outros pelo nome",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "`?kind=&action=&q=&page=&pageSize=` (sem `kind`: todos)"
              }
            }
          },
          "description": "`?kind=&action=&q=&page=&pageSize=` (sem `kind`: todos)"
        },
        "responses": {
          "200": {
            "description": "`{ data: [ImportRecord], meta }`. O chamado mais novo primeiro; os outros pelo nome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ImportRecord"
                      }
                    },
                    "meta": {}
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/imports/6750a1c2e4b0a1b2c3d4e5f1/records\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/imports/{id}/records/{rid}": {
      "put": {
        "tags": [
          "Importar dados"
        ],
        "summary": "Escolher o que fazer com o registro",
        "operationId": "putImportsByIdRecordsByRid",
        "description": "**Corpo:** `{ action: \"create\" | \"update\" | \"skip\" | \"auto\", targetId? }` (`update` pede o contato daqui; `auto` volta ao sugerido)\n\n**Resposta:** `{ record, draft }`. Só em `review`. `422` em `action` (item que não pode vir) ou `targetId` (contato que não está mais aqui ou grupo); `404 import_record_not_found`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "rid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "create",
                      "update",
                      "skip",
                      "auto"
                    ],
                    "example": "create"
                  },
                  "targetId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "action"
                ],
                "description": "(`update` pede o contato daqui; `auto` volta ao sugerido)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{ record, draft }`. Só em `review`. `422` em `action` (item que não pode vir) ou `targetId` (contato que não está mais aqui ou grupo); `404 import_record_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "record": {},
                    "draft": {}
                  },
                  "required": [
                    "record",
                    "draft"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`import_record_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.whatzabot.com.br/api/v1/imports/6750a1c2e4b0a1b2c3d4e5f1/records/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"action\":\"create\",\"targetId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/imports/{id}/start": {
      "post": {
        "tags": [
          "Importar dados"
        ],
        "summary": "Iniciar importação",
        "operationId": "postImportsByIdStart",
        "description": "**Resposta:** `Import` em `importing`. `409 import_pending` (contato em Decidir), `409 plan_limit` (passa do plano), `409 import_changed`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Import` em `importing`. `409 import_pending` (contato em Decidir), `409 plan_limit` (passa do plano), `409 import_changed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Import"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`import_pending`, `plan_limit`, `import_changed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/imports/6750a1c2e4b0a1b2c3d4e5f1/start\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/imports/{id}/cancel": {
      "post": {
        "tags": [
          "Importar dados"
        ],
        "summary": "Cancelar importação",
        "operationId": "postImportsByIdCancel",
        "description": "**Resposta:** `Import` em `canceled` (o que já entrou fica). `409 import_changed` quando já terminou",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Import` em `canceled` (o que já entrou fica). `409 import_changed` quando já terminou",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Import"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`import_changed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/imports/6750a1c2e4b0a1b2c3d4e5f1/cancel\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integrations/keys": {
      "get": {
        "tags": [
          "Integração"
        ],
        "summary": "Listar chaves de integração",
        "operationId": "getIntegrationsKeys",
        "description": "**Resposta:** `{ data: [IntegrationKey] }`, por nome",
        "responses": {
          "200": {
            "description": "`{ data: [IntegrationKey] }`, por nome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegrationKey"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integrations/keys\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      },
      "post": {
        "tags": [
          "Integração"
        ],
        "summary": "Criar chave de integração",
        "operationId": "postIntegrationsKeys",
        "description": "**Corpo:** `{ name, scopes, numberId, recipients: [{ phone, name? }], perMinute, enabled }`\n\n**Resposta:** `201 { key: IntegrationKey, secret }`. `422` em `name` (até 60 letras), `scopes` (pelo menos um; sem o campo, `[\"send\"]`), `perMinute` (1 a 60; 0 vira 10) e, com `send`, `numberId` (número por QR Code da empresa, num Conector) e `recipients` (1 a 10, só dígitos com DDI, 10 a 15, sem repetir o mesmo celular). Sem `send`, `numberId` e `recipients` são ignorados",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "scopes": {},
                  "numberId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "recipients": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "phone": {
                          "type": "string",
                          "example": "5554999990000"
                        },
                        "name": {
                          "type": "string",
                          "example": "Ana Prado"
                        }
                      },
                      "required": [
                        "phone"
                      ]
                    }
                  },
                  "perMinute": {
                    "type": "integer"
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "name",
                  "scopes",
                  "numberId",
                  "recipients",
                  "perMinute",
                  "enabled"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 { key: IntegrationKey, secret }`. `422` em `name` (até 60 letras), `scopes` (pelo menos um; sem o campo, `[\"send\"]`), `perMinute` (1 a 60; 0 vira 10) e, com `send`, `numberId` (número por QR Code da empresa, num Conector) e `recipients` (1 a 10, só dígitos com DDI, 10 a 15, sem repetir o mesmo celular). Sem `send`, `numberId` e `recipients` são ignorados",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "$ref": "#/components/schemas/IntegrationKey"
                    },
                    "secret": {}
                  },
                  "required": [
                    "key",
                    "secret"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/integrations/keys\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"numberId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"recipients\":[{\"phone\":\"5554999990000\",\"name\":\"Ana Prado\"}],\"perMinute\":0,\"enabled\":true}'"
          }
        ]
      }
    },
    "/api/v1/integrations/keys/{id}": {
      "patch": {
        "tags": [
          "Integração"
        ],
        "summary": "Alterar chave de integração",
        "operationId": "patchIntegrationsKeysById",
        "description": "**Corpo:** o mesmo do `POST` (inteiro)\n\n**Resposta:** `IntegrationKey` (o texto da chave não muda; sem `send`, a conexão e os telefones saem). `404 key_not_found`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "o mesmo do `POST` (inteiro)"
              }
            }
          },
          "description": "o mesmo do `POST` (inteiro)"
        },
        "responses": {
          "200": {
            "description": "`IntegrationKey` (o texto da chave não muda; sem `send`, a conexão e os telefones saem). `404 key_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationKey"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`key_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/integrations/keys/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Integração"
        ],
        "summary": "Apagar chave de integração",
        "operationId": "deleteIntegrationsKeysById",
        "description": "**Resposta:** `204`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/integrations/keys/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integrations/keys/{id}/rotate": {
      "post": {
        "tags": [
          "Integração"
        ],
        "summary": "Trocar a chave de integração",
        "operationId": "postIntegrationsKeysByIdRotate",
        "description": "**Resposta:** `{ key, secret }`: outro texto; o de antes deixa de valer na hora",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ key, secret }`: outro texto; o de antes deixa de valer na hora",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {},
                    "secret": {}
                  },
                  "required": [
                    "key",
                    "secret"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/integrations/keys/6750a1c2e4b0a1b2c3d4e5f1/rotate\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integrations/keys/{id}/calls": {
      "get": {
        "tags": [
          "Integração"
        ],
        "summary": "Listar pedidos da chave de integração",
        "operationId": "getIntegrationsKeysByIdCalls",
        "description": "**Resposta:** `{ data: [IntegrationCall] }`: os 50 últimos pedidos, envios e consultas, aceitos e recusados (90 dias)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [IntegrationCall] }`: os 50 últimos pedidos, envios e consultas, aceitos e recusados (90 dias)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegrationCall"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integrations/keys/6750a1c2e4b0a1b2c3d4e5f1/calls\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integration/messages": {
      "post": {
        "tags": [
          "Mandar mensagem (sem sessão)"
        ],
        "summary": "Mandar mensagem pela integração",
        "operationId": "postIntegrationMessages",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…` (a chave, sem o login do painel)\n\n**Corpo:** `{ to: string, text: string }`: `to` é o telefone com DDI (`+5554999990000`; o 9º dígito do celular brasileiro vale com ou sem) e `text`, até 4.096 letras. Só texto nesta versão\n\n**Resposta:** `202 { id: string, status: \"queued\"|\"held\", messageId: string, conversationId: string }`; `401 invalid_key`, `403 key_disabled`, `403 company_suspended`, `403 not_allowed`, `409 number_removed`, `409 no_conector`, `422 validation`, `429 rate_limited`, `503 tenant_updating` (o que cada um quer dizer está logo abaixo)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string",
                    "example": "+5554999990000"
                  },
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  }
                },
                "required": [
                  "to",
                  "text"
                ],
                "description": "`to` é o telefone com DDI (`+5554999990000`; o 9º dígito do celular brasileiro vale com ou sem) e `text`, até 4.096 letras. Só texto nesta versão"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "`202 { id: string, status: \"queued\"|\"held\", messageId: string, conversationId: string }`; `401 invalid_key`, `403 key_disabled`, `403 company_suspended`, `403 not_allowed`, `409 number_removed`, `409 no_conector`, `422 validation`, `429 rate_limited`, `503 tenant_updating` (o que cada um quer dizer está logo abaixo)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "held"
                      ],
                      "example": "queued"
                    },
                    "messageId": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "conversationId": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "required": [
                    "id",
                    "status",
                    "messageId",
                    "conversationId"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "`invalid_key`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`key_disabled`, `company_suspended`, `not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`number_removed`, `no_conector`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "503": {
            "description": "`tenant_updating`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/integration/messages\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"to\":\"+5554999990000\",\"text\":\"Bom dia, o pedido já saiu?\"}'"
          }
        ]
      }
    },
    "/api/v1/integration/contacts": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Buscar contatos pela integração",
        "operationId": "getIntegrationContacts",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `contacts`\n\n**Resposta:** `{ data: [IntegContact], next }`, do criado por último. Só os não apagados\n\n**Regra:** `phone` (com DDI, com ou sem o 9º dígito), `name` (pedaço, até 100 letras), `updatedSince` (criados ou com mensagem desde), `limit`, `cursor`",
        "parameters": [
          {
            "name": "phone",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "5554999990000"
            }
          },
          {
            "name": "name",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana Prado"
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [IntegContact], next }`, do criado por último. Só os não apagados",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegContact"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/contacts\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integration/contacts/{id}": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Ver um contato pela integração",
        "operationId": "getIntegrationContactsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `contacts`\n\n**Resposta:** `IntegContact`; o juntado a outro volta como o que ficou (outro `id`)\n\n**Regra:** —",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`IntegContact`; o juntado a outro volta como o que ficou (outro `id`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegContact"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/contacts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integration/conversations": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Buscar conversas pela integração",
        "operationId": "getIntegrationConversations",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `conversations`\n\n**Resposta:** `{ data: [IntegConversation], next }`, pela última mensagem. Sem as paradas há mais de 6 meses\n\n**Regra:** `contactId`, `phone`, `operationId`, `status`, `since` (última mensagem desde), `limit`, `cursor`",
        "parameters": [
          {
            "name": "contactId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "5554999990000"
            }
          },
          {
            "name": "operationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "example": "2026-12-01T12:12:00Z"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [IntegConversation], next }`, pela última mensagem. Sem as paradas há mais de 6 meses",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegConversation"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/conversations\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integration/conversations/{id}": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Ver uma conversa pela integração",
        "operationId": "getIntegrationConversationsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `conversations`\n\n**Resposta:** `IntegConversation`, também a parada (`archived: true`)\n\n**Regra:** —",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`IntegConversation`, também a parada (`archived: true`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegConversation"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integration/conversations/{id}/messages": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Listar mensagens de uma conversa pela integração",
        "operationId": "getIntegrationConversationsByIdMessages",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `conversations`\n\n**Resposta:** `{ data: [IntegMessage], next }`, da mais nova, também as do arquivo frio\n\n**Regra:** `limit`, `cursor` (o `next`: o id da mensagem)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [IntegMessage], next }`, da mais nova, também as do arquivo frio",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegMessage"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e5f1/messages\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integration/cards": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Buscar cartões pela integração",
        "operationId": "getIntegrationCards",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `cards`\n\n**Resposta:** `{ data: [IntegCard], next }`, pela última mudança; abertos e fechados\n\n**Regra:** `operationId`, `stageId`, `contactId`, `updatedSince` (última mudança desde), `limit`, `cursor`",
        "parameters": [
          {
            "name": "operationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "stageId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "contactId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [IntegCard], next }`, pela última mudança; abertos e fechados",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegCard"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/cards\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/integration/protocols": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Buscar protocolos pela integração",
        "operationId": "getIntegrationProtocols",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `protocols`\n\n**Resposta:** `{ data: [IntegProtocol], next }`, do aberto por último\n\n**Regra:** `protocol` (o número), `contactId`, `from` e `to` (o período da abertura; `to` só com o dia vale até o fim dele), `limit`, `cursor`",
        "parameters": [
          {
            "name": "protocol",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "20261201-0042"
            }
          },
          {
            "name": "contactId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "+5554999990000"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [IntegProtocol], next }`, do aberto por último",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegProtocol"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/protocols\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/deivid/status": {
      "get": {
        "tags": [
          "Deivid"
        ],
        "summary": "Ver a situação do Deivid",
        "operationId": "getDeividStatus",
        "description": "**Resposta:** `DeividStatus` `{ enabled, available, reason?, left? }`",
        "responses": {
          "200": {
            "description": "`DeividStatus` `{ enabled, available, reason?, left? }`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/deivid/status\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/deivid/suggestions": {
      "get": {
        "tags": [
          "Deivid"
        ],
        "summary": "Listar dúvidas comuns da tela",
        "operationId": "getDeividSuggestions",
        "description": "**Resposta:** `{ data: [texto] }`: até 3 dúvidas comuns da tela (`duvidas` da página da Ajuda)",
        "parameters": [
          {
            "name": "screen",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ data: [texto] }`: até 3 dúvidas comuns da tela (`duvidas` da página da Ajuda)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/deivid/suggestions\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/deivid/conversations": {
      "get": {
        "tags": [
          "Deivid"
        ],
        "summary": "Listar conversas com o Deivid",
        "operationId": "getDeividConversations",
        "description": "**Resposta:** `{ data: [DeividConversationSummary] }`, as do usuário, da mais nova (até 50)",
        "responses": {
          "200": {
            "description": "`{ data: [DeividConversationSummary] }`, as do usuário, da mais nova (até 50)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "description": "DeividConversationSummary"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/deivid/conversations\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/deivid/conversations/{id}": {
      "get": {
        "tags": [
          "Deivid"
        ],
        "summary": "Ver uma conversa com o Deivid",
        "operationId": "getDeividConversationsById",
        "description": "**Resposta:** `DeividConversation`, com as mensagens; de outro usuário ou vencida, `404`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`DeividConversation`, com as mensagens; de outro usuário ou vencida, `404`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/deivid/conversations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $TOKEN\""
          }
        ]
      }
    },
    "/api/v1/deivid/ask": {
      "post": {
        "tags": [
          "Deivid"
        ],
        "summary": "Perguntar ao Deivid",
        "operationId": "postDeividAsk",
        "description": "**Corpo:** `{ conversationId?, text, screen: { name, title, path }, context? }`\n\n**Resposta:** `text/event-stream` com os eventos `start`, `status`, `delta`, `message` e `error` (`event: <nome>`, `data: <json>`, linha em branco; um comentário a cada 15 s mantém a conexão). Antes de abrir: `422` (texto vazio ou com mais de 2.000 letras), `403 deivid_off`, `429 deivid_limit` ou `503 deivid_unavailable`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "conversationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "screen": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "example": "Ana Prado"
                      },
                      "title": {
                        "type": "string",
                        "example": "Pedido 48211"
                      },
                      "path": {}
                    },
                    "required": [
                      "name",
                      "title",
                      "path"
                    ]
                  },
                  "context": {}
                },
                "required": [
                  "text",
                  "screen"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`text/event-stream` com os eventos `start`, `status`, `delta`, `message` e `error` (`event: <nome>`, `data: <json>`, linha em branco; um comentário a cada 15 s mantém a conexão). Antes de abrir: `422` (texto vazio ou com mais de 2.000 letras), `403 deivid_off`, `429 deivid_limit` ou `503 deivid_unavailable`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "403": {
            "description": "`deivid_off`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "429": {
            "description": "`deivid_limit`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "503": {
            "description": "`deivid_unavailable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/deivid/ask\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"text\":\"Bom dia, o pedido já saiu?\",\"screen\":{\"name\":\"Ana Prado\",\"title\":\"Pedido 48211\"}}'"
          }
        ]
      }
    },
    "/api/v1/deivid/messages/{id}/feedback": {
      "post": {
        "tags": [
          "Deivid"
        ],
        "summary": "Avaliar resposta do Deivid",
        "operationId": "postDeividMessagesByIdFeedback",
        "description": "**Corpo:** `{ conversationId, helpful }`\n\n**Resposta:** `204`. `false` manda a pergunta e a resposta para o Admin",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "conversationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "helpful": {}
                },
                "required": [
                  "conversationId",
                  "helpful"
                ]
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "`204`. `false` manda a pergunta e a resposta para o Admin"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/deivid/messages/6750a1c2e4b0a1b2c3d4e5f1/feedback\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/deivid/actions/{id}/confirm": {
      "post": {
        "tags": [
          "Deivid"
        ],
        "summary": "Confirmar ação do Deivid",
        "operationId": "postDeividActionsByIdConfirm",
        "description": "**Corpo:** `{ conversationId }`\n\n**Resposta:** `text/event-stream`: `start`, `message` (a caixa resolvida) e a continuação. Já clicada: `409 deivid_action_done`; vencida (10 min): `409 deivid_action_expired`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "conversationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "conversationId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`text/event-stream`: `start`, `message` (a caixa resolvida) e a continuação. Já clicada: `409 deivid_action_done`; vencida (10 min): `409 deivid_action_expired`"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`deivid_action_done`, `deivid_action_expired`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/deivid/actions/6750a1c2e4b0a1b2c3d4e5f1/confirm\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/deivid/actions/{id}/cancel": {
      "post": {
        "tags": [
          "Deivid"
        ],
        "summary": "Cancelar ação do Deivid",
        "operationId": "postDeividActionsByIdCancel",
        "description": "**Corpo:** `{ conversationId }`\n\n**Resposta:** `DeividMessage`, com a caixa cancelada",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "conversationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "conversationId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`DeividMessage`, com a caixa cancelada"
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "painel": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/deivid/actions/6750a1c2e4b0a1b2c3d4e5f1/cancel\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "painel": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Token de acesso do painel (POST /api/v1/auth/login ou /auth/refresh), vale 15 min."
      },
      "chaveIntegracao": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "wzb_…",
        "description": "Chave de integração criada em Configurações › Integrações."
      }
    },
    "schemas": {
      "Ref": {
        "type": "object",
        "description": "Referência a outro documento.",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          }
        },
        "required": [
          "id"
        ]
      },
      "Erro": {
        "type": "object",
        "description": "Corpo de todo erro: `error` é o código (o mesmo das tabelas), `message` a frase para mostrar à pessoa e `details` o erro de cada campo.",
        "properties": {
          "error": {
            "type": "string",
            "example": "validation"
          },
          "message": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "details": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "requestId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          }
        },
        "required": [
          "error",
          "message"
        ]
      },
      "Paginada": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {}
          },
          "meta": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "page": {
                "type": "integer",
                "example": 1
              },
              "pageSize": {
                "type": "integer",
                "example": 50
              },
              "pages": {
                "type": "integer"
              }
            }
          }
        }
      },
      "Activity": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "kind": {
            "type": "string"
          },
          "key": {},
          "title": {
            "type": "string",
            "example": "Pedido 48211"
          },
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "link": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "postId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "messageId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "operationId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              }
            },
            "required": [
              "type",
              "id"
            ]
          },
          "count": {
            "type": "integer"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "seenAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "pinned": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "kind",
          "key",
          "title",
          "link",
          "count",
          "at"
        ]
      },
      "ActivityPrefs": {
        "type": "object",
        "properties": {
          "queue": {},
          "sound": {
            "type": "array",
            "items": {},
            "description": "kind"
          },
          "notify": {
            "type": "array",
            "items": {},
            "description": "kind"
          },
          "hidden": {},
          "unseen": {},
          "clearedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "digest": {}
        },
        "required": [
          "queue",
          "sound",
          "notify",
          "hidden",
          "unseen",
          "digest"
        ]
      },
      "Agent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "tone": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "objective": {
            "type": "string"
          },
          "instructions": {
            "type": "string"
          },
          "operationIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          "numberIds": {
            "type": "array",
            "items": {}
          },
          "hours": {
            "type": "object",
            "properties": {
              "always": {
                "type": "boolean"
              },
              "days": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "day": {
                      "type": "integer"
                    },
                    "start": {
                      "type": "string"
                    },
                    "end": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "kbSpaceIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          "kbPageIds": {
            "type": "array",
            "items": {}
          },
          "tools": {
            "type": "object",
            "properties": {
              "link": {
                "type": "boolean"
              },
              "tag": {
                "type": "boolean"
              },
              "card": {
                "type": "boolean"
              },
              "resolve": {
                "type": "boolean"
              }
            }
          },
          "handoff": {
            "type": "object",
            "properties": {
              "asksPerson": {
                "type": "boolean"
              },
              "angry": {
                "type": "boolean"
              },
              "valueAboveCents": {
                "type": "integer"
              },
              "noAnswer": {
                "type": "boolean"
              },
              "afterMessages": {
                "type": "integer"
              },
              "rules": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "message": {
                "type": "string",
                "example": "Bom dia, o pedido já saiu?"
              }
            }
          },
          "autoStart": {
            "type": "boolean"
          },
          "suggest": {
            "type": "boolean"
          },
          "dailyLimit": {
            "type": "integer"
          },
          "active": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "example": {
          "id": "...",
          "name": "Bia",
          "tone": "proximo",
          "provider": "anthropic",
          "model": "claude-haiku-5-5",
          "objective": "Tirar dúvidas sobre planos e agendar visitas técnicas",
          "instructions": "Chame o cliente pelo nome.",
          "operationIds": [
            "..."
          ],
          "numberIds": [],
          "hours": {
            "always": false,
            "days": [
              {
                "day": 1,
                "start": "08:00",
                "end": "18:00"
              }
            ]
          },
          "kbSpaceIds": [
            "..."
          ],
          "kbPageIds": [],
          "tools": {
            "link": true,
            "tag": false,
            "card": false,
            "resolve": true
          },
          "handoff": {
            "asksPerson": true,
            "angry": true,
            "valueAboveCents": 50000,
            "noAnswer": true,
            "afterMessages": 15,
            "rules": [
              "Pedido de reembolso"
            ],
            "message": ""
          },
          "autoStart": true,
          "suggest": true,
          "dailyLimit": 200,
          "active": true,
          "createdAt": "...",
          "updatedAt": "..."
        }
      },
      "Area": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "icon": {
            "type": "string"
          },
          "audience": {},
          "hours": {
            "type": "integer"
          },
          "sla": {},
          "numbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          },
          "people": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          }
        },
        "required": [
          "id",
          "name",
          "icon",
          "audience",
          "hours",
          "sla",
          "numbers",
          "people"
        ]
      },
      "Automation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "description": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "draft": {
            "description": "FlowGraph"
          },
          "version": {
            "type": "integer"
          },
          "dirty": {},
          "start": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "event": {},
              "hook": {}
            },
            "required": [
              "type"
            ]
          },
          "signingKey": {},
          "runs": {},
          "errors": {},
          "lastRunAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "createdBy": {},
          "updatedBy": {},
          "publishedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "name",
          "active",
          "draft",
          "version",
          "dirty",
          "runs",
          "errors",
          "createdBy",
          "updatedBy",
          "createdAt",
          "updatedAt"
        ]
      },
      "AutoRun": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "automationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "automation": {},
          "version": {
            "type": "integer"
          },
          "event": {},
          "summary": {},
          "status": {
            "type": "string",
            "enum": [
              "running",
              "waiting",
              "done",
              "stopped",
              "failed"
            ],
            "example": "running"
          },
          "node": {},
          "attempt": {},
          "waitUntil": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "vars": {},
          "steps": {},
          "stepCount": {
            "type": "integer"
          },
          "reason": {
            "type": "string"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "endedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "automationId",
          "automation",
          "version",
          "event",
          "summary",
          "status",
          "steps",
          "stepCount",
          "at",
          "updatedAt"
        ]
      },
      "Call": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "number": {
            "$ref": "#/components/schemas/Ref"
          },
          "conector": {
            "$ref": "#/components/schemas/Ref"
          },
          "user": {
            "$ref": "#/components/schemas/Ref"
          },
          "direction": {
            "type": "string",
            "enum": [
              "in"
            ],
            "example": "in"
          },
          "status": {
            "type": "string",
            "enum": [
              "starting",
              "dialing",
              "ringing",
              "answered",
              "ended",
              "failed",
              "missed"
            ],
            "example": "starting"
          },
          "reason": {
            "type": "string"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "answeredAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "endedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "seconds": {
            "type": "number"
          },
          "transcript": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "done",
                  "failed"
                ],
                "example": "pending"
              },
              "reason": {
                "type": "string"
              },
              "seconds": {
                "type": "integer"
              },
              "cut": {
                "type": "boolean"
              },
              "by": {
                "$ref": "#/components/schemas/Ref"
              },
              "at": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              },
              "doneAt": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              }
            },
            "required": [
              "status",
              "by",
              "at"
            ]
          },
          "sameNetwork": {
            "type": "boolean"
          },
          "quality": {
            "type": "object",
            "properties": {
              "rttMs": {
                "type": "number"
              },
              "jitterMs": {
                "type": "number"
              },
              "lossPct": {
                "type": "number"
              },
              "path": {}
            },
            "required": [
              "rttMs",
              "jitterMs",
              "lossPct"
            ]
          }
        },
        "required": [
          "id",
          "conversationId",
          "number",
          "user",
          "status",
          "startedAt",
          "seconds"
        ]
      },
      "CallCheck": {
        "type": "object",
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "ready": {
            "type": "boolean"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {},
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "level": {
                  "type": "string",
                  "enum": [
                    "ok",
                    "warn",
                    "error",
                    "pending"
                  ],
                  "example": "ok"
                },
                "text": {
                  "type": "string",
                  "example": "Bom dia, o pedido já saiu?"
                },
                "fix": {}
              },
              "required": [
                "key",
                "name",
                "level",
                "text"
              ]
            }
          }
        },
        "required": [
          "at",
          "ready",
          "items"
        ]
      },
      "CallStart": {
        "type": "object",
        "properties": {
          "callId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "route": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "conector",
                  "official"
                ],
                "example": "conector"
              },
              "number": {
                "$ref": "#/components/schemas/Ref"
              },
              "conector": {}
            },
            "required": [
              "kind",
              "number"
            ]
          },
          "iceServers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "urls": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "example": "https://exemplo.com.br"
                  }
                },
                "username": {},
                "credential": {}
              },
              "required": [
                "urls"
              ]
            }
          },
          "record": {
            "type": "boolean"
          },
          "sameNetwork": {
            "type": "boolean"
          }
        },
        "required": [
          "callId",
          "route",
          "iceServers"
        ]
      },
      "Campaign": {
        "description": "{\n  \"id\": \"...\", \"notice\": false, \"name\": \"Promoção de novembro\",\n  \"number\": { \"id\": \"...\", \"name\": \"Loja Centro\", \"channel\": \"qr\" },\n  \"audience\": { \"tags\": [\"cliente-vip\"], \"operationIds\": [], \"stageIds\": [], \"kinds\": [\"cliente\"], \"fields\": [ { \"field\": \"city\", \"op\": \"equals\", \"value\": \"Campinas\" } ], \"contactIds\": [], \"listName\": \"\" },\n  \"message\": { \"kind\": \"text\", \"texts\": [\"Oi, {{primeiro_nome}}! ...\"], \"file\": { \"id\": \"...\", \"name\": \"folheto.pdf\", \"mime\": \"application/pdf\" }, \"optOut\": true, \"template\": { \"name\": \"promo_novembro\", \"language\": \"pt_BR\", \"category\": \"marketing\", \"vars\": [\"{{primeiro_nome}}\"] } },\n  \"pace\": { \"minDelaySec\": 30, \"maxDelaySec\": 90, \"perDay\": 200, \"windowStart\": \"08:00\", \"windowEnd\": \"20:00\" },\n  \"startAt\": \"...\", \"state\": \"running\", \"waiting\": \"A campanha só envia das 08:00 às 20:00.\", \"nextAt\": \"...\",\n  \"stats\": { \"total\": 840, \"sent\": 312, \"delivered\": 300, \"read\": 251, \"replied\": 37, \"failed\": 2, \"optOut\": 3, \"skipped\": 1 },\n  \"createdBy\": Ref, \"updatedBy\": Ref, \"startedAt\": \"...\", \"finishedAt\": \"...\", \"createdAt\": \"...\", \"updatedAt\": \"...\"\n}"
      },
      "CampaignOptOut": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "kind": {
            "type": "string"
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "5554999990000"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "optOutAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "name",
          "kind",
          "phones",
          "tags",
          "optOutAt"
        ]
      },
      "CampaignSend": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "campaignId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "contact": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "phone": {
                "type": "string",
                "example": "5554999990000"
              }
            },
            "required": [
              "id",
              "name"
            ]
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "messageId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "status": {
            "type": "string"
          },
          "error": {},
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "sentAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "deliveredAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "readAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "repliedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "optOutAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "campaignId",
          "contact",
          "status",
          "at"
        ]
      },
      "Card": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "operationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "stageId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "title": {
            "type": "string",
            "example": "Pedido 48211"
          },
          "contact": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "valueCents": {
            "type": "integer"
          },
          "owner": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "note": {
            "type": "string"
          },
          "dueAt": {
            "type": "string"
          },
          "dueStatus": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "fields": {
            "type": "object",
            "properties": {
              "tipo_de_servico": {
                "type": "string"
              },
              "valor_cobrado": {
                "type": "integer"
              }
            }
          },
          "lastActivityAt": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          }
        },
        "example": {
          "id": "...",
          "operationId": "...",
          "stageId": "...",
          "title": "Escola Viva",
          "contact": {
            "id": "...",
            "name": "Escola Viva"
          },
          "conversationId": "...",
          "valueCents": 290000,
          "owner": {
            "id": "...",
            "name": "Rafael Mendes"
          },
          "note": "Tênis para 40 alunos",
          "dueAt": "...",
          "dueStatus": "ok|warn|late",
          "tags": [
            "Aguardando peça"
          ],
          "fields": {
            "tipo_de_servico": "Conserto",
            "valor_cobrado": 1500000
          },
          "lastActivityAt": "...",
          "createdAt": "..."
        }
      },
      "ChatChannel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "kind": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "topic": {
            "type": "string"
          },
          "general": {
            "type": "boolean"
          },
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "members": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "memberCount": {
            "type": "integer"
          },
          "createdBy": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "mode": {
            "type": "string"
          },
          "admins": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bookmarks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "title": {
                  "type": "string",
                  "example": "Pedido 48211"
                },
                "emoji": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "example": "https://exemplo.com.br"
                },
                "fileId": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "fileName": {
                  "type": "string"
                },
                "fileUrl": {
                  "type": "string",
                  "example": "https://exemplo.com.br"
                },
                "by": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    }
                  }
                }
              }
            }
          },
          "archived": {
            "type": "boolean"
          },
          "lastPostAt": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "member": {
            "type": "boolean"
          },
          "unread": {
            "type": "integer"
          },
          "mentions": {
            "type": "integer"
          },
          "lastReadAt": {
            "type": "string"
          },
          "favorite": {
            "type": "boolean"
          },
          "muted": {
            "type": "boolean"
          },
          "notify": {
            "type": "string"
          },
          "ignoreAll": {
            "type": "boolean"
          },
          "group": {
            "type": "string"
          }
        },
        "example": {
          "id": "...",
          "kind": "open|closed|direct",
          "name": "suporte",
          "topic": "Trocas e devoluções",
          "general": true,
          "operation": {
            "id": "...",
            "name": "Suporte"
          },
          "members": [
            {
              "id": "...",
              "name": "Ana Souza"
            }
          ],
          "memberCount": 12,
          "createdBy": {
            "id": "...",
            "name": "Ana Souza"
          },
          "mode": "questions",
          "admins": [
            "<conta>"
          ],
          "bookmarks": [
            {
              "id": "...",
              "title": "Tabela de trocas",
              "emoji": "📄",
              "url": "https://...",
              "fileId": "...",
              "fileName": "trocas.pdf",
              "fileUrl": "...",
              "by": {
                "id": "...",
                "name": "Ana Souza"
              }
            }
          ],
          "archived": false,
          "lastPostAt": "...",
          "createdAt": "...",
          "member": true,
          "unread": 3,
          "mentions": 1,
          "lastReadAt": "...",
          "favorite": true,
          "muted": false,
          "notify": "all|mentions|none",
          "ignoreAll": false,
          "group": "<id do grupo da lista>"
        }
      },
      "ChatDraft": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "kind": {
            "type": "string",
            "enum": [
              "draft|scheduled"
            ],
            "example": "draft|scheduled"
          },
          "channelId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "rootId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "fileIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          "mentionIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          "also": {},
          "priority": {},
          "ack": {},
          "subjects": {},
          "sendAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "error": {},
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "channel": {},
          "files": {}
        },
        "required": [
          "id",
          "kind",
          "channelId",
          "updatedAt",
          "channel"
        ]
      },
      "ChatEdit": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "current": {
            "type": "boolean"
          }
        },
        "required": [
          "text",
          "at"
        ]
      },
      "ChatFormAnswer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "postId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "by": {
            "$ref": "#/components/schemas/Ref"
          },
          "values": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {},
                "text": {
                  "type": "string",
                  "example": "Bom dia, o pedido já saiu?"
                },
                "file": {
                  "$ref": "#/components/schemas/File"
                }
              },
              "required": [
                "field"
              ]
            }
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "postId",
          "by",
          "values",
          "at"
        ]
      },
      "ChatFormResult": {
        "type": "object",
        "properties": {
          "form": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "example": "Pedido 48211"
              },
              "fields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "text",
                        "long",
                        "rating",
                        "date",
                        "number",
                        "choice",
                        "yesno",
                        "photo"
                      ],
                      "example": "text"
                    },
                    "label": {
                      "type": "string"
                    },
                    "options": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "required": {}
                  },
                  "required": [
                    "id",
                    "kind",
                    "label"
                  ]
                }
              },
              "closeAt": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              },
              "closedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              },
              "count": {
                "type": "number"
              }
            },
            "required": [
              "title",
              "fields",
              "count"
            ]
          },
          "answers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatFormAnswer"
            }
          },
          "missing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          }
        },
        "required": [
          "form",
          "answers",
          "missing"
        ]
      },
      "ChatPerson": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "handle": {
            "type": "string",
            "example": "boas-vindas"
          },
          "online": {
            "type": "boolean"
          },
          "presence": {
            "type": "string",
            "enum": [
              "online|away|dnd|offline"
            ],
            "example": "online|away|dnd|offline"
          },
          "awaySince": {},
          "dndUntil": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "status": {
            "type": "object",
            "properties": {
              "emoji": {},
              "text": {
                "type": "string",
                "example": "Bom dia, o pedido já saiu?"
              },
              "until": {}
            },
            "required": [
              "text"
            ]
          },
          "inHours": {},
          "hours": {
            "type": "string",
            "enum": [
              "Seg. a sex., 8h às 18h"
            ],
            "example": "Seg. a sex., 8h às 18h"
          },
          "role": {
            "description": "o nome do perfil de acesso (sem perfil"
          },
          "Administrador": {},
          "ou": {},
          "Atendente": {
            "description": ")"
          },
          "operations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          }
        },
        "required": [
          "id",
          "name",
          "handle",
          "online",
          "presence",
          "inHours",
          "Administrador",
          "ou",
          "Atendente"
        ]
      },
      "ChatPost": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "channelId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "rootId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "also": {
            "type": "boolean"
          },
          "kind": {
            "type": "string"
          },
          "author": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "mentions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "mentionAll": {
            "type": "boolean"
          },
          "mentionHere": {
            "type": "boolean"
          },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "mime": {
                  "type": "string"
                },
                "size": {
                  "type": "integer"
                },
                "fileName": {
                  "type": "string"
                },
                "width": {
                  "type": "integer"
                },
                "height": {
                  "type": "integer"
                },
                "url": {
                  "type": "string",
                  "example": "https://exemplo.com.br"
                }
              }
            }
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "conversation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "phone": {
                "type": "string",
                "example": "5554999990000"
              },
              "operation": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  }
                }
              },
              "owner": {
                "description": "Pode vir null."
              },
              "status": {
                "type": "string"
              },
              "lastMessage": {
                "type": "object",
                "properties": {}
              }
            }
          },
          "alert": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "example": "Pedido 48211"
              },
              "detail": {
                "type": "string"
              },
              "operationId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "cardId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              }
            }
          },
          "reactions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "emoji": {
                  "type": "string"
                },
                "by": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    }
                  }
                }
              }
            }
          },
          "replyCount": {
            "type": "integer"
          },
          "lastReplyAt": {
            "type": "string"
          },
          "repliers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "pinned": {
            "type": "boolean"
          },
          "pinnedAt": {
            "type": "string"
          },
          "edited": {
            "type": "boolean"
          },
          "editedAt": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean"
          },
          "at": {
            "type": "string"
          },
          "priority": {
            "type": "string"
          },
          "ackRequested": {
            "type": "boolean"
          },
          "acks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "by": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    }
                  }
                },
                "at": {
                  "type": "string"
                }
              }
            }
          },
          "poll": {
            "type": "object",
            "properties": {
              "question": {
                "type": "string"
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "text": {
                      "type": "string",
                      "example": "Bom dia, o pedido já saiu?"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "people": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              },
              "multi": {
                "type": "boolean"
              },
              "anonymous": {
                "type": "boolean"
              },
              "blind": {
                "type": "boolean"
              },
              "closeAt": {
                "type": "string"
              },
              "closedAt": {
                "type": "string"
              },
              "voters": {
                "type": "integer"
              },
              "mine": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "hidden": {
                "type": "boolean"
              }
            }
          },
          "forward": {
            "type": "object",
            "properties": {
              "postId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "rootId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "channelId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "channelKind": {
                "type": "string"
              },
              "channelName": {
                "type": "string"
              },
              "author": {
                "type": "object",
                "properties": {}
              },
              "text": {
                "type": "string",
                "example": "Bom dia, o pedido já saiu?"
              },
              "files": {
                "type": "array",
                "items": {}
              },
              "at": {
                "type": "string"
              },
              "locked": {
                "type": "boolean"
              }
            }
          },
          "preview": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "example": "https://exemplo.com.br"
              },
              "site": {
                "type": "string",
                "example": "https://exemplo.com.br"
              },
              "title": {
                "type": "string",
                "example": "Pedido 48211"
              },
              "description": {
                "type": "string"
              },
              "image": {
                "type": "string"
              },
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              }
            }
          },
          "solved": {
            "type": "object",
            "properties": {
              "answerId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "author": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  }
                }
              },
              "text": {
                "type": "string",
                "example": "Bom dia, o pedido já saiu?"
              },
              "by": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  }
                }
              },
              "at": {
                "type": "string"
              }
            }
          },
          "subjects": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "saved": {
            "type": "boolean"
          },
          "following": {
            "type": "boolean"
          },
          "threadUnread": {
            "type": "boolean"
          },
          "channel": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "kind": {
                "type": "string"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "notInChannel": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          }
        },
        "example": {
          "id": "...",
          "channelId": "...",
          "rootId": "...",
          "also": false,
          "kind": "post|system|alert",
          "author": {
            "id": "...",
            "name": "Ana Souza"
          },
          "text": "@Bruno olha este caso",
          "mentions": [
            "<conta>"
          ],
          "mentionAll": false,
          "mentionHere": false,
          "files": [
            {
              "id": "...",
              "mime": "image/jpeg",
              "size": 81234,
              "fileName": "foto.jpg",
              "width": 1200,
              "height": 900,
              "url": "..."
            },
            {
              "id": "...",
              "mime": "audio/ogg",
              "size": 9120,
              "fileName": "voz.ogg",
              "seconds": 7.4,
              "voice": true,
              "waveform": [
                12,
                40,
                63
              ],
              "url": "..."
            }
          ],
          "conversationId": "...",
          "conversation": {
            "id": "...",
            "name": "Marina Lopes",
            "phone": "5511...",
            "operation": {
              "id": "...",
              "name": "Suporte"
            },
            "owner": null,
            "status": "open",
            "lastMessage": {}
          },
          "alert": {
            "title": "Ticket “Troca” vence às 14:00",
            "detail": "Sem resposta há 25 minutos. Quem assume?",
            "operationId": "...",
            "cardId": "..."
          },
          "reactions": [
            {
              "emoji": "👍",
              "by": {
                "id": "...",
                "name": "Bruno"
              }
            }
          ],
          "replyCount": 2,
          "lastReplyAt": "...",
          "repliers": [
            {
              "id": "...",
              "name": "Bruno"
            }
          ],
          "pinned": true,
          "pinnedAt": "...",
          "edited": false,
          "editedAt": "...",
          "deleted": false,
          "at": "...",
          "priority": "urgent|important",
          "ackRequested": true,
          "acks": [
            {
              "by": {
                "id": "...",
                "name": "Bruno"
              },
              "at": "..."
            }
          ],
          "poll": {
            "question": "Qual dia?",
            "options": [
              {
                "id": "1",
                "text": "Sexta",
                "count": 3,
                "people": []
              }
            ],
            "multi": false,
            "anonymous": false,
            "blind": false,
            "closeAt": "...",
            "closedAt": "...",
            "voters": 3,
            "mine": [
              "1"
            ],
            "hidden": false
          },
          "forward": {
            "postId": "...",
            "rootId": "...",
            "channelId": "...",
            "channelKind": "open",
            "channelName": "vendas",
            "author": {},
            "text": "...",
            "files": [],
            "at": "...",
            "locked": false
          },
          "preview": {
            "url": "https://...",
            "site": "exemplo.com.br",
            "title": "...",
            "description": "...",
            "image": "...",
            "width": 1200,
            "height": 630
          },
          "solved": {
            "answerId": "...",
            "author": {
              "id": "...",
              "name": "Bruno"
            },
            "text": "começo da resposta",
            "by": {
              "id": "...",
              "name": "Rafael"
            },
            "at": "..."
          },
          "subjects": [
            "Correção",
            "Melhoria"
          ],
          "saved": false,
          "following": true,
          "threadUnread": false,
          "channel": {
            "id": "...",
            "kind": "open",
            "name": "suporte"
          },
          "notInChannel": [
            {
              "id": "...",
              "name": "Carla"
            }
          ]
        }
      },
      "ChatPrefs": {
        "type": "object",
        "properties": {
          "groups": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          },
          "keywords": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presence": {
            "type": "string",
            "enum": [
              "away|dnd|offline"
            ],
            "example": "away|dnd|offline"
          },
          "dndUntil": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "status": {
            "type": "string"
          },
          "recentEmojis": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "skinTone": {}
        },
        "required": [
          "groups",
          "keywords",
          "recentEmojis",
          "skinTone"
        ]
      },
      "CompanyAI": {
        "type": "object",
        "properties": {
          "ownKeys": {
            "type": "boolean"
          },
          "ownUses": {
            "type": "boolean"
          },
          "enabled": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          },
          "canSaveKey": {
            "type": "boolean"
          },
          "providers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "site": {},
                "hasKey": {
                  "type": "boolean"
                },
                "keyEnd": {},
                "keySetAt": {
                  "type": "string",
                  "format": "date-time",
                  "example": "2026-12-01T12:12:00Z"
                },
                "keySetBy": {
                  "$ref": "#/components/schemas/Ref"
                },
                "lastTest": {
                  "type": "object",
                  "properties": {
                    "at": {
                      "type": "string",
                      "format": "date-time",
                      "example": "2026-12-01T12:12:00Z"
                    },
                    "ok": {
                      "type": "boolean"
                    },
                    "detail": {},
                    "by": {
                      "$ref": "#/components/schemas/Ref"
                    }
                  },
                  "required": [
                    "at",
                    "ok",
                    "detail",
                    "by"
                  ]
                },
                "off": {
                  "type": "boolean"
                }
              },
              "required": [
                "id",
                "name",
                "site",
                "hasKey"
              ]
            }
          },
          "catalog": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "site": {},
                "kinds": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "id",
                "name",
                "site",
                "kinds"
              ]
            }
          },
          "uses": {},
          "ready": {},
          "models": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "hint": {},
                "provider": {},
                "providerName": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "chat",
                    "image",
                    "audio",
                    "embedding"
                  ],
                  "example": "chat"
                }
              },
              "required": [
                "id",
                "name",
                "provider",
                "providerName"
              ]
            }
          },
          "calls": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "available": {
                "type": "boolean"
              },
              "reason": {
                "type": "string"
              }
            },
            "required": [
              "enabled",
              "available"
            ]
          },
          "audios": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "available": {
                "type": "boolean"
              },
              "reason": {
                "type": "string"
              }
            },
            "required": [
              "enabled",
              "available"
            ]
          },
          "month": {
            "type": "object",
            "properties": {
              "calls": {
                "type": "number"
              },
              "costMicroUsd": {
                "type": "number"
              },
              "failures": {
                "type": "number"
              },
              "audios": {
                "type": "number"
              },
              "audioSeconds": {
                "type": "number"
              },
              "transcriptions": {
                "type": "number"
              }
            },
            "required": [
              "calls",
              "costMicroUsd",
              "failures",
              "audios",
              "audioSeconds",
              "transcriptions"
            ]
          },
          "test": {}
        },
        "required": [
          "ownKeys",
          "ownUses",
          "enabled",
          "canSaveKey",
          "providers",
          "catalog",
          "uses",
          "ready",
          "models",
          "calls",
          "audios",
          "month"
        ]
      },
      "Conector": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "computer": {
            "type": "string"
          },
          "windowsUser": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "os": {
            "type": "string"
          },
          "online": {
            "type": "boolean"
          },
          "lastBeatAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "latencyMs": {
            "type": "integer"
          },
          "numbers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "callNumber": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "callReady": {
            "type": "boolean"
          },
          "callBusy": {
            "type": "boolean"
          },
          "pairedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "callCheck": {
            "type": "object",
            "properties": {
              "at": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              },
              "ready": {
                "type": "boolean"
              },
              "testedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              },
              "ref": {
                "type": "string"
              },
              "items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    },
                    "level": {
                      "type": "string"
                    },
                    "text": {
                      "type": "string",
                      "example": "Bom dia, o pedido já saiu?"
                    },
                    "fix": {
                      "type": "string"
                    }
                  }
                }
              },
              "web": {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string",
                    "example": "5554999990000"
                  }
                }
              }
            }
          }
        },
        "example": {
          "id": "...",
          "name": "PC do balcão",
          "computer": "BALCAO-01",
          "windowsUser": "balcao",
          "version": "1.0.0",
          "os": "windows 10.0.26100",
          "online": true,
          "lastBeatAt": "2026-11-13T12:00:03Z",
          "latencyMs": 38,
          "numbers": [
            {
              "id": "...",
              "name": "Balcão da Loja Centro"
            }
          ],
          "callNumber": {
            "id": "...",
            "name": "Balcão da Loja Centro"
          },
          "callReady": true,
          "callBusy": false,
          "pairedAt": "2026-11-10T09:00:00Z",
          "callCheck": {
            "at": "2026-11-13T12:00:00Z",
            "ready": true,
            "testedAt": "2026-11-13T11:58:10Z",
            "ref": "...",
            "items": [
              {
                "key": "sleep",
                "name": "Suspensão",
                "level": "warn",
                "text": "O computador suspende depois de ...",
                "fix": "..."
              }
            ],
            "web": {
              "state": "connected",
              "phone": "5511900000000"
            }
          }
        }
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "kind": {
            "type": "string"
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "5554999990000"
            }
          },
          "email": {
            "type": "string",
            "example": "ana@exemplo.com.br"
          },
          "organization": {
            "type": "string",
            "example": "Padaria Bom Grão"
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "primary": {
                  "type": "boolean"
                }
              }
            }
          },
          "organizations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "role": {
                  "type": "string"
                },
                "primary": {
                  "type": "boolean"
                }
              }
            }
          },
          "birthday": {
            "type": "string"
          },
          "birthYear": {
            "type": "integer"
          },
          "city": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "avatarUrl": {
            "type": "string",
            "example": "https://exemplo.com.br"
          },
          "lastMessageAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "operations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "createdAt": {
            "type": "string"
          },
          "fields": {
            "type": "object",
            "properties": {
              "endereco_de_instalacao": {
                "type": "string"
              },
              "equipamentos": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "example": {
          "id": "...",
          "name": "Mariana Souza",
          "kind": "cliente",
          "phones": [
            "5519998124410"
          ],
          "email": "mariana@exemplo.com.br",
          "organization": "Padaria Pão de Luz",
          "channels": [
            {
              "kind": "whatsapp",
              "value": "5519998124410",
              "label": "Pessoal",
              "primary": true
            },
            {
              "kind": "email",
              "value": "mariana@exemplo.com.br",
              "primary": true
            },
            {
              "kind": "instagram",
              "value": "mari.souza",
              "primary": true
            }
          ],
          "organizations": [
            {
              "id": "...",
              "name": "Padaria Pão de Luz",
              "role": "Sócia",
              "primary": true
            }
          ],
          "birthday": "03-14",
          "birthYear": 1988,
          "city": "Campinas, SP",
          "notes": "",
          "tags": [
            "Lead"
          ],
          "avatarUrl": "https://...",
          "lastMessageAt": "2026-11-13T10:42:00Z",
          "operations": [
            {
              "id": "...",
              "name": "Vendas"
            }
          ],
          "createdAt": "...",
          "fields": {
            "endereco_de_instalacao": "Rua das Acácias, 120",
            "equipamentos": [
              "Split 12.000 BTUs"
            ]
          }
        }
      },
      "Conversation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "contact": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "phone": {
                "type": "string",
                "example": "5554999990000"
              },
              "avatarUrl": {
                "type": "string",
                "example": "https://exemplo.com.br"
              }
            }
          },
          "number": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "channel": {
                "type": "string"
              }
            }
          },
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "owner": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "status": {
            "type": "string"
          },
          "unread": {
            "type": "integer"
          },
          "isGroup": {
            "type": "boolean"
          },
          "groupName": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "lastMessage": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string"
              },
              "text": {
                "type": "string",
                "example": "Bom dia, o pedido já saiu?"
              },
              "fromMe": {
                "type": "boolean"
              },
              "status": {
                "type": "string"
              },
              "at": {
                "type": "string"
              }
            }
          },
          "lastMessageAt": {
            "type": "string"
          },
          "card": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "operationId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "stageId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "stage": {
                "type": "string"
              }
            }
          },
          "lastInboundAt": {
            "type": "string"
          },
          "callPermission": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string"
              },
              "permanent": {
                "type": "boolean"
              },
              "expiresAt": {
                "type": "string"
              },
              "at": {
                "type": "string"
              }
            }
          },
          "ticket": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "protocol": {
                "type": "string",
                "example": "20261201-0042"
              },
              "openedAt": {
                "type": "string"
              }
            }
          }
        },
        "example": {
          "id": "...",
          "contact": {
            "id": "...",
            "name": "Mariana Souza",
            "phone": "5519998124410",
            "avatarUrl": "..."
          },
          "number": {
            "id": "...",
            "name": "Balcão da Loja Centro",
            "channel": "qr"
          },
          "operation": {
            "id": "...",
            "name": "Vendas"
          },
          "owner": {
            "id": "...",
            "name": "Rafael Mendes"
          },
          "status": "open",
          "unread": 2,
          "isGroup": false,
          "groupName": "",
          "tags": [
            "Lead"
          ],
          "lastMessage": {
            "kind": "text",
            "text": "Vocês entregam em Campinas?",
            "fromMe": false,
            "status": "read",
            "at": "..."
          },
          "lastMessageAt": "...",
          "card": {
            "id": "...",
            "operationId": "...",
            "stageId": "...",
            "stage": "Qualificado"
          },
          "lastInboundAt": "...",
          "callPermission": {
            "status": "granted",
            "permanent": false,
            "expiresAt": "...",
            "at": "..."
          },
          "ticket": {
            "id": "...",
            "protocol": "2026-000123",
            "openedAt": "..."
          }
        }
      },
      "Delivery": {
        "type": "object",
        "properties": {
          "push": {
            "type": "object",
            "properties": {
              "key": {},
              "devices": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/PushDevice"
                  },
                  {
                    "type": "array",
                    "items": {}
                  }
                ]
              }
            },
            "required": [
              "key",
              "devices"
            ]
          },
          "email": {
            "type": "object",
            "properties": {
              "ready": {},
              "address": {}
            },
            "required": [
              "ready",
              "address"
            ]
          }
        },
        "required": [
          "push",
          "email"
        ]
      },
      "Fichas": {
        "type": "object",
        "properties": {
          "contact": {
            "type": "object",
            "properties": {
              "tabs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    }
                  }
                }
              },
              "sections": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    },
                    "tabId": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "access": {
                      "type": "object",
                      "properties": {
                        "mode": {
                          "type": "string"
                        },
                        "areaIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "example": "6750a1c2e4b0a1b2c3d4e5f1"
                          }
                        },
                        "operationIds": {
                          "type": "array",
                          "items": {}
                        }
                      }
                    },
                    "fields": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "type": {
                            "type": "string"
                          },
                          "required": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "organization": {
            "type": "object",
            "properties": {
              "tabs": {
                "type": "array",
                "items": {}
              },
              "sections": {
                "type": "array",
                "items": {}
              }
            }
          }
        },
        "example": {
          "contact": {
            "tabs": [
              {
                "id": "...",
                "name": "Instalação e cobrança"
              }
            ],
            "sections": [
              {
                "id": "...",
                "name": "Financeiro",
                "tabId": "...",
                "access": {
                  "mode": "ops",
                  "areaIds": [
                    "..."
                  ],
                  "operationIds": []
                },
                "fields": [
                  {
                    "key": "cpf_do_responsavel",
                    "name": "CPF do responsável",
                    "type": "document",
                    "required": true
                  },
                  {
                    "key": "limite_de_credito",
                    "name": "Limite de crédito",
                    "type": "money",
                    "access": {
                      "mode": "admin",
                      "areaIds": [],
                      "operationIds": []
                    }
                  }
                ]
              }
            ]
          },
          "organization": {
            "tabs": [],
            "sections": []
          }
        }
      },
      "File": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "kind": {
            "type": "string"
          },
          "mime": {
            "type": "string"
          },
          "size": {
            "type": "integer"
          },
          "fileName": {
            "type": "string"
          },
          "width": {},
          "height": {},
          "seconds": {
            "type": "integer"
          },
          "scan": {},
          "url": {
            "type": "string",
            "example": "https://exemplo.com.br"
          }
        },
        "required": [
          "id",
          "kind",
          "mime",
          "size",
          "fileName",
          "width",
          "height",
          "seconds",
          "url"
        ]
      },
      "Flow": {
        "description": "{\n  \"id\": \"...\", \"name\": \"Boas-vindas da loja\", \"description\": \"Primeiro contato pelo WhatsApp\",\n  \"active\": true, \"version\": 3, \"dirty\": false, \"draftRev\": 42,\n  \"draft\": { \"nodes\": [FlowNode], \"edges\": [ { \"from\": \"inicio\", \"port\": \"next\", \"to\": \"b1\" } ],\n             \"config\": [ { \"name\": \"setor_padrao\", \"value\": \"Suporte\" } ] },\n  \"trigger\": FlowTrigger, \"runs\": 128, \"lastRunAt\": \"...\", \"live\": 4,\n  \"createdBy\": Ref, \"updatedBy\": Ref, \"publishedAt\": \"...\", \"createdAt\": \"...\", \"updatedAt\": \"...\"\n}"
      },
      "FlowNode": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string",
            "example": "Pedido 48211"
          },
          "x": {},
          "y": {}
        },
        "required": [
          "id",
          "type",
          "x",
          "y"
        ]
      },
      "FlowRun": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "flowId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "flow": {},
          "version": {
            "type": "integer"
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "contact": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "phone": {
                "type": "string",
                "example": "5554999990000"
              }
            },
            "required": [
              "id",
              "name"
            ]
          },
          "number": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "channel": {}
            },
            "required": [
              "id",
              "name",
              "channel"
            ]
          },
          "trigger": {},
          "status": {
            "type": "string",
            "enum": [
              "running",
              "waiting",
              "done",
              "stopped",
              "failed"
            ],
            "example": "running"
          },
          "node": {},
          "waitUntil": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "vars": {},
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "node": {},
                "type": {
                  "type": "string"
                },
                "title": {
                  "type": "string",
                  "example": "Pedido 48211"
                },
                "port": {},
                "note": {
                  "type": "string"
                },
                "error": {},
                "vars": {},
                "at": {
                  "type": "string",
                  "format": "date-time",
                  "example": "2026-12-01T12:12:00Z"
                }
              },
              "required": [
                "node",
                "type",
                "at"
              ]
            }
          },
          "stepCount": {
            "type": "integer"
          },
          "reason": {
            "type": "string"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "endedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "flowId",
          "flow",
          "version",
          "conversationId",
          "contact",
          "number",
          "trigger",
          "status",
          "steps",
          "stepCount",
          "at",
          "updatedAt"
        ]
      },
      "FlowSecret": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "type": {
            "type": "string",
            "enum": [
              "header",
              "database"
            ],
            "example": "header"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "header": {},
          "db": {
            "type": "object",
            "properties": {
              "engine": {},
              "host": {},
              "port": {},
              "database": {},
              "user": {},
              "ssl": {},
              "via": {},
              "conector": {}
            },
            "required": [
              "engine",
              "host",
              "port",
              "database",
              "user",
              "ssl",
              "via"
            ]
          },
          "hint": {},
          "createdBy": {},
          "updatedBy": {},
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "type",
          "name",
          "header",
          "hint",
          "createdBy",
          "updatedBy",
          "createdAt",
          "updatedAt"
        ]
      },
      "FlowVersion": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "flowId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "version": {
            "type": "number"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "graph": {
            "type": "object",
            "properties": {
              "nodes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/FlowNode"
                }
              },
              "edges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "from": {},
                    "port": {},
                    "to": {
                      "type": "string",
                      "example": "+5554999990000"
                    }
                  },
                  "required": [
                    "from",
                    "port",
                    "to"
                  ]
                }
              },
              "config": {}
            },
            "required": [
              "nodes",
              "edges"
            ]
          },
          "note": {
            "type": "string"
          },
          "author": {
            "$ref": "#/components/schemas/Ref"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "flowId",
          "version",
          "name",
          "graph",
          "author",
          "at"
        ]
      },
      "Import": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "source": {
            "type": "string",
            "enum": [
              "digisac"
            ],
            "example": "digisac"
          },
          "status": {
            "type": "string"
          },
          "host": {},
          "since": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "files": {},
          "complete": {},
          "kinds": {},
          "first": {},
          "counts": {},
          "numbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportNumber"
            }
          },
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportUser"
            }
          },
          "departments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportDept"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportTag"
            }
          },
          "customFields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportField"
            }
          },
          "loaded": {},
          "draft": {},
          "phase": {},
          "progress": {},
          "result": {},
          "skipped": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportLeftOut"
            }
          },
          "error": {},
          "createdBy": {
            "$ref": "#/components/schemas/Ref"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "finishedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "plan": {}
        },
        "required": [
          "id",
          "source",
          "status",
          "host",
          "files",
          "complete",
          "kinds",
          "counts",
          "numbers",
          "users",
          "departments",
          "tags",
          "customFields",
          "loaded",
          "progress",
          "createdBy",
          "createdAt"
        ]
      },
      "ImportDept": {
        "type": "object",
        "properties": {
          "sourceId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "archived": {
            "type": "boolean"
          },
          "action": {},
          "operationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          }
        },
        "required": [
          "sourceId",
          "name",
          "archived",
          "action"
        ]
      },
      "ImportField": {
        "type": "object",
        "properties": {
          "sourceId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "type": {
            "type": "string"
          },
          "action": {},
          "key": {}
        },
        "required": [
          "sourceId",
          "name",
          "type",
          "action"
        ]
      },
      "ImportLeftOut": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "contact": {},
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "name",
          "reason"
        ]
      },
      "ImportNumber": {
        "type": "object",
        "properties": {
          "sourceId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "phone": {
            "type": "string",
            "example": "5554999990000"
          },
          "type": {
            "type": "string"
          },
          "archived": {
            "type": "boolean"
          },
          "action": {},
          "numberId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "sourceId",
          "name",
          "phone",
          "type",
          "archived",
          "action"
        ]
      },
      "ImportRecord": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "kind": {
            "type": "string"
          },
          "sourceId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "phones": {},
          "extra": {},
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "protocol": {},
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "end": {},
          "steps": {},
          "services": {},
          "auto": {},
          "pick": {},
          "action": {},
          "connOut": {},
          "contactOut": {},
          "blocked": {},
          "target": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "detail": {}
            },
            "required": [
              "id",
              "name"
            ]
          },
          "targets": {
            "type": "array",
            "items": {
              "description": "..."
            }
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "kind",
          "sourceId",
          "name",
          "auto",
          "action"
        ]
      },
      "ImportTag": {
        "type": "object",
        "properties": {
          "sourceId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "action": {},
          "target": {}
        },
        "required": [
          "sourceId",
          "name",
          "action"
        ]
      },
      "ImportUser": {
        "type": "object",
        "properties": {
          "sourceId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "sourceName": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "email": {
            "type": "string",
            "example": "ana@exemplo.com.br"
          },
          "archived": {
            "type": "boolean"
          },
          "admin": {
            "type": "boolean"
          },
          "departments": {},
          "action": {},
          "active": {
            "type": "boolean"
          },
          "accountId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          }
        },
        "required": [
          "sourceId",
          "sourceName",
          "name",
          "email",
          "archived",
          "admin",
          "departments",
          "action",
          "active"
        ]
      },
      "IntegCard": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "title": {
            "type": "string",
            "example": "Pedido 48211"
          },
          "operation": {
            "$ref": "#/components/schemas/Ref"
          },
          "stage": {
            "$ref": "#/components/schemas/Ref"
          },
          "contact": {
            "$ref": "#/components/schemas/Ref"
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "valueCents": {
            "type": "integer"
          },
          "owner": {
            "$ref": "#/components/schemas/Ref"
          },
          "note": {
            "type": "string"
          },
          "tags": {},
          "fields": {},
          "dueAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "closed": {},
          "lastActivityAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "title",
          "operation",
          "stage",
          "valueCents",
          "tags",
          "closed",
          "lastActivityAt",
          "createdAt"
        ]
      },
      "IntegContact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "pushName": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "5554999990000"
            }
          },
          "email": {
            "type": "string",
            "example": "ana@exemplo.com.br"
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string"
                },
                "value": {},
                "label": {
                  "type": "string"
                },
                "primary": {}
              },
              "required": [
                "kind",
                "value"
              ]
            }
          },
          "organizations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "role": {},
                "primary": {}
              },
              "required": [
                "id",
                "name"
              ]
            }
          },
          "birthday": {},
          "birthYear": {},
          "city": {},
          "notes": {},
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "fields": {},
          "optOutAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "lastMessageAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "name",
          "kind",
          "phones",
          "channels",
          "organizations",
          "tags",
          "createdAt"
        ]
      },
      "IntegConversation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "contact": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "phone": {
                "type": "string",
                "example": "5554999990000"
              }
            },
            "required": [
              "id",
              "name"
            ]
          },
          "number": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "channel": {}
            },
            "required": [
              "id",
              "name",
              "channel"
            ]
          },
          "operation": {
            "$ref": "#/components/schemas/Ref"
          },
          "owner": {
            "$ref": "#/components/schemas/Ref"
          },
          "status": {
            "type": "string"
          },
          "isGroup": {
            "type": "boolean"
          },
          "groupName": {
            "type": "string"
          },
          "tags": {},
          "unread": {},
          "lastMessage": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string"
              },
              "text": {
                "type": "string",
                "example": "Bom dia, o pedido já saiu?"
              },
              "fromMe": {},
              "status": {
                "type": "string"
              },
              "at": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              }
            },
            "required": [
              "kind",
              "fromMe",
              "at"
            ]
          },
          "lastMessageAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "card": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "operationId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "stageId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "stage": {}
            },
            "required": [
              "id",
              "operationId",
              "stageId",
              "stage"
            ]
          },
          "ticket": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "protocol": {},
              "openedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              }
            },
            "required": [
              "id",
              "openedAt"
            ]
          },
          "closed": {
            "type": "object",
            "properties": {
              "at": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              },
              "by": {},
              "idle": {}
            },
            "required": [
              "at"
            ]
          },
          "archived": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "contact",
          "number",
          "status",
          "isGroup",
          "tags",
          "unread",
          "lastMessageAt"
        ]
      },
      "IntegMessage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "fromMe": {},
          "author": {
            "$ref": "#/components/schemas/Ref"
          },
          "agent": {
            "$ref": "#/components/schemas/Ref"
          },
          "automation": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string"
              },
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            },
            "required": [
              "kind",
              "id",
              "name"
            ]
          },
          "senderName": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "aiText": {
            "type": "string"
          },
          "media": {
            "type": "object",
            "properties": {
              "mime": {
                "type": "string"
              },
              "size": {
                "type": "integer"
              },
              "fileName": {
                "type": "string"
              },
              "seconds": {
                "type": "integer"
              },
              "url": {
                "type": "string",
                "example": "https://exemplo.com.br"
              }
            },
            "required": [
              "mime",
              "size"
            ]
          },
          "location": {},
          "status": {
            "type": "string"
          },
          "edited": {},
          "revoked": {}
        },
        "required": [
          "id",
          "at",
          "fromMe",
          "kind"
        ]
      },
      "IntegProtocol": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "protocol": {},
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "contact": {
            "$ref": "#/components/schemas/Ref"
          },
          "number": {
            "$ref": "#/components/schemas/Ref"
          },
          "operation": {
            "$ref": "#/components/schemas/Ref"
          },
          "origin": {},
          "openedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "repliedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "repliedBy": {
            "$ref": "#/components/schemas/Ref"
          },
          "resolvedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "resolvedBy": {
            "$ref": "#/components/schemas/Ref"
          },
          "closeReason": {},
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string"
                },
                "at": {
                  "type": "string",
                  "format": "date-time",
                  "example": "2026-12-01T12:12:00Z"
                },
                "by": {},
                "from": {},
                "to": {
                  "type": "string",
                  "example": "+5554999990000"
                }
              },
              "required": [
                "kind",
                "at"
              ]
            }
          },
          "rating": {}
        },
        "required": [
          "id",
          "conversationId",
          "number",
          "origin",
          "openedAt",
          "events"
        ]
      },
      "IntegrationCall": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "key": {
            "$ref": "#/components/schemas/Ref"
          },
          "scope": {},
          "route": {},
          "count": {
            "type": "integer"
          },
          "result": {},
          "code": {
            "type": "string"
          },
          "error": {},
          "to": {
            "type": "string",
            "example": "+5554999990000"
          },
          "messageId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "ip": {},
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "key",
          "scope",
          "route",
          "count",
          "result",
          "at"
        ]
      },
      "IntegrationKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "end": {},
          "scopes": {
            "type": "array",
            "items": {
              "description": "Scope"
            }
          },
          "number": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "channel": {}
            },
            "required": [
              "id",
              "name",
              "channel"
            ]
          },
          "recipients": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "phone": {
                  "type": "string",
                  "example": "5554999990000"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              },
              "required": [
                "phone"
              ]
            }
          },
          "perMinute": {
            "type": "integer"
          },
          "enabled": {
            "type": "boolean"
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "createdBy": {
            "$ref": "#/components/schemas/Ref"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "updatedBy": {},
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "name",
          "end",
          "scopes",
          "recipients",
          "perMinute",
          "enabled",
          "createdBy",
          "createdAt",
          "updatedAt"
        ]
      },
      "KBAudience": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "all",
              "operations",
              "areas"
            ],
            "example": "all"
          },
          "operations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          },
          "areas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          }
        },
        "required": [
          "kind",
          "operations",
          "areas"
        ]
      },
      "KBPage": {
        "description": "{\n  \"id\": \"...\", \"kind\": \"page\", \"spaceId\": \"...\", \"parentId\": \"...\", \"order\": 0,\n  \"title\": \"Trocas e devoluções\", \"slug\": \"trocas-e-devolucoes\",\n  \"body\": \"## Prazo\\nAté **30 dias** com a nota.\", \"tag\": \"\",\n  \"visibility\": \"public\", \"areas\": [], \"ai\": true, \"aiLink\": true,\n  \"draft\": false, \"archived\": false, \"version\": 3,\n  \"helpful\": { \"yes\": 12, \"no\": 1 },\n  \"aiUse\": { \"month\": \"2026-11\", \"count\": 4, \"total\": 9, \"recent\": [ { \"conversationId\": \"...\", \"name\": \"Marina Souza\", \"agent\": \"Atendente IA\", \"at\": \"...\" } ] },\n  \"source\": { \"kind\": \"chat\", \"id\": \"...\", \"name\": \"Rafael Mendes\" },\n  \"createdBy\": { \"id\": \"...\", \"name\": \"Ana Lima\" }, \"updatedBy\": { \"id\": \"...\", \"name\": \"Ana Lima\" },\n  \"publishedAt\": \"...\", \"createdAt\": \"...\", \"updatedAt\": \"...\",\n  \"public\": true, \"url\": \"https://painel.exemplo.com.br/central/passo-firme/trocas-e-devolucoes\",\n  \"restrictedBy\": { \"id\": \"...\", \"name\": \"Procedimentos\" }, \"crumb\": [ Ref ], \"files\": { \"<id do arquivo>\": \"<link de 1 hora>\" }\n}"
      },
      "KBPageVersion": {
        "type": "object",
        "properties": {
          "pageId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "version": {
            "type": "number"
          },
          "title": {
            "type": "string",
            "example": "Pedido 48211"
          },
          "body": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "tag": {},
          "note": {
            "type": "string"
          },
          "author": {
            "$ref": "#/components/schemas/Ref"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "restored": {
            "type": "number"
          },
          "files": {}
        },
        "required": [
          "pageId",
          "version",
          "title",
          "author",
          "at",
          "files"
        ]
      },
      "KBSpace": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "title": {
            "type": "string",
            "example": "Pedido 48211"
          },
          "icon": {
            "type": "string"
          },
          "layout": {
            "type": "string",
            "enum": [
              "docs",
              "news"
            ],
            "example": "docs"
          },
          "visibility": {},
          "areas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          },
          "order": {
            "type": "integer"
          },
          "archived": {
            "type": "boolean"
          },
          "count": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "title",
          "icon",
          "layout",
          "visibility",
          "areas",
          "order",
          "archived",
          "count",
          "createdAt",
          "updatedAt"
        ]
      },
      "KBTrail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "title": {
            "type": "string",
            "example": "Pedido 48211"
          },
          "description": {
            "type": "string"
          },
          "audience": {
            "$ref": "#/components/schemas/KBAudience"
          },
          "archived": {
            "type": "boolean"
          },
          "mine": {},
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "title": {
                  "type": "string",
                  "example": "Pedido 48211"
                },
                "done": {},
                "open": {}
              },
              "required": [
                "id",
                "title",
                "done",
                "open"
              ]
            }
          },
          "questions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "example": "Bom dia, o pedido já saiu?"
                },
                "options": {}
              },
              "required": [
                "text",
                "options"
              ]
            }
          },
          "status": {
            "type": "object",
            "properties": {
              "done": {},
              "total": {
                "type": "integer"
              },
              "attempts": {},
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              },
              "completedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              }
            },
            "required": [
              "done",
              "total",
              "attempts"
            ]
          },
          "answers": {},
          "createdBy": {},
          "updatedBy": {},
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "title",
          "description",
          "audience",
          "archived",
          "mine",
          "steps",
          "questions",
          "status",
          "createdBy",
          "updatedBy",
          "updatedAt"
        ]
      },
      "KBTrailBody": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "example": "Pedido 48211"
          },
          "description": {
            "type": "string"
          },
          "pageIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          "questions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "example": "Bom dia, o pedido já saiu?"
                },
                "options": {},
                "answer": {}
              },
              "required": [
                "text",
                "options",
                "answer"
              ]
            }
          },
          "audience": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string"
              },
              "operationIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                }
              },
              "areaIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                }
              }
            },
            "required": [
              "kind"
            ]
          }
        },
        "required": [
          "title",
          "description",
          "pageIds",
          "questions",
          "audience"
        ]
      },
      "Message": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "waId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "fromMe": {
            "type": "boolean"
          },
          "author": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "senderName": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "status": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "media": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "url": {
                "type": "string",
                "example": "https://exemplo.com.br"
              },
              "mime": {
                "type": "string"
              },
              "size": {
                "type": "integer"
              },
              "fileName": {
                "type": "string"
              },
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "seconds": {
                "type": "integer"
              },
              "waveform": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              },
              "thumb": {
                "type": "string"
              },
              "animated": {
                "type": "boolean"
              },
              "missing": {
                "type": "boolean"
              },
              "tooLarge": {
                "type": "boolean"
              },
              "retry": {
                "type": "object",
                "properties": {
                  "at": {
                    "type": "string"
                  },
                  "error": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "location": {
            "type": "object",
            "properties": {
              "lat": {
                "type": "number"
              },
              "lng": {
                "type": "number"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "address": {
                "type": "string"
              },
              "live": {
                "type": "boolean"
              }
            }
          },
          "contacts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "vcard": {
                  "type": "string"
                },
                "phones": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "example": "5554999990000"
                  }
                }
              }
            }
          },
          "poll": {
            "type": "object",
            "properties": {
              "question": {
                "type": "string"
              },
              "selectable": {
                "type": "integer"
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    },
                    "votes": {
                      "type": "integer"
                    },
                    "mine": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "reactions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "emoji": {
                  "type": "string"
                },
                "fromMe": {
                  "type": "boolean"
                },
                "by": {
                  "type": "string"
                }
              }
            }
          },
          "quoted": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "waId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "kind": {
                "type": "string"
              },
              "text": {
                "type": "string",
                "example": "Bom dia, o pedido já saiu?"
              },
              "senderName": {
                "type": "string"
              }
            }
          },
          "link": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "example": "https://exemplo.com.br"
              },
              "title": {
                "type": "string",
                "example": "Pedido 48211"
              },
              "description": {
                "type": "string"
              },
              "thumb": {
                "type": "string"
              }
            }
          },
          "preview": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "example": "https://exemplo.com.br"
              },
              "site": {
                "type": "string",
                "example": "https://exemplo.com.br"
              },
              "title": {
                "type": "string",
                "example": "Pedido 48211"
              },
              "description": {
                "type": "string"
              },
              "image": {
                "type": "string"
              },
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "video": {
                "type": "boolean"
              }
            }
          },
          "noPreview": {
            "type": "boolean"
          },
          "edited": {
            "type": "boolean"
          },
          "revoked": {
            "type": "boolean"
          },
          "forwarded": {
            "type": "boolean"
          },
          "viewOnce": {
            "type": "boolean"
          },
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "example": {
          "id": "...",
          "conversationId": "...",
          "waId": "3EB0...",
          "fromMe": true,
          "author": {
            "id": "...",
            "name": "Rafael Mendes"
          },
          "senderName": "",
          "kind": "image",
          "text": "Legenda",
          "status": "read",
          "error": "",
          "media": {
            "id": "...",
            "url": "https://s3/...",
            "mime": "image/jpeg",
            "size": 183422,
            "fileName": "foto.jpg",
            "width": 1280,
            "height": 960,
            "seconds": 0,
            "waveform": [
              0,
              12,
              40
            ],
            "thumb": "<base64 jpeg>",
            "animated": false,
            "missing": false,
            "tooLarge": false,
            "retry": {
              "at": "...",
              "error": ""
            }
          },
          "location": {
            "lat": -23.5,
            "lng": -46.6,
            "name": "Loja Centro",
            "address": "...",
            "live": false
          },
          "contacts": [
            {
              "name": "Ana",
              "vcard": "BEGIN:VCARD...",
              "phones": [
                "5511..."
              ]
            }
          ],
          "poll": {
            "question": "Qual cor?",
            "selectable": 1,
            "options": [
              {
                "name": "Azul",
                "votes": 2,
                "mine": false
              }
            ]
          },
          "reactions": [
            {
              "emoji": "👍",
              "fromMe": false,
              "by": "Mariana Souza"
            }
          ],
          "quoted": {
            "id": "...",
            "waId": "...",
            "kind": "text",
            "text": "Trecho",
            "senderName": "Mariana Souza"
          },
          "link": {
            "url": "https://loja.exemplo.com.br/tenis",
            "title": "Tênis azul",
            "description": "...",
            "thumb": "<base64 jpeg>"
          },
          "preview": {
            "url": "https://loja.exemplo.com.br/tenis",
            "site": "Loja Exemplo",
            "title": "Tênis azul",
            "description": "...",
            "image": "https://s3/...",
            "width": 1200,
            "height": 630,
            "video": false
          },
          "noPreview": false,
          "edited": false,
          "revoked": false,
          "forwarded": false,
          "viewOnce": false,
          "operation": {
            "id": "...",
            "name": "Vendas"
          },
          "at": "2026-11-13T10:42:00Z"
        }
      },
      "Note": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "kind": {
            "type": "string"
          },
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "author": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "call": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "direction": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              },
              "answered": {
                "type": "boolean"
              },
              "seconds": {
                "type": "integer"
              },
              "path": {
                "type": "string"
              }
            }
          },
          "summary": {
            "type": "string"
          },
          "at": {
            "type": "string"
          },
          "editedAt": {
            "type": "string"
          }
        },
        "example": {
          "id": "...",
          "kind": "text",
          "text": "Combinou entrega na sexta.",
          "author": {
            "id": "...",
            "name": "Rafael Mendes"
          },
          "call": {
            "id": "...",
            "direction": "in",
            "status": "ended",
            "reason": "hangup",
            "answered": true,
            "seconds": 222,
            "path": "local"
          },
          "summary": "Resumo da ligação feito pela IA",
          "at": "...",
          "editedAt": "..."
        }
      },
      "Number": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "phone": {
            "type": "string",
            "example": "5554999990000"
          },
          "label": {
            "type": "string"
          },
          "channel": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "jid": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "pushName": {
            "type": "string"
          },
          "conector": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "calls": {
            "type": "boolean"
          },
          "operations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "areas": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "principal": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "statusAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "detail": {
            "type": "string"
          }
        },
        "example": {
          "id": "...",
          "phone": "5511977771020",
          "label": "Balcão da Loja Centro",
          "channel": "qr",
          "status": "connected",
          "jid": "5511977771020@s.whatsapp.net",
          "pushName": "Passo Firme",
          "conector": {
            "id": "...",
            "name": "PC do balcão"
          },
          "calls": true,
          "operations": [
            {
              "id": "...",
              "name": "Vendas"
            }
          ],
          "areas": [
            {
              "id": "...",
              "name": "Comercial"
            }
          ],
          "principal": {
            "id": "...",
            "name": "Vendas"
          },
          "statusAt": "2026-11-13T12:00:00Z",
          "detail": "Texto da última mudança"
        }
      },
      "NumberEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "numberId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "kind": {
            "type": "string"
          },
          "reason": {
            "type": "number"
          },
          "until": {},
          "detail": {},
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "numberId",
          "kind",
          "detail",
          "at"
        ]
      },
      "Operation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "area": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "cardLabel": {
            "type": "string"
          },
          "cardPlural": {
            "type": "string"
          },
          "cardGender": {
            "type": "string"
          },
          "money": {
            "type": "boolean"
          },
          "access": {
            "type": "string"
          },
          "areaRole": {
            "type": "string"
          },
          "people": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "role": {
                  "type": "string"
                }
              }
            }
          },
          "members": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "viewers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "managerIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          "flow": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "hideInMenu": {
            "type": "boolean"
          },
          "numbers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "ownNumbers": {
            "type": "boolean"
          },
          "stages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "color": {
                  "type": "string",
                  "example": "#2E7D32"
                },
                "sla": {
                  "type": "string"
                },
                "auto": {
                  "type": "string"
                },
                "message": {
                  "type": "string",
                  "example": "Bom dia, o pedido já saiu?"
                },
                "done": {
                  "type": "boolean"
                }
              }
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                }
              }
            }
          },
          "cardSections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "access": {
                  "type": "object",
                  "properties": {
                    "mode": {
                      "type": "string"
                    }
                  }
                },
                "fields": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string",
                        "example": "Ana Prado"
                      },
                      "type": {
                        "type": "string"
                      },
                      "requiredFrom": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "counts": {
            "type": "object",
            "properties": {
              "cards": {
                "type": "integer"
              },
              "late": {
                "type": "integer"
              }
            }
          }
        },
        "example": {
          "id": "...",
          "name": "Vendas",
          "area": {
            "id": "...",
            "name": "Comercial"
          },
          "cardLabel": "Venda",
          "cardPlural": "Vendas",
          "cardGender": "a",
          "money": true,
          "access": "area",
          "areaRole": "agent",
          "people": [
            {
              "id": "...",
              "name": "Rafael Mendes",
              "role": "manager"
            }
          ],
          "members": [
            {
              "id": "...",
              "name": "Rafael Mendes"
            }
          ],
          "viewers": [
            {
              "id": "...",
              "name": "Lúcia Prado"
            }
          ],
          "managerIds": [
            "..."
          ],
          "flow": {
            "id": "...",
            "name": "Boas-vindas de Vendas"
          },
          "hideInMenu": false,
          "numbers": [
            {
              "id": "...",
              "name": "Central de clientes"
            }
          ],
          "ownNumbers": false,
          "stages": [
            {
              "id": "...",
              "name": "Novo lead",
              "color": "info",
              "sla": "2 min",
              "auto": "",
              "message": "",
              "done": false
            }
          ],
          "tags": [
            {
              "id": "...",
              "name": "Aguardando peça"
            }
          ],
          "cardSections": [
            {
              "id": "...",
              "name": "Fechamento",
              "access": {
                "mode": "all"
              },
              "fields": [
                {
                  "key": "valor_cobrado",
                  "name": "Valor cobrado",
                  "type": "money",
                  "requiredFrom": "<id da etapa>"
                }
              ]
            }
          ],
          "counts": {
            "cards": 18,
            "late": 2
          }
        }
      },
      "Organization": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "kind": {
            "type": "string"
          },
          "legalName": {
            "type": "string"
          },
          "document": {},
          "site": {},
          "city": {},
          "notes": {},
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "fields": {},
          "people": {
            "type": "number"
          },
          "lastMessageAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "name",
          "kind",
          "tags",
          "createdAt",
          "people"
        ]
      },
      "Profile": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "system": {
            "type": "string",
            "enum": [
              "admin"
            ],
            "example": "admin"
          },
          "perms": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "allNumbers": {
            "type": "boolean"
          },
          "numbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          },
          "areas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          },
          "people": {
            "type": "number"
          }
        },
        "required": [
          "id",
          "name",
          "perms",
          "allNumbers",
          "numbers",
          "areas",
          "people"
        ]
      },
      "PushDevice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "endpoint": {},
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "lastOkAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "failures": {},
          "lastError": {}
        },
        "required": [
          "id",
          "endpoint",
          "name",
          "createdAt",
          "updatedAt"
        ]
      },
      "QuickReply": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "shortcut": {},
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "fileId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          }
        },
        "required": [
          "id",
          "shortcut",
          "text"
        ]
      },
      "Report": {
        "description": "{\n  \"from\": \"2026-10-15\", \"to\": \"2026-11-13\", \"timezone\": \"America/Sao_Paulo\",\n  \"since\": { \"tickets\": \"2026-11-13T12:00:00Z\", \"stages\": \"2026-11-13T12:05:00Z\" },\n  \"summary\": {\n    \"opened\": 182, \"unanswered\": 3, \"resolved\": 170, \"queue\": 4,\n    \"firstResponse\": { \"count\": 160, \"avg\": 540, \"p50\": 190, \"p90\": 1500 },\n    \"resolution\": { \"count\": 170, \"avg\": 30200, \"p50\": 7400, \"p90\": 86000 },\n    \"rating\": { \"count\": 64, \"avg\": 4.6 }\n  },\n  \"days\": [ { \"day\": \"2026-11-13\", \"opened\": 8, \"resolved\": 6 } ],\n  \"heat\": [ [0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 4, 2, 1, 0, 2, 3, 2, 1, 0, 0, 0, 0, 0, 0] ],\n  \"numbers\": [ { \"number\": Ref, \"opened\", \"resolved\", \"firstResponse\", \"resolution\", \"rating\" } ],\n  \"operations\": [ { \"operation\": Ref, \"opened\", \"resolved\", \"firstResponse\", \"resolution\", \"rating\" } ],\n  \"people\": [ { \"user\": Ref, \"replied\", \"firstResponse\", \"resolved\", \"resolution\", \"rating\" } ],\n  \"funnel\": [ { \"operation\": Ref, \"stages\": [\n    { \"id\": \"...\", \"name\": \"Proposta\", \"color\": \"warn\", \"done\": false, \"removed\": false,\n      \"entered\": 12, \"left\": 9, \"now\": 5, \"time\": { \"count\": 9, \"avg\": 0, \"p50\": 0, \"p90\": 0 } } ] } ]\n}"
      },
      "ReportChat": {
        "description": "{\n  \"from\": \"2026-10-19\", \"to\": \"2026-11-17\", \"timezone\": \"America/Sao_Paulo\",\n  \"summary\": { \"messages\": 1240, \"people\": 12, \"team\": 15, \"questions\": 10, \"solved\": 8,\n    \"acks\": 6, \"ackRate\": 92, \"kudos\": 4 },\n  \"days\": [ { \"day\": \"2026-11-17\", \"messages\": 58, \"people\": 9 } ],\n  \"channels\": [ { \"channel\": Ref, \"kind\": \"open\", \"messages\": 410, \"people\": 11 } ]\n}"
      },
      "SendBody": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string"
          },
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "fileId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "quotedId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "location": {
            "type": "object",
            "properties": {
              "lat": {
                "type": "integer"
              },
              "lng": {
                "type": "integer"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "address": {
                "type": "string"
              }
            }
          },
          "contacts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "vcard": {
                  "type": "string"
                }
              }
            }
          },
          "poll": {
            "type": "object",
            "properties": {
              "question": {
                "type": "string"
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "selectable": {
                "type": "integer"
              }
            }
          },
          "viewOnce": {
            "type": "boolean"
          },
          "noPreview": {
            "type": "boolean"
          },
          "template": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "params": {
                "type": "object",
                "properties": {
                  "header": {
                    "type": "array",
                    "items": {}
                  },
                  "body": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "Bom dia, o pedido já saiu?"
                    }
                  },
                  "buttons": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "headerFileId": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              }
            }
          }
        },
        "example": {
          "kind": "text|image|video|gif|audio|voice|document|sticker|location|contact|poll",
          "text": "texto ou legenda",
          "fileId": "id de POST /files (para tipos com arquivo)",
          "quotedId": "id da mensagem respondida",
          "location": {
            "lat": 0,
            "lng": 0,
            "name": "",
            "address": ""
          },
          "contacts": [
            {
              "name": "",
              "vcard": ""
            }
          ],
          "poll": {
            "question": "",
            "options": [
              "",
              ""
            ],
            "selectable": 1
          },
          "viewOnce": false,
          "noPreview": false,
          "template": {
            "id": "id do Template",
            "params": {
              "header": [],
              "body": [
                "Marina",
                "R$ 120,00"
              ],
              "buttons": [
                ""
              ]
            },
            "headerFileId": "id de POST /files"
          }
        }
      },
      "SendLimits": {
        "type": "object",
        "properties": {
          "minDelayMs": {
            "type": "number"
          },
          "maxDelayMs": {
            "type": "number"
          },
          "perDay": {
            "type": "number"
          },
          "newPerDay": {
            "type": "number"
          },
          "windowStart": {},
          "windowEnd": {},
          "typingPreSec": {
            "type": "number"
          }
        },
        "required": [
          "minDelayMs",
          "maxDelayMs",
          "perDay",
          "newPerDay",
          "windowStart",
          "windowEnd",
          "typingPreSec"
        ]
      },
      "Session": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "account": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "email": {
                "type": "string",
                "example": "ana@exemplo.com.br"
              }
            }
          },
          "company": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "timezone": {
                "type": "string"
              }
            }
          },
          "companies": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "admin": {
                  "type": "boolean"
                },
                "profile": {
                  "type": "string"
                }
              }
            }
          },
          "me": {
            "type": "object",
            "properties": {
              "admin": {
                "type": "boolean"
              },
              "operations": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "viewOnly": {
                "type": "array",
                "items": {}
              },
              "managerOf": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "profile": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  }
                }
              },
              "perms": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "allNumbers": {
                "type": "boolean"
              },
              "numberIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                }
              },
              "permissions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "passwordPending": {
                "type": "boolean"
              },
              "passwordLocked": {
                "type": "boolean"
              }
            }
          },
          "invites": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "company": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    }
                  }
                },
                "by": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    }
                  }
                },
                "admin": {
                  "type": "boolean"
                },
                "at": {
                  "type": "string",
                  "format": "date-time",
                  "example": "2026-12-01T12:12:00Z"
                }
              }
            }
          },
          "support": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "reason": {
                "type": "string"
              },
              "expiresAt": {
                "type": "string",
                "format": "date-time",
                "example": "2026-12-01T12:12:00Z"
              }
            }
          },
          "twoFactor": {
            "type": "object",
            "properties": {
              "on": {
                "type": "boolean"
              },
              "required": {
                "type": "boolean"
              },
              "pending": {
                "type": "boolean"
              }
            }
          }
        },
        "example": {
          "accessToken": "eyJ...",
          "expiresAt": "2026-11-13T15:00:00Z",
          "account": {
            "id": "...",
            "name": "Ana Lima",
            "email": "ana@exemplo.com.br"
          },
          "company": {
            "id": "...",
            "name": "Passo Firme",
            "timezone": "America/Sao_Paulo"
          },
          "companies": [
            {
              "id": "...",
              "name": "Passo Firme",
              "admin": true,
              "profile": "Administrador"
            }
          ],
          "me": {
            "admin": false,
            "operations": [
              "<id>"
            ],
            "viewOnly": [],
            "managerOf": [
              "<id>"
            ],
            "profile": {
              "id": "...",
              "name": "Supervisor"
            },
            "perms": [
              "allOperations",
              "team"
            ],
            "allNumbers": false,
            "numberIds": [
              "<id>"
            ],
            "permissions": [
              "conversations",
              "contacts",
              "operations",
              "team"
            ],
            "passwordPending": false,
            "passwordLocked": false
          },
          "invites": [
            {
              "company": {
                "id": "...",
                "name": "Loja Aurora"
              },
              "by": {
                "id": "...",
                "name": "Rafael Mendes"
              },
              "admin": false,
              "at": "2026-11-14T13:00:00Z"
            }
          ],
          "support": {
            "id": "...",
            "reason": "Chamado 1190",
            "expiresAt": "2026-11-13T15:30:00Z"
          },
          "twoFactor": {
            "on": true,
            "required": true,
            "pending": false
          }
        }
      },
      "Settings": {
        "type": "object",
        "properties": {
          "qrLimits": {
            "$ref": "#/components/schemas/SendLimits"
          },
          "companyName": {
            "type": "string",
            "example": "Padaria Bom Grão"
          },
          "attendance": {},
          "twoFactor": {
            "type": "string",
            "enum": [
              "none",
              "admins",
              "all"
            ],
            "example": "none"
          }
        },
        "required": [
          "qrLimits",
          "companyName",
          "attendance",
          "twoFactor"
        ]
      },
      "Survey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "question": {},
          "hours": {
            "type": "integer"
          },
          "thanks": {},
          "askComment": {},
          "default": {
            "type": "boolean"
          },
          "operations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          }
        },
        "required": [
          "id",
          "name",
          "question",
          "hours",
          "thanks",
          "askComment",
          "default",
          "operations"
        ]
      },
      "Tag": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "color": {},
          "usage": {
            "type": "object",
            "properties": {
              "contacts": {
                "type": "number"
              },
              "organizations": {
                "type": "number"
              },
              "flows": {
                "type": "number"
              },
              "campaigns": {
                "type": "number"
              }
            },
            "required": [
              "contacts",
              "organizations",
              "flows",
              "campaigns"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "color"
        ]
      },
      "Template": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "wabaId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "metaId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "language": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "paramFormat": {
            "type": "string"
          },
          "header": {
            "type": "object",
            "properties": {
              "format": {
                "type": "string"
              },
              "text": {
                "type": "string",
                "example": "Bom dia, o pedido já saiu?"
              }
            }
          },
          "body": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "footer": {
            "type": "string"
          },
          "buttons": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                },
                "text": {
                  "type": "string",
                  "example": "Bom dia, o pedido já saiu?"
                },
                "url": {
                  "type": "string",
                  "example": "https://exemplo.com.br"
                }
              }
            }
          },
          "rejectedReason": {
            "type": "string"
          },
          "createdBy": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              }
            }
          },
          "syncedAt": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "vars": {
            "type": "object",
            "properties": {
              "header": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "body": {
                "type": "array",
                "items": {
                  "type": "string",
                  "example": "Bom dia, o pedido já saiu?"
                }
              },
              "buttons": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "example": {
          "id": "...",
          "wabaId": "102290129340398",
          "metaId": "1187...",
          "name": "lembrete_pagamento",
          "language": "pt_BR",
          "category": "utility",
          "status": "approved",
          "paramFormat": "positional",
          "header": {
            "format": "text",
            "text": "Pedido {{1}}"
          },
          "body": "Olá, {{1}}! Seu pagamento de {{2}} vence amanhã.",
          "footer": "Loja Exemplo",
          "buttons": [
            {
              "type": "url",
              "text": "Ver pedido",
              "url": "https://loja.exemplo.com.br/p/{{1}}"
            }
          ],
          "rejectedReason": "",
          "createdBy": {
            "id": "...",
            "name": "Rafael Mendes"
          },
          "syncedAt": "...",
          "createdAt": "...",
          "updatedAt": "...",
          "vars": {
            "header": [
              "1"
            ],
            "body": [
              "1",
              "2"
            ],
            "buttons": [
              "1"
            ]
          }
        }
      },
      "TicketRow": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "number": {
            "$ref": "#/components/schemas/Ref"
          },
          "operation": {
            "$ref": "#/components/schemas/Ref"
          },
          "origin": {},
          "openedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "repliedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "resolvedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "protocol": {},
          "closeReason": {},
          "rating": {},
          "contact": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "6750a1c2e4b0a1b2c3d4e5f1"
              },
              "name": {
                "type": "string",
                "example": "Ana Prado"
              },
              "phone": {
                "type": "string",
                "example": "5554999990000"
              },
              "organizations": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    },
                    "name": {
                      "type": "string",
                      "example": "Ana Prado"
                    },
                    "role": {},
                    "primary": {}
                  },
                  "required": [
                    "id",
                    "name"
                  ]
                }
              }
            },
            "required": [
              "id",
              "name",
              "organizations"
            ]
          },
          "hits": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "at": {
                  "type": "string",
                  "format": "date-time",
                  "example": "2026-12-01T12:12:00Z"
                },
                "text": {
                  "type": "string",
                  "example": "Bom dia, o pedido já saiu?"
                },
                "fromMe": {
                  "type": "boolean"
                }
              },
              "required": [
                "id",
                "at",
                "text",
                "fromMe"
              ]
            }
          },
          "hitCount": {
            "type": "number"
          }
        },
        "required": [
          "id",
          "conversationId",
          "number",
          "origin",
          "openedAt"
        ]
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "email": {
            "type": "string",
            "example": "ana@exemplo.com.br"
          },
          "admin": {
            "type": "boolean"
          },
          "profile": {
            "$ref": "#/components/schemas/Ref"
          },
          "areas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          },
          "operations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          },
          "viewOnly": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "calendarId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disabled",
              "invited"
            ],
            "example": "active"
          },
          "lastSeenAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "ownAccount": {
            "type": "boolean"
          },
          "passwordPending": {},
          "passwordLocked": {},
          "invitedBy": {
            "$ref": "#/components/schemas/Ref"
          },
          "invitedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "title": {
            "type": "string",
            "example": "Pedido 48211"
          },
          "birthday": {},
          "birthYear": {},
          "since": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "birthdayQuiet": {},
          "signName": {
            "type": "string"
          },
          "managerOf": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ref"
            }
          },
          "idle": {
            "type": "string",
            "enum": [
              "away",
              "invite"
            ],
            "example": "away"
          },
          "idleKeptUntil": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          },
          "twoFactor": {},
          "photoUrl": {
            "type": "string",
            "example": "https://exemplo.com.br"
          }
        },
        "required": [
          "id",
          "name",
          "email",
          "admin",
          "areas",
          "operations",
          "viewOnly",
          "status",
          "ownAccount",
          "managerOf"
        ]
      },
      "Uso": {
        "type": "object",
        "properties": {
          "answers": {},
          "replies": {},
          "suggestions": {},
          "tests": {},
          "summaries": {},
          "conversations": {},
          "handoffs": {},
          "resolved": {},
          "inputTokens": {},
          "outputTokens": {},
          "cacheReadTokens": {},
          "cacheWriteTokens": {},
          "costMicros": {
            "type": "integer"
          },
          "transcriptions": {},
          "transcribedSeconds": {},
          "audios": {},
          "audioSeconds": {}
        },
        "required": [
          "answers",
          "replies",
          "suggestions",
          "tests",
          "summaries",
          "conversations",
          "handoffs",
          "resolved",
          "inputTokens",
          "outputTokens",
          "cacheReadTokens",
          "cacheWriteTokens",
          "costMicros",
          "transcriptions",
          "transcribedSeconds",
          "audios",
          "audioSeconds"
        ]
      }
    }
  },
  "x-webhooks": {
    "conv.message.in, conv.message.out": {
      "post": {
        "summary": "Mensagem recebida do contato ou enviada a ele",
        "description": "Evento: `conv.message.in`, `conv.message.out`.\n\nNa mensagem recebida não vem `autor`.",
        "operationId": "webhookConvMessageIn",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "autor": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "conexao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "contato": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      },
                      "telefone": {
                        "type": "string"
                      }
                    }
                  },
                  "conversa": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "protocolo": {
                        "type": "string"
                      },
                      "situacao": {
                        "type": "string"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "mensagem": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "texto": {
                        "type": "string"
                      },
                      "tipo": {
                        "type": "string"
                      }
                    }
                  },
                  "operacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "responsavel": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Avisar o CRM"
                  },
                  "autor": {
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  },
                  "conexao": {
                    "id": "6750a1c2e4b0a1b2c3d4e503",
                    "nome": "Vendas"
                  },
                  "contato": {
                    "id": "6750a1c2e4b0a1b2c3d4e504",
                    "nome": "Ana Prado",
                    "telefone": "5554999990000"
                  },
                  "conversa": {
                    "id": "6750a1c2e4b0a1b2c3d4e505",
                    "link": "https://app.whatzabot.com.br/conversas?c=6750a1c2e4b0a1b2c3d4e505",
                    "protocolo": "20261201-0042",
                    "situacao": "aberta"
                  },
                  "evento": "conv.message.out",
                  "mensagem": {
                    "id": "6750a1c2e4b0a1b2c3d4e506",
                    "texto": "Bom dia, o pedido já saiu?",
                    "tipo": "text"
                  },
                  "operacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e507",
                    "nome": "Vendas"
                  },
                  "quando": "2026-12-01T12:12:00Z",
                  "responsavel": {
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "conv.opened, conv.assigned, conv.transferred, conv.closed": {
      "post": {
        "summary": "Conversa aberta, assumida, passada a outra pessoa ou fechada",
        "description": "Evento: `conv.opened`, `conv.assigned`, `conv.transferred`, `conv.closed`.\n\n`de` (com quem a conversa estava e em que operação) só vem na assumida e na passada. Na fechada, `conversa.situacao` é `fechada`.",
        "operationId": "webhookConvOpened",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "autor": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "conexao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "contato": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      },
                      "telefone": {
                        "type": "string"
                      }
                    }
                  },
                  "conversa": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "protocolo": {
                        "type": "string"
                      },
                      "situacao": {
                        "type": "string"
                      }
                    }
                  },
                  "de": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      },
                      "operacao": {
                        "type": "string"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "operacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "responsavel": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Avisar o CRM"
                  },
                  "autor": {
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  },
                  "conexao": {
                    "id": "6750a1c2e4b0a1b2c3d4e503",
                    "nome": "Vendas"
                  },
                  "contato": {
                    "id": "6750a1c2e4b0a1b2c3d4e504",
                    "nome": "Ana Prado",
                    "telefone": "5554999990000"
                  },
                  "conversa": {
                    "id": "6750a1c2e4b0a1b2c3d4e505",
                    "link": "https://app.whatzabot.com.br/conversas?c=6750a1c2e4b0a1b2c3d4e505",
                    "protocolo": "20261201-0042",
                    "situacao": "aberta"
                  },
                  "de": {
                    "id": "6750a1c2e4b0a1b2c3d4e508",
                    "nome": "Rafael Mendes",
                    "operacao": "Suporte"
                  },
                  "evento": "conv.transferred",
                  "operacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e507",
                    "nome": "Vendas"
                  },
                  "quando": "2026-12-01T12:12:00Z",
                  "responsavel": {
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "card.stage": {
      "post": {
        "summary": "Cartão mudou de etapa",
        "description": "Evento: `card.stage`.",
        "operationId": "webhookCardStage",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "autor": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "cartao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "titulo": {
                        "type": "string"
                      }
                    }
                  },
                  "contato": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "etapa": {
                    "type": "object",
                    "properties": {
                      "anterior": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "operacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Avisar o CRM"
                  },
                  "autor": {
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  },
                  "cartao": {
                    "id": "6750a1c2e4b0a1b2c3d4e509",
                    "link": "https://app.whatzabot.com.br/operacao/6750a1c2e4b0a1b2c3d4e507?cartao=6750a1c2e4b0a1b2c3d4e509",
                    "titulo": "Pedido 48211"
                  },
                  "contato": {
                    "id": "6750a1c2e4b0a1b2c3d4e504",
                    "nome": "Ana Prado"
                  },
                  "etapa": {
                    "anterior": "Negociação",
                    "id": "6750a1c2e4b0a1b2c3d4e50a",
                    "nome": "Faturado"
                  },
                  "evento": "card.stage",
                  "operacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e507",
                    "nome": "Vendas"
                  },
                  "quando": "2026-12-01T12:12:00Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "chat.post": {
      "post": {
        "summary": "Mensagem publicada no chat interno",
        "description": "Evento: `chat.post`.\n\n`conversa` é a mensagem que abriu a conversa do chat interno (as respostas a ela). Fora de uma conversa, `conversa.id` é o da própria mensagem.",
        "operationId": "webhookChatPost",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "autor": {
                    "type": "object",
                    "properties": {
                      "email": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "canal": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "conversa": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "mensagem": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "texto": {
                        "type": "string"
                      }
                    }
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Avisar o CRM"
                  },
                  "autor": {
                    "email": "marina@exemplo.com.br",
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  },
                  "canal": {
                    "id": "6750a1c2e4b0a1b2c3d4e50b",
                    "nome": "vendas"
                  },
                  "conversa": {
                    "id": "6750a1c2e4b0a1b2c3d4e50c",
                    "link": "https://app.whatzabot.com.br/chat?c=6750a1c2e4b0a1b2c3d4e50b&t=6750a1c2e4b0a1b2c3d4e50c"
                  },
                  "evento": "chat.post",
                  "mensagem": {
                    "id": "6750a1c2e4b0a1b2c3d4e50d",
                    "link": "https://app.whatzabot.com.br/chat?c=6750a1c2e4b0a1b2c3d4e50b&t=6750a1c2e4b0a1b2c3d4e50c&p=6750a1c2e4b0a1b2c3d4e50d",
                    "texto": "Tudo certo, pode lançar."
                  },
                  "quando": "2026-12-01T12:33:00Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "chat.bot": {
      "post": {
        "summary": "Chamaram um robô no chat interno",
        "description": "Evento: `chat.bot`.\n\n`conversa.mensagens` só vem com **A conversa inteira** marcada no começo da automação: a mensagem que abriu a conversa e as respostas, da mais antiga para a mais nova (até cerca de 80 KB de texto). `robo.chamado` diz como o robô foi chamado: `@nome` (menção) ou `!nome` (palavra no começo da mensagem).",
        "operationId": "webhookChatBot",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "autor": {
                    "type": "object",
                    "properties": {
                      "email": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "canal": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "conversa": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "mensagens": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "quando": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "autor": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "nome": {
                                  "type": "string"
                                }
                              }
                            },
                            "texto": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "mensagem": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "texto": {
                        "type": "string"
                      }
                    }
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "robo": {
                    "type": "object",
                    "properties": {
                      "chamado": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Pedidos"
                  },
                  "autor": {
                    "email": "marina@exemplo.com.br",
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  },
                  "canal": {
                    "id": "6750a1c2e4b0a1b2c3d4e50b",
                    "nome": "vendas"
                  },
                  "conversa": {
                    "id": "6750a1c2e4b0a1b2c3d4e50c",
                    "link": "https://app.whatzabot.com.br/chat?c=6750a1c2e4b0a1b2c3d4e50b&t=6750a1c2e4b0a1b2c3d4e50c",
                    "mensagens": [
                      {
                        "id": "6750a1c2e4b0a1b2c3d4e50c",
                        "quando": "2026-12-01T12:12:00Z",
                        "autor": {
                          "id": "6750a1c2e4b0a1b2c3d4e502",
                          "nome": "Marina Souza"
                        },
                        "texto": "Cliente Padaria Bom Grão fechou 40 caixas."
                      },
                      {
                        "id": "6750a1c2e4b0a1b2c3d4e50d",
                        "quando": "2026-12-01T12:33:00Z",
                        "autor": {
                          "id": "6750a1c2e4b0a1b2c3d4e502",
                          "nome": "Marina Souza"
                        },
                        "texto": "Tudo certo. @pedidos pode lançar"
                      }
                    ]
                  },
                  "evento": "chat.bot",
                  "mensagem": {
                    "id": "6750a1c2e4b0a1b2c3d4e50d",
                    "link": "https://app.whatzabot.com.br/chat?c=6750a1c2e4b0a1b2c3d4e50b&t=6750a1c2e4b0a1b2c3d4e50c&p=6750a1c2e4b0a1b2c3d4e50d",
                    "texto": "Tudo certo. @pedidos pode lançar"
                  },
                  "quando": "2026-12-01T12:33:00Z",
                  "robo": {
                    "chamado": "@pedidos",
                    "nome": "Pedidos"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "kb.created, kb.updated, kb.published": {
      "post": {
        "summary": "Página do Conhecimento criada, alterada ou publicada",
        "description": "Evento: `kb.created`, `kb.updated`, `kb.published`.",
        "operationId": "webhookKbCreated",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "autor": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "espaco": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "pagina": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "titulo": {
                        "type": "string"
                      },
                      "versao": {
                        "type": "integer"
                      }
                    }
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Avisar o CRM"
                  },
                  "autor": {
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  },
                  "espaco": {
                    "id": "6750a1c2e4b0a1b2c3d4e50e",
                    "nome": "Atendimento"
                  },
                  "evento": "kb.published",
                  "pagina": {
                    "id": "6750a1c2e4b0a1b2c3d4e50f",
                    "link": "https://app.whatzabot.com.br/conhecimento?p=6750a1c2e4b0a1b2c3d4e50f",
                    "titulo": "Política de trocas",
                    "versao": 3
                  },
                  "quando": "2026-12-01T12:12:00Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "contact.created, contact.updated, contact.tag": {
      "post": {
        "summary": "Contato criado, alterado, ou etiqueta posta ou tirada",
        "description": "Evento: `contact.created`, `contact.updated`, `contact.tag`.\n\n`etiqueta` só vem no `contact.tag` (`acao`: `posta` ou `tirada`). No contato criado pelo WhatsApp, na primeira mensagem, `autor` vem com o `nome` vazio.",
        "operationId": "webhookContactCreated",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "autor": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "contato": {
                    "type": "object",
                    "properties": {
                      "email": {
                        "type": "string"
                      },
                      "empresa": {
                        "type": "string"
                      },
                      "etiquetas": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      },
                      "telefone": {
                        "type": "string"
                      }
                    }
                  },
                  "etiqueta": {
                    "type": "object",
                    "properties": {
                      "acao": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Avisar o CRM"
                  },
                  "autor": {
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  },
                  "contato": {
                    "email": "ana@exemplo.com.br",
                    "empresa": "Padaria Bom Grão",
                    "etiquetas": "cliente, atacado",
                    "id": "6750a1c2e4b0a1b2c3d4e504",
                    "nome": "Ana Prado",
                    "telefone": "5554999990000"
                  },
                  "etiqueta": {
                    "acao": "posta",
                    "nome": "atacado"
                  },
                  "evento": "contact.tag",
                  "quando": "2026-12-01T12:12:00Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "call.received, call.answered, call.missed": {
      "post": {
        "summary": "Ligação recebida, atendida ou perdida",
        "description": "Evento: `call.received`, `call.answered`, `call.missed`.\n\n`ligacao.duracao` em segundos. Na perdida, `atendente` vem com o nome vazio.",
        "operationId": "webhookCallReceived",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "atendente": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "conexao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "contato": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      },
                      "telefone": {
                        "type": "string"
                      }
                    }
                  },
                  "conversa": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "situacao": {
                        "type": "string"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "ligacao": {
                    "type": "object",
                    "properties": {
                      "duracao": {
                        "type": "integer"
                      },
                      "id": {
                        "type": "string"
                      }
                    }
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "example": {
                  "atendente": {
                    "id": "6750a1c2e4b0a1b2c3d4e502",
                    "nome": "Marina Souza"
                  },
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Avisar o CRM"
                  },
                  "conexao": {
                    "id": "6750a1c2e4b0a1b2c3d4e503",
                    "nome": "Vendas"
                  },
                  "contato": {
                    "id": "6750a1c2e4b0a1b2c3d4e504",
                    "nome": "Ana Prado",
                    "telefone": "5554999990000"
                  },
                  "conversa": {
                    "id": "6750a1c2e4b0a1b2c3d4e505",
                    "link": "https://app.whatzabot.com.br/conversas?c=6750a1c2e4b0a1b2c3d4e505",
                    "situacao": "aberta"
                  },
                  "evento": "call.answered",
                  "ligacao": {
                    "duracao": 95,
                    "id": "6750a1c2e4b0a1b2c3d4e510"
                  },
                  "quando": "2026-12-01T12:12:00Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "campaign.done": {
      "post": {
        "summary": "Campanha terminou",
        "description": "Evento: `campaign.done`.",
        "operationId": "webhookCampaignDone",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "campanha": {
                    "type": "object",
                    "properties": {
                      "enviadas": {
                        "type": "integer"
                      },
                      "falhas": {
                        "type": "integer"
                      },
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      },
                      "total": {
                        "type": "integer"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Avisar o CRM"
                  },
                  "campanha": {
                    "enviadas": 118,
                    "falhas": 2,
                    "id": "6750a1c2e4b0a1b2c3d4e511",
                    "link": "https://app.whatzabot.com.br/campanhas?c=6750a1c2e4b0a1b2c3d4e511",
                    "nome": "Promoção de dezembro",
                    "total": 120
                  },
                  "evento": "campaign.done",
                  "quando": "2026-12-01T12:12:00Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "flow.failed": {
      "post": {
        "summary": "Fluxo terminou com erro",
        "description": "Evento: `flow.failed`.",
        "operationId": "webhookFlowFailed",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "conexao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "contato": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      },
                      "telefone": {
                        "type": "string"
                      }
                    }
                  },
                  "conversa": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "fluxo": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "motivo": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Avisar o CRM"
                  },
                  "conexao": {
                    "id": "6750a1c2e4b0a1b2c3d4e503",
                    "nome": "Vendas"
                  },
                  "contato": {
                    "id": "6750a1c2e4b0a1b2c3d4e504",
                    "nome": "Ana Prado",
                    "telefone": "5554999990000"
                  },
                  "conversa": {
                    "id": "6750a1c2e4b0a1b2c3d4e505",
                    "link": "https://app.whatzabot.com.br/conversas?c=6750a1c2e4b0a1b2c3d4e505"
                  },
                  "evento": "flow.failed",
                  "fluxo": {
                    "id": "6750a1c2e4b0a1b2c3d4e512",
                    "motivo": "O endereço do CRM não respondeu.",
                    "nome": "Boas-vindas"
                  },
                  "quando": "2026-12-01T12:12:00Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    },
    "hook": {
      "post": {
        "summary": "Outro sistema chamou o endereço próprio da automação",
        "description": "Evento: `hook`.\n\nO endereço próprio é o `POST /hooks/{token}`. `pedido` traz o corpo recebido em texto (`corpo`), o IP de quem chamou (`ip`), cada campo do JSON recebido, com o nome em letras minúsculas, e os parâmetros do endereço em `query`.",
        "operationId": "webhookHook",
        "parameters": [
          {
            "name": "X-WhatzaBot-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "1796207925"
            },
            "description": "Hora do envio, em segundos desde 1970 (só com Assinar o pedido ligado)."
          },
          {
            "name": "X-WhatzaBot-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "example": "sha256=5f2b…"
            },
            "description": "`sha256=` e o HMAC-SHA256 de `<timestamp>.<corpo>` com a chave de assinatura da automação."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "automacao": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "chave": {
                    "type": "object",
                    "properties": {
                      "nome": {
                        "type": "string"
                      }
                    }
                  },
                  "evento": {
                    "type": "string"
                  },
                  "pedido": {
                    "type": "object",
                    "properties": {
                      "corpo": {
                        "type": "string"
                      },
                      "ip": {
                        "type": "string"
                      },
                      "pedido": {
                        "type": "string"
                      },
                      "situacao": {
                        "type": "string"
                      }
                    }
                  },
                  "quando": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "example": {
                  "automacao": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "nome": "Pedido faturado"
                  },
                  "chave": {
                    "nome": "ERP da loja"
                  },
                  "evento": "hook",
                  "pedido": {
                    "corpo": "{\"pedido\":\"48211\",\"situacao\":\"faturado\"}",
                    "ip": "203.0.113.10",
                    "pedido": "48211",
                    "situacao": "faturado"
                  },
                  "quando": "2026-12-01T12:12:00Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx dá certo. Sem resposta em 10 s ou com 5xx, o WhatzaBot tenta de novo (se a opção estiver ligada)."
          }
        },
        "tags": [
          "Automações: o que o Chamar endereço manda"
        ]
      }
    }
  }
}
