{
  "openapi": "3.0.3",
  "info": {
    "title": "API do WhatzaBot",
    "version": "0.1.0",
    "description": "Use esta API para ligar outro sistema ao WhatzaBot: mandar mensagens pelo WhatsApp da empresa, consultar contatos, conversas, cartões e protocolos, e começar uma automação.\n\nPara isso, um administrador da empresa deverá criar uma chave de integração (`wzb_…`) no painel, em Configurações › Integrações, com os escopos que o sistema vai usar. A chave vai em todo pedido, no cabeçalho `Authorization: Bearer`.\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\". O sistema que atende as conversas passadas por um robô recebe as mensagens como mostra a seção \"Robôs: o que o Passar a outro sistema manda\"."
  },
  "servers": [
    {
      "url": "https://api.whatzabot.com.br",
      "description": "Produção"
    }
  ],
  "tags": [
    {
      "name": "Automações"
    },
    {
      "name": "Mandar mensagem (sem sessão)",
      "description": "Integração"
    },
    {
      "name": "Consultar dados (sem sessão)",
      "description": "Integração"
    },
    {
      "name": "Cadastrar e alterar (sem sessão)",
      "description": "Integração"
    },
    {
      "name": "Atender a conversa passada pelo robô (sem sessão)",
      "description": "Integração"
    },
    {
      "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```"
    },
    {
      "name": "Robôs: o que o Passar a outro sistema manda",
      "description": "O bloco **Passar a outro sistema** de um robô manda ao endereço escrito\nnele um `POST` com JSON a cada passo da conversa que está com o sistema. O\ncampo `event` diz qual é. Os exemplos abaixo mostram o JSON de cada um.\n\nComo o pedido chega:\n\n- **Cabeçalhos:** `Content-Type: application/json`,\n  `User-Agent: WhatzaBot-Fluxos/1` e o cabeçalho da credencial escolhida no\n  bloco, se houver.\n- **Resposta:** qualquer 2xx confirma; o corpo não é lido. Sem resposta,\n  com 429 ou 5xx, o WhatzaBot tenta de novo depois de 10 s, 1 min e 5 min,\n  e depois o robô segue pela saída \"Deu erro\". O `ended` vai uma vez só.\n- **Depois:** o sistema responde ao contato pelo endereço `reply` e devolve\n  a conversa ao robô pelo `release`, com a chave de integração do bloco\n  (rotas acima). `reply` e `release` só vêm com o `API_PUBLIC_URL`\n  configurado."
    }
  ],
  "paths": {
    "/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/integration/messages": {
      "post": {
        "tags": [
          "Mandar mensagem (sem sessão)"
        ],
        "summary": "Mandar mensagem pela integração",
        "operationId": "postIntegrationMessages",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `send`\n\n**Corpo:** `{ numberId, to, text, name? }`: `numberId` é a conexão por QR Code que manda (de `GET /integration/numbers`; as chaves de antes, com a conexão fixa, podem mandar sem ele); `to`, o telefone com DDI (`+5554999990000`; o 9º dígito do celular brasileiro vale com ou sem); `text`, até 4.096 letras, só texto nesta versão; `name`, o nome do contato novo, até 60 letras\n\n**Resposta:** `202 { id: string, status: \"queued\"|\"held\", messageId: string, conversationId: string }`; `401 invalid_key`, `403 key_disabled`, `403 company_suspended`, `403 ip_not_allowed`, `403 missing_scope`, `409 number_removed`, `409 outside_window`, `409 daily_limit`, `409 daily_new_limit`, `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": {
                  "numberId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "to": {
                    "type": "string",
                    "example": "+5554999990000"
                  },
                  "text": {
                    "type": "string",
                    "example": "Bom dia, o pedido já saiu?"
                  },
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  }
                },
                "required": [
                  "numberId",
                  "to",
                  "text"
                ],
                "description": "`numberId` é a conexão por QR Code que manda (de `GET /integration/numbers`; as chaves de antes, com a conexão fixa, podem mandar sem ele); `to`, o telefone com DDI (`+5554999990000`; o 9º dígito do celular brasileiro vale com ou sem); `text`, até 4.096 letras, só texto nesta versão; `name`, o nome do contato novo, até 60 letras"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "`202 { id: string, status: \"queued\"|\"held\", messageId: string, conversationId: string }`; `401 invalid_key`, `403 key_disabled`, `403 company_suspended`, `403 ip_not_allowed`, `403 missing_scope`, `409 number_removed`, `409 outside_window`, `409 daily_limit`, `409 daily_new_limit`, `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`, `ip_not_allowed`, `missing_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`number_removed`, `outside_window`, `daily_limit`, `daily_new_limit`",
            "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 '{\"numberId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"to\":\"+5554999990000\",\"text\":\"Bom dia, o pedido já saiu?\",\"name\":\"Ana Prado\"}'"
          }
        ]
      }
    },
    "/api/v1/integration/numbers": {
      "get": {
        "tags": [
          "Mandar mensagem (sem sessão)"
        ],
        "summary": "Listar conexões que mandam pela integração",
        "operationId": "getIntegrationNumbers",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `send`\n\n**Resposta:** `{ data: [IntegNumber] }`: os números por QR Code num Conector, por nome",
        "responses": {
          "200": {
            "description": "`{ data: [IntegNumber] }`: os números por QR Code num Conector, por nome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegNumber"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/numbers\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/messages/{id}": {
      "get": {
        "tags": [
          "Mandar mensagem (sem sessão)"
        ],
        "summary": "Ver a situação de uma mensagem mandada pela integração",
        "operationId": "getIntegrationMessagesById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `messages`\n\n**Resposta:** `IntegSentMessage`, só das mandadas por esta chave; `status`: `held`, `pending`, `queued`, `sent`, `delivered`, `read`, `played` ou `failed`. `404 not_found`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`IntegSentMessage`, só das mandadas por esta chave; `status`: `held`, `pending`, `queued`, `sent`, `delivered`, `read`, `played` ou `failed`. `404 not_found`"
          },
          "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"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/messages/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/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": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/contacts\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      },
      "post": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Criar contato pela integração",
        "operationId": "postIntegrationContacts",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `contacts:write`\n\n**Corpo:** `{ name, phones?, email?, kind?, city?, notes?, tags?, organizations?: [{ id, role?, primary? }], birthday?, birthYear?, fields? }`: `phones` com DDI; `kind` `cliente` (o padrão), `fornecedor` ou `colaborador`; `fields` pela chave do campo personalizado\n\n**Resposta:** `201 IntegContact`. `409 phone_taken` com `details.contactId` quando o telefone já é de outro contato (para alterar esse em vez de criar); `422 validation`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Ana Prado"
                  },
                  "phones": {},
                  "email": {
                    "type": "string",
                    "example": "ana@exemplo.com.br"
                  },
                  "kind": {
                    "type": "string"
                  },
                  "city": {},
                  "notes": {},
                  "tags": {},
                  "organizations": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "6750a1c2e4b0a1b2c3d4e5f1"
                        },
                        "role": {},
                        "primary": {}
                      },
                      "required": [
                        "id"
                      ]
                    }
                  },
                  "birthday": {},
                  "birthYear": {},
                  "fields": {}
                },
                "required": [
                  "name"
                ],
                "description": "`phones` com DDI; `kind` `cliente` (o padrão), `fornecedor` ou `colaborador`; `fields` pela chave do campo personalizado"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 IntegContact`. `409 phone_taken` com `details.contactId` quando o telefone já é de outro contato (para alterar esse em vez de criar); `422 validation`",
            "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"
                }
              }
            }
          },
          "409": {
            "description": "`phone_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "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/contacts\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"email\":\"ana@exemplo.com.br\",\"kind\":\"texto\",\"organizations\":[{\"id\":\"6750a1c2e4b0a1b2c3d4e5f1\"}]}'"
          }
        ]
      }
    },
    "/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": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/contacts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Alterar contato pela integração",
        "operationId": "patchIntegrationContactsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `contacts:write`\n\n**Corpo:** o mesmo do `POST`, só o que muda; `tags` troca a lista inteira\n\n**Resposta:** `IntegContact`. `404 not_found`, `409 phone_taken`, `422 validation`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "o mesmo do `POST`, só o que muda; `tags` troca a lista inteira"
              }
            }
          },
          "description": "o mesmo do `POST`, só o que muda; `tags` troca a lista inteira"
        },
        "responses": {
          "200": {
            "description": "`IntegContact`. `404 not_found`, `409 phone_taken`, `422 validation`",
            "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"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`phone_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/integration/contacts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Apagar contato pela integração",
        "operationId": "deleteIntegrationContactsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `contacts:delete`\n\n**Resposta:** `204`; o contato sai das listas e entra em `GET /integration/contacts/deleted`. `404 not_found`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; o contato sai das listas e entra em `GET /integration/contacts/deleted`. `404 not_found`"
          },
          "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"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/integration/contacts/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/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": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/conversations\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/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": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Passar ou fechar a conversa pela integração",
        "operationId": "patchIntegrationConversationsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `conversations:write`\n\n**Corpo:** `{ operationId?, ownerId?, status? }`: `operationId` passa para a operação (que atenda o número da conversa); `ownerId` passa para o usuário (`null` volta para a fila); `status` só `\"resolved\"`, que fecha\n\n**Resposta:** `IntegConversation`. `404 not_found`, `422 validation`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "ownerId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "description": "`operationId` passa para a operação (que atenda o número da conversa); `ownerId` passa para o usuário (`null` volta para a fila); `status` só `\"resolved\"`, que fecha"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`IntegConversation`. `404 not_found`, `422 validation`",
            "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"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"operationId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"ownerId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"status\":\"texto\"}'"
          }
        ]
      }
    },
    "/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": [
          {
            "chaveIntegracao": []
          }
        ],
        "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 $CHAVE_WZB\""
          }
        ]
      },
      "post": {
        "tags": [
          "Atender a conversa passada pelo robô (sem sessão)"
        ],
        "summary": "Responder ao contato pela integração",
        "operationId": "postIntegrationConversationsByIdMessages",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `handover`\n\n**Corpo:** `{ text }`, até 4.096 letras\n\n**Resposta:** `202 { id, status: \"queued\"|\"held\", messageId, conversationId }`; `404 conversation_not_found`, `409 not_with_system`, `409 number_removed`, `409 no_conector`, `422 validation`, `429 rate_limited`",
        "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é 4.096 letras"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "`202 { id, status: \"queued\"|\"held\", messageId, conversationId }`; `404 conversation_not_found`, `409 not_with_system`, `409 number_removed`, `409 no_conector`, `422 validation`, `429 rate_limited`",
            "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": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`conversation_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_with_system`, `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"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e5f1/messages\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\"}'"
          }
        ]
      }
    },
    "/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": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/cards\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      },
      "post": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Criar cartão pela integração",
        "operationId": "postIntegrationCards",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `cards:write`\n\n**Corpo:** `{ operationId, title?, stageId?, contactId?, conversationId?, valueCents?, ownerId?, note?, dueAt?, tags?, fields? }`: sem `stageId`, a primeira etapa; sem `ownerId`, sem responsável\n\n**Resposta:** `201 IntegCard`. `422 validation` (operação, etapa, contato, usuário ou campo obrigatório)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operationId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  },
                  "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": {},
                  "fields": {}
                },
                "required": [
                  "operationId"
                ],
                "description": "sem `stageId`, a primeira etapa; sem `ownerId`, sem responsável"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 IntegCard`. `422 validation` (operação, etapa, contato, usuário ou campo obrigatório)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegCard"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "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/cards\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"operationId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"title\":\"Pedido 48211\",\"stageId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"contactId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"conversationId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"valueCents\":0,\"ownerId\":\"6750a1c2e4b0a1b2c3d4e5f1\",\"note\":\"texto\",\"dueAt\":\"2026-12-01T12:12:00Z\"}'"
          }
        ]
      }
    },
    "/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": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/protocols\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/organizations": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Buscar empresas pela integração",
        "operationId": "getIntegrationOrganizations",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `organizations`\n\n**Resposta:** `{ data: [IntegOrganization], next }`, da criada por último. Só as não apagadas\n\n**Regra:** `name` (pedaço, até 100 letras), `document` (CNPJ ou CPF), `updatedSince` (criadas desde), `limit`, `cursor`",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "Ana Prado"
            }
          },
          {
            "name": "document",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "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: [IntegOrganization], next }`, da criada por último. Só as não apagadas",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegOrganization"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/organizations\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      },
      "post": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Criar empresa pela integração",
        "operationId": "postIntegrationOrganizations",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `organizations:write`\n\n**Corpo:** `{ name, kind?, legalName?, document?, site?, city?, notes?, tags?, fields? }`\n\n**Resposta:** `201 IntegOrganization`. `409` com o nome ou o documento de outra empresa; `422 validation`",
        "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"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 IntegOrganization`. `409` com o nome ou o documento de outra empresa; `422 validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegOrganization"
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "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/organizations\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Ana Prado\",\"kind\":\"texto\",\"legalName\":\"texto\"}'"
          }
        ]
      }
    },
    "/api/v1/integration/organizations/{id}": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Ver uma empresa pela integração",
        "operationId": "getIntegrationOrganizationsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `organizations`\n\n**Resposta:** `IntegOrganization`; a juntada a outra volta como a que ficou (outro `id`)\n\n**Regra:** —",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`IntegOrganization`; a juntada a outra volta como a que ficou (outro `id`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegOrganization"
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/organizations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      },
      "patch": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Alterar empresa pela integração",
        "operationId": "patchIntegrationOrganizationsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `organizations:write`\n\n**Corpo:** o mesmo do `POST`, só o que muda\n\n**Resposta:** `IntegOrganization`. `404 not_found`, `409`, `422 validation`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "o mesmo do `POST`, só o que muda"
              }
            }
          },
          "description": "o mesmo do `POST`, só o que muda"
        },
        "responses": {
          "200": {
            "description": "`IntegOrganization`. `404 not_found`, `409`, `422 validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegOrganization"
                }
              }
            }
          },
          "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": "Ver a descrição da rota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/integration/organizations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      },
      "delete": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Apagar empresa pela integração",
        "operationId": "deleteIntegrationOrganizationsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `organizations:delete`\n\n**Resposta:** `204`; os contatos dela ficam, sem a empresa. `404 not_found`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "`204`; os contatos dela ficam, sem a empresa. `404 not_found`"
          },
          "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"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/integration/organizations/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/calls": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Buscar ligações pela integração",
        "operationId": "getIntegrationCalls",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `calls`\n\n**Resposta:** `{ data: [IntegCall], next }`, da mais nova\n\n**Regra:** `conversationId`, `direction` (`in`: o contato ligou; `out`: a equipe ligou), `status` (`answered`, `ended`, `missed`, `failed`), `since` (começadas desde), `limit`, `cursor`",
        "parameters": [
          {
            "name": "conversationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          },
          {
            "name": "direction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "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: [IntegCall], next }`, da mais nova",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegCall"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/calls\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/opt-outs": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Buscar quem não recebe campanhas pela integração",
        "operationId": "getIntegrationOptOuts",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `optouts`\n\n**Resposta:** `{ data: [IntegOptOut], next }`, do marcado por último\n\n**Regra:** `since` (marcados desde), `limit`, `cursor`",
        "parameters": [
          {
            "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: [IntegOptOut], next }`, do marcado por último",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegOptOut"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/opt-outs\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      },
      "post": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Marcar quem não recebe campanhas pela integração",
        "operationId": "postIntegrationOptOuts",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `optouts:write`\n\n**Corpo:** `{ contactId }`\n\n**Resposta:** `IntegOptOut`; o contato deixa de receber campanhas e avisos. `404 not_found`",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contactId": {
                    "type": "string",
                    "example": "6750a1c2e4b0a1b2c3d4e5f1"
                  }
                },
                "required": [
                  "contactId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`IntegOptOut`; o contato deixa de receber campanhas e avisos. `404 not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegOptOut"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.whatzabot.com.br/api/v1/integration/opt-outs\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"contactId\":\"6750a1c2e4b0a1b2c3d4e5f1\"}'"
          }
        ]
      }
    },
    "/api/v1/integration/contacts/deleted": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Listar contatos apagados pela integração",
        "operationId": "getIntegrationContactsDeleted",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `contacts`\n\n**Resposta:** `{ data: [Deletion], next }`, do mais antigo para o mais novo, por 90 dias\n\n**Regra:** `since` (apagados desde), `limit`, `cursor`",
        "parameters": [
          {
            "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: [Deletion], next }`, do mais antigo para o mais novo, por 90 dias",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Deletion"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/contacts/deleted\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/organizations/deleted": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Listar empresas apagadas pela integração",
        "operationId": "getIntegrationOrganizationsDeleted",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `organizations`\n\n**Resposta:** `{ data: [Deletion], next }`, do mais antigo para o mais novo, por 90 dias\n\n**Regra:** `since`, `limit`, `cursor`",
        "parameters": [
          {
            "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: [Deletion], next }`, do mais antigo para o mais novo, por 90 dias",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Deletion"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/organizations/deleted\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/cards/deleted": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Listar cartões apagados pela integração",
        "operationId": "getIntegrationCardsDeleted",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `cards`\n\n**Resposta:** `{ data: [Deletion], next }`, do mais antigo para o mais novo, por 90 dias\n\n**Regra:** `since`, `limit`, `cursor`",
        "parameters": [
          {
            "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: [Deletion], next }`, do mais antigo para o mais novo, por 90 dias",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Deletion"
                      }
                    },
                    "next": {}
                  },
                  "required": [
                    "data",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/cards/deleted\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/operations": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Listar operações pela integração",
        "operationId": "getIntegrationOperations",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `lists`\n\n**Resposta:** `{ data: [IntegOperation] }`, por nome\n\n**Regra:** —",
        "responses": {
          "200": {
            "description": "`{ data: [IntegOperation] }`, por nome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegOperation"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/operations\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/users": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Listar usuários pela integração",
        "operationId": "getIntegrationUsers",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `lists`\n\n**Resposta:** `{ data: [Ref] }`: os usuários ativos, por nome; o `id` vai em `ownerId`\n\n**Regra:** —",
        "responses": {
          "200": {
            "description": "`{ data: [Ref] }`: os usuários ativos, por nome; o `id` vai em `ownerId`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ref"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/users\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/tags": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Listar etiquetas pela integração",
        "operationId": "getIntegrationTags",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `lists`\n\n**Resposta:** `{ data: [{ name, color }] }`: as etiquetas de contatos e empresas, por nome (as dos cartões e das conversas vêm em cada operação)\n\n**Regra:** —",
        "responses": {
          "200": {
            "description": "`{ data: [{ name, color }] }`: as etiquetas de contatos e empresas, por nome (as dos cartões e das conversas vêm em cada operação)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "example": "Ana Prado"
                          },
                          "color": {}
                        },
                        "required": [
                          "name",
                          "color"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/tags\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/custom-fields": {
      "get": {
        "tags": [
          "Consultar dados (sem sessão)"
        ],
        "summary": "Listar campos personalizados pela integração",
        "operationId": "getIntegrationCustomFields",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `lists`\n\n**Resposta:** `{ contact: [IntegCustomField], organization: [IntegCustomField] }` (os dos cartões vêm em cada operação)\n\n**Regra:** —",
        "responses": {
          "200": {
            "description": "`{ contact: [IntegCustomField], organization: [IntegCustomField] }` (os dos cartões vêm em cada operação)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contact": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegCustomField"
                      }
                    },
                    "organization": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegCustomField"
                      }
                    }
                  },
                  "required": [
                    "contact",
                    "organization"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.whatzabot.com.br/api/v1/integration/custom-fields\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\""
          }
        ]
      }
    },
    "/api/v1/integration/contacts/{id}/tags": {
      "post": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Pôr e tirar etiquetas do contato pela integração",
        "operationId": "postIntegrationContactsByIdTags",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `contacts:write`\n\n**Corpo:** `{ add?: [string], remove?: [string] }`: as outras etiquetas ficam\n\n**Resposta:** `IntegContact`. `404 not_found`, `422 validation` (etiqueta que não existe em Etiquetas)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "add": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "remove": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "description": "as outras etiquetas ficam"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`IntegContact`. `404 not_found`, `422 validation` (etiqueta que não existe em Etiquetas)",
            "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"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "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/contacts/6750a1c2e4b0a1b2c3d4e5f1/tags\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"add\":[\"texto\"],\"remove\":[\"texto\"]}'"
          }
        ]
      }
    },
    "/api/v1/integration/cards/{id}": {
      "patch": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Alterar cartão e mudar de etapa pela integração",
        "operationId": "patchIntegrationCardsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `cards:write`\n\n**Corpo:** o mesmo do `POST`, sem `operationId`, mais `closed?` e `sendStageMessage?` (`false`: ao mudar de etapa, não manda a mensagem da etapa ao contato)\n\n**Resposta:** `IntegCard`. `404 not_found`, `422 validation`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "o mesmo do `POST`, sem `operationId`, mais `closed?` e `sendStageMessage?` (`false`: ao mudar de etapa, não manda a mensagem da etapa ao contato)"
              }
            }
          },
          "description": "o mesmo do `POST`, sem `operationId`, mais `closed?` e `sendStageMessage?` (`false`: ao mudar de etapa, não manda a mensagem da etapa ao contato)"
        },
        "responses": {
          "200": {
            "description": "`IntegCard`. `404 not_found`, `422 validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegCard"
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.whatzabot.com.br/api/v1/integration/cards/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/integration/conversations/{id}/notes": {
      "post": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Escrever nota interna pela integração",
        "operationId": "postIntegrationConversationsByIdNotes",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `conversations:write`\n\n**Corpo:** `{ text }`\n\n**Resposta:** `201 IntegNote`: só a equipe vê, o contato não. `404 not_found`, `422 validation`",
        "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"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`201 IntegNote`: só a equipe vê, o contato não. `404 not_found`, `422 validation`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegNote"
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "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/conversations/6750a1c2e4b0a1b2c3d4e5f1/notes\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Bom dia, o pedido já saiu?\"}'"
          }
        ]
      }
    },
    "/api/v1/integration/opt-outs/{id}": {
      "delete": {
        "tags": [
          "Cadastrar e alterar (sem sessão)"
        ],
        "summary": "Desmarcar quem não recebe campanhas pela integração",
        "operationId": "deleteIntegrationOptOutsById",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `optouts:write`\n\n**Corpo:** — (o `id` do contato)\n\n**Resposta:** `204`; o contato volta a receber campanhas. `404 not_found`",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "— (o `id` do contato)"
              }
            }
          },
          "description": "— (o `id` do contato)"
        },
        "responses": {
          "204": {
            "description": "`204`; o contato volta a receber campanhas. `404 not_found`"
          },
          "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"
                }
              }
            }
          }
        },
        "security": [
          {
            "chaveIntegracao": []
          }
        ],
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.whatzabot.com.br/api/v1/integration/opt-outs/6750a1c2e4b0a1b2c3d4e5f1\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\""
          }
        ]
      }
    },
    "/api/v1/integration/conversations/{id}/release": {
      "post": {
        "tags": [
          "Atender a conversa passada pelo robô (sem sessão)"
        ],
        "summary": "Devolver a conversa ao robô pela integração",
        "operationId": "postIntegrationConversationsByIdRelease",
        "description": "**Autenticação:** `Authorization: Bearer wzb_…`, com o escopo `handover`\n\n**Corpo:** `{ port?: \"released\"|\"error\", vars?: { nome: valor } }`: sem `port`, `released`; `vars` (até 30, nomes com letras minúsculas sem acento, números, `_` e ponto) viram `{{sistema.<nome>}}`\n\n**Resposta:** `200 { status, conversationId }`: o robô segue pela saída \"Devolvida\" (ou \"Deu erro\"); `404 conversation_not_found`, `409 not_with_system`, `409 already_released`, `422 validation` (`details.port` ou `details.vars`)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "6750a1c2e4b0a1b2c3d4e5f1"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "port": {
                    "type": "string",
                    "enum": [
                      "released",
                      "error"
                    ],
                    "example": "released"
                  },
                  "vars": {
                    "type": "object",
                    "properties": {
                      "nome": {
                        "description": "valor"
                      }
                    },
                    "required": [
                      "nome"
                    ]
                  }
                },
                "description": "sem `port`, `released`; `vars` (até 30, nomes com letras minúsculas sem acento, números, `_` e ponto) viram `{{sistema.<nome>}}`"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`200 { status, conversationId }`: o robô segue pela saída \"Devolvida\" (ou \"Deu erro\"); `404 conversation_not_found`, `409 not_with_system`, `409 already_released`, `422 validation` (`details.port` ou `details.vars`)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string",
                      "example": "6750a1c2e4b0a1b2c3d4e5f1"
                    }
                  },
                  "required": [
                    "status",
                    "conversationId"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem login, token vencido ou chave inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "404": {
            "description": "`conversation_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "409": {
            "description": "`not_with_system`, `already_released`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Erro"
                }
              }
            }
          },
          "422": {
            "description": "`validation`",
            "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/conversations/6750a1c2e4b0a1b2c3d4e5f1/release\" \\\n  -H \"Authorization: Bearer $CHAVE_WZB\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"port\":\"released\",\"vars\":{}}'"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "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"
        ]
      },
      "Deletion": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "mergedInto": {},
          "by": {
            "$ref": "#/components/schemas/Ref"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "by",
          "at"
        ]
      },
      "IntegCall": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "conversationId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "number": {
            "$ref": "#/components/schemas/Ref"
          },
          "direction": {},
          "phone": {
            "type": "string",
            "example": "5554999990000"
          },
          "user": {
            "$ref": "#/components/schemas/Ref"
          },
          "status": {
            "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": "integer"
          }
        },
        "required": [
          "id",
          "conversationId",
          "number",
          "direction",
          "phone",
          "status",
          "startedAt",
          "seconds"
        ]
      },
      "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"
        ]
      },
      "IntegCustomField": {
        "type": "object",
        "properties": {
          "key": {},
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "type": {
            "type": "string"
          },
          "options": {},
          "required": {}
        },
        "required": [
          "key",
          "name",
          "type"
        ]
      },
      "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"
        ]
      },
      "IntegNote": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "text": {
            "type": "string",
            "example": "Bom dia, o pedido já saiu?"
          },
          "author": {
            "$ref": "#/components/schemas/Ref"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "text",
          "author",
          "at"
        ]
      },
      "IntegNumber": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "phone": {
            "type": "string",
            "example": "5554999990000"
          },
          "channel": {},
          "status": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "phone",
          "channel",
          "status"
        ]
      },
      "IntegOperation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "cardLabel": {},
          "money": {},
          "stages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "6750a1c2e4b0a1b2c3d4e5f1"
                },
                "name": {
                  "type": "string",
                  "example": "Ana Prado"
                },
                "done": {}
              },
              "required": [
                "id",
                "name",
                "done"
              ]
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cardFields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IntegCustomField"
            }
          }
        },
        "required": [
          "id",
          "name",
          "cardLabel",
          "money",
          "stages",
          "tags",
          "cardFields"
        ]
      },
      "IntegOptOut": {
        "type": "object",
        "properties": {
          "contactId": {
            "type": "string",
            "example": "6750a1c2e4b0a1b2c3d4e5f1"
          },
          "name": {
            "type": "string",
            "example": "Ana Prado"
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "5554999990000"
            }
          },
          "optOutAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "contactId",
          "name",
          "phones",
          "optOutAt"
        ]
      },
      "IntegOrganization": {
        "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"
            }
          },
          "fields": {},
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-01T12:12:00Z"
          }
        },
        "required": [
          "id",
          "name",
          "kind",
          "tags",
          "createdAt"
        ]
      },
      "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"
        ]
      }
    }
  },
  "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"
        ]
      }
    },
    "handover: start": {
      "post": {
        "summary": "O robô passou a conversa ao sistema",
        "description": "Evento: `start`.\n\n`vars` traz só as variáveis escolhidas no bloco, e `messages`, as últimas mensagens da conversa, até a quantidade do bloco (no máximo 50).",
        "operationId": "handoverStart",
        "tags": [
          "Robôs: o que o Passar a outro sistema manda"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "contact": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "phone": {
                        "type": "string"
                      }
                    }
                  },
                  "conversation": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "number": {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      },
                      "operation": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      },
                      "protocol": {
                        "type": "string"
                      },
                      "tags": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "conversationId": {
                    "type": "string"
                  },
                  "event": {
                    "type": "string"
                  },
                  "flow": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    }
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "fromMe": {
                          "type": "boolean"
                        },
                        "id": {
                          "type": "string"
                        },
                        "kind": {
                          "type": "string"
                        },
                        "text": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "release": {
                    "type": "string"
                  },
                  "reply": {
                    "type": "string"
                  },
                  "runId": {
                    "type": "string"
                  },
                  "vars": {
                    "type": "object",
                    "properties": {
                      "cpf": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "at": "2026-12-01T12:34:00Z",
                  "contact": {
                    "id": "6750a1c2e4b0a1b2c3d4e501",
                    "name": "Ana Prado",
                    "phone": "5554999990000"
                  },
                  "conversation": {
                    "id": "6750a1c2e4b0a1b2c3d4e505",
                    "number": {
                      "channel": "qr",
                      "id": "6750a1c2e4b0a1b2c3d4e502",
                      "name": "Comercial"
                    },
                    "operation": {
                      "id": "6750a1c2e4b0a1b2c3d4e503",
                      "name": "Vendas"
                    },
                    "protocol": "20261201-0042",
                    "tags": [
                      "cliente"
                    ]
                  },
                  "conversationId": "6750a1c2e4b0a1b2c3d4e505",
                  "event": "start",
                  "flow": {
                    "id": "6750a1c2e4b0a1b2c3d4e512",
                    "name": "Recepção"
                  },
                  "messages": [
                    {
                      "at": "2026-12-01T12:32:00Z",
                      "fromMe": false,
                      "id": "6750a1c2e4b0a1b2c3d4e541",
                      "kind": "text",
                      "text": "Bom dia, preciso da segunda via do boleto."
                    },
                    {
                      "at": "2026-12-01T12:33:00Z",
                      "fromMe": true,
                      "id": "6750a1c2e4b0a1b2c3d4e542",
                      "kind": "text",
                      "text": "Vou passar para o setor financeiro.",
                      "who": "Recepção"
                    }
                  ],
                  "release": "https://app.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e505/release",
                  "reply": "https://app.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e505/messages",
                  "runId": "6750a1c2e4b0a1b2c3d4e540",
                  "vars": {
                    "cpf": "000.000.000-00"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx confirma; o corpo não é lido. Sem resposta, com 429 ou 5xx, o WhatzaBot tenta de novo depois de 10 s, 1 min e 5 min."
          }
        }
      }
    },
    "handover: message": {
      "post": {
        "summary": "Mensagem nova do contato",
        "description": "Evento: `message`.\n\nNa mensagem de texto, vem `text` e não vêm `summary`, `transcript` nem `file`. O endereço de `file.url` vale 24 horas.",
        "operationId": "handoverMessage",
        "tags": [
          "Robôs: o que o Passar a outro sistema manda"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "conversationId": {
                    "type": "string"
                  },
                  "event": {
                    "type": "string"
                  },
                  "flow": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    }
                  },
                  "message": {
                    "type": "object",
                    "properties": {
                      "at": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "fromMe": {
                        "type": "boolean"
                      },
                      "id": {
                        "type": "string"
                      },
                      "kind": {
                        "type": "string"
                      },
                      "summary": {
                        "type": "string"
                      },
                      "transcript": {
                        "type": "string"
                      },
                      "file": {
                        "type": "object",
                        "properties": {
                          "expires": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "mime": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "size": {
                            "type": "integer"
                          },
                          "url": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  },
                  "release": {
                    "type": "string"
                  },
                  "reply": {
                    "type": "string"
                  },
                  "runId": {
                    "type": "string"
                  }
                },
                "example": {
                  "at": "2026-12-01T12:34:00Z",
                  "conversationId": "6750a1c2e4b0a1b2c3d4e505",
                  "event": "message",
                  "flow": {
                    "id": "6750a1c2e4b0a1b2c3d4e512",
                    "name": "Recepção"
                  },
                  "message": {
                    "at": "2026-12-01T12:35:00Z",
                    "fromMe": false,
                    "id": "6750a1c2e4b0a1b2c3d4e543",
                    "kind": "image",
                    "summary": "Foto do boleto vencido",
                    "transcript": "Boleto do pedido 48211, vencido em 28/11/2026.",
                    "file": {
                      "expires": "2026-12-02T12:35:00Z",
                      "mime": "image/jpeg",
                      "name": "boleto.jpg",
                      "size": 182340,
                      "url": "https://arquivos.exemplo.com.br/boleto.jpg?assinatura=..."
                    }
                  },
                  "release": "https://app.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e505/release",
                  "reply": "https://app.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e505/messages",
                  "runId": "6750a1c2e4b0a1b2c3d4e540"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx confirma; o corpo não é lido. Sem resposta, com 429 ou 5xx, o WhatzaBot tenta de novo depois de 10 s, 1 min e 5 min."
          }
        }
      }
    },
    "handover: ended": {
      "post": {
        "summary": "A conversa voltou ao WhatzaBot sem o sistema devolver",
        "description": "Evento: `ended`.\n\nVai quando alguém da equipe assume, outro sistema passa ou fecha a conversa pela chave, o robô para ou o contato não responde a tempo. Depois dele, `reply` e `release` respondem `409 not_with_system`.",
        "operationId": "handoverEnded",
        "tags": [
          "Robôs: o que o Passar a outro sistema manda"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "conversationId": {
                    "type": "string"
                  },
                  "event": {
                    "type": "string"
                  },
                  "flow": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    }
                  },
                  "reason": {
                    "type": "string"
                  },
                  "release": {
                    "type": "string"
                  },
                  "reply": {
                    "type": "string"
                  },
                  "runId": {
                    "type": "string"
                  }
                },
                "example": {
                  "at": "2026-12-01T12:34:00Z",
                  "conversationId": "6750a1c2e4b0a1b2c3d4e505",
                  "event": "ended",
                  "flow": {
                    "id": "6750a1c2e4b0a1b2c3d4e512",
                    "name": "Recepção"
                  },
                  "reason": "Marina Costa assumiu a conversa.",
                  "release": "https://app.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e505/release",
                  "reply": "https://app.whatzabot.com.br/api/v1/integration/conversations/6750a1c2e4b0a1b2c3d4e505/messages",
                  "runId": "6750a1c2e4b0a1b2c3d4e540"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Qualquer resposta 2xx confirma; o corpo não é lido. Sem resposta, com 429 ou 5xx, o WhatzaBot tenta de novo depois de 10 s, 1 min e 5 min."
          }
        }
      }
    }
  }
}
