{
  "openapi": "3.1.0",
  "info": {
    "title": "W2 API",
    "version": "1.0.0",
    "description": "API REST para conectar números de WhatsApp, enviar e receber mensagens, administrar grupos e canais, agendar envios e fazer ligações de voz e vídeo.\n\n**Endereço:** `https://api.w2-api.com/v1`\n\n## Começo rápido\n\n1. Assine um plano em [w2-api.com](https://w2-api.com) e entre no painel em [app.w2-api.com](https://app.w2-api.com).\n2. Em **Minha conta**, crie uma **chave de API**.\n3. Crie uma instância e conecte o número pelo QR code, ou pelo código de pareamento (`POST /instances/{id}/pairing-code`).\n4. Configure o webhook da instância (`PUT /instances/{id}/webhook`) para receber as mensagens.\n5. Envie a primeira mensagem:\n\n```bash\ncurl -X POST \"https://api.w2-api.com/v1/instances/<instance-id>/messages/text\" \\\n  -H \"X-Api-Key: <sua-chave>\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"to\": \"5511999999999\", \"text\": \"Olá!\"}'\n```\n\n## Autenticação\n\nMande a chave de API em todas as rotas, num destes headers:\n\n```http\nX-Api-Key: w2_...\nAuthorization: Bearer w2_...\n```\n\nA chave não expira e pode ser revogada a qualquer momento em **Minha conta**. Quem tem a chave controla todas as instâncias da conta: guarde no servidor, nunca no navegador ou em código público.\n\nO token de sessão devolvido por `POST /auth/login` também funciona, mas expira em 7 dias. Criar e revogar chaves exige esse token de sessão, não uma chave.\n\n## Versões e endereços\n\nTodas as rotas respondem em `https://api.w2-api.com/v1`. As mesmas rotas sem o `/v1` e o endereço antigo `https://whats2-api.dextino.com.br` continuam respondendo, para não quebrar integrações existentes.\n\nO contrato completo está em [`/v1/openapi.json`](https://api.w2-api.com/v1/openapi.json): importe no Postman, no Insomnia ou num gerador de clientes.\n\n## Erros\n\nTodo erro vem com o status HTTP e este corpo. Trate pelo `code`, que não muda; o texto de `error` pode mudar.\n\n```json\n{ \"error\": \"instance is not connected\", \"code\": \"instance_not_connected\" }\n```\n\n| code | HTTP | Quando |\n|---|---|---|\n| `missing_credentials` | 401 | Nenhuma chave ou token na requisição |\n| `invalid_api_key` | 401 | Chave inexistente ou revogada |\n| `invalid_token` | 401 | Token de sessão inválido ou expirado |\n| `plan_required`, `instance_limit`, `calls_require_pro` | 402 | O plano não cobre a ação (veja `GET /billing`) |\n| `session_required` | 403 | Rota que só aceita a sessão do painel |\n| `not_allowed` | 403 | O WhatsApp recusou: falta permissão (em grupo, ser admin) |\n| `instance_not_found` | 404 | A instância não existe nesta conta |\n| `not_found` | 404 | O WhatsApp não encontrou o grupo, link ou contato |\n| `instance_already_connected` | 409 | A instância já está conectada |\n| `invalid_request`, `invalid_body` | 400 | Campo faltando ou corpo inválido |\n| `rejected_by_whatsapp` | 400 | O WhatsApp rejeitou o pedido |\n| `rate_limited` | 429 | Requisições demais; espere os segundos de `Retry-After` |\n| `instance_not_connected` | 503 | O número está desconectado |\n| `server_busy` | 503 | Sem vaga para ligação agora; tente após `Retry-After` |\n| `internal_error` | 500 | Falha do nosso lado |\n\nToda resposta traz o header `X-Request-Id`. Mande ele ao suporte quando algo der errado.\n\n## Limites\n\n- **40 requisições por segundo por conta**, com rajadas de até 200. Os headers `X-RateLimit-Limit` e `X-RateLimit-Remaining` mostram quanto resta; acima disso vem 429 com `Retry-After`.\n- **Login:** 20 tentativas por IP, repondo uma a cada 30 segundos.\n- **Histórico guardado:** `/messages` e `/chats` trazem os últimos 180 dias. Baixar mídia e encaminhar valem para mensagens de até 30 dias.\n\n## Webhooks\n\nCada instância envia os eventos por POST para a URL configurada em `PUT /instances/{id}/webhook`. Uma resposta 2xx confirma a entrega; erro de rede ou 5xx é tentado de novo.\n\nTodo POST traz `X-W2-Event` (nome do evento), `X-W2-Instance` e `X-W2-Signature: t=<timestamp>,v1=<assinatura>`. A assinatura é o HMAC-SHA256, em hexadecimal, de `\"<timestamp>.<corpo cru>\"` com o `secret` do webhook como chave. Recuse se não bater ou se o timestamp tiver mais de 5 minutos.\n\n```js\n// Node.js (Express): use o corpo cru, antes de qualquer JSON.parse\nimport crypto from 'node:crypto'\n\nfunction verify(rawBody, header, secret) {\n  const { t, v1 } = Object.fromEntries(header.split(',').map(p => p.split('=')))\n  const expected = crypto.createHmac('sha256', secret).update(t + '.' + rawBody).digest('hex')\n  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300\n  return fresh && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(v1))\n}\n```\n\n```python\n# Python\nimport hmac, hashlib, time\n\ndef verify(raw_body: bytes, header: str, secret: str) -> bool:\n    parts = dict(p.split(\"=\", 1) for p in header.split(\",\"))\n    expected = hmac.new(secret.encode(), parts[\"t\"].encode() + b\".\" + raw_body, hashlib.sha256).hexdigest()\n    fresh = abs(time.time() - int(parts[\"t\"])) < 300\n    return fresh and hmac.compare_digest(expected, parts[\"v1\"])\n```\n\nA lista de eventos e o formato de cada um estão na seção **Webhooks** da referência, abaixo.\n\n## O que mudou em novembro de 2026\n\nNada foi removido. Se você já tem uma integração, confira só estes pontos:\n\n- O token de 7 dias não aparece mais em Minha conta. Para integrações, use uma chave de API, que não expira.\n- Os erros ganharam o campo `code`; o campo `error` continua igual.\n- Enviar por uma instância que nunca foi conectada devolve 503 `instance_not_connected` (antes, 404).\n- Votos em enquete chegam no webhook `poll_vote` (antes, `message` com `type: unknown`).\n- `PUT /webhook` exige uma URL http(s) completa.\n- Limite de 40 requisições por segundo por conta e de 20 tentativas de login por IP.\n- Histórico: 180 dias de mensagens; mídia e encaminhamento para mensagens de até 30 dias.\n- Os webhooks trazem os headers `X-W2-Signature`, `X-W2-Event` e `X-W2-Instance`; o `X-WhatsAPI-Instance` continua.",
    "contact": {
      "name": "W2 API",
      "url": "https://w2-api.com"
    }
  },
  "servers": [
    {
      "url": "https://api.w2-api.com/v1"
    }
  ],
  "security": [
    {
      "ApiKey": []
    },
    {
      "Bearer": []
    }
  ],
  "tags": [
    {
      "name": "Autenticação"
    },
    {
      "name": "Plano da conta"
    },
    {
      "name": "Instâncias"
    },
    {
      "name": "Conexão e QR Code"
    },
    {
      "name": "Mensagens"
    },
    {
      "name": "Conversas"
    },
    {
      "name": "Perfil e contatos"
    },
    {
      "name": "Respostas rápidas"
    },
    {
      "name": "Grupos"
    },
    {
      "name": "Presença (online/offline)"
    },
    {
      "name": "Ligações de voz e vídeo"
    },
    {
      "name": "Envios agendados"
    },
    {
      "name": "Status (stories)"
    },
    {
      "name": "Canais"
    },
    {
      "name": "Webhooks"
    }
  ],
  "x-tagGroups": [
    {
      "name": "Conta",
      "tags": [
        "Autenticação",
        "Plano da conta"
      ]
    },
    {
      "name": "Números",
      "tags": [
        "Instâncias",
        "Conexão e QR Code"
      ]
    },
    {
      "name": "Mensagens",
      "tags": [
        "Mensagens",
        "Conversas",
        "Envios agendados",
        "Status (stories)",
        "Respostas rápidas"
      ]
    },
    {
      "name": "Contatos e grupos",
      "tags": [
        "Perfil e contatos",
        "Grupos",
        "Presença (online/offline)"
      ]
    },
    {
      "name": "Canais e ligações",
      "tags": [
        "Canais",
        "Ligações de voz e vídeo"
      ]
    },
    {
      "name": "Eventos",
      "tags": [
        "Webhooks"
      ]
    }
  ],
  "paths": {
    "/api-keys": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "operationId": "postApiKeys",
        "summary": "Criar chave de API",
        "description": "Cria uma chave de API permanente. Use ela nas integrações: não expira e pode ser revogada a qualquer momento.\n\nA chave completa (\"key\") aparece só nesta resposta. Guarde num cofre de segredos; depois só o prefixo fica visível.\n\nMande a chave em todas as rotas, em um destes headers:\n\nX-Api-Key: w2_...\n\nAuthorization: Bearer w2_...\n\nAs chaves também podem ser criadas e revogadas em Minha conta.\n\nCriar, listar e revogar chaves exige a sessão do painel (token do login), não uma chave. Assim, uma chave vazada não consegue criar outras. Limite de 20 chaves ativas por conta.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "name": "n8n produção"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "prefix": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "last_used_at": {}
                  }
                },
                "example": {
                  "id": "6f1c2b0e-...",
                  "name": "n8n produção",
                  "prefix": "w2_3f9a1c2d",
                  "key": "w2_3f9a1c2d...",
                  "created_at": "2026-11-23T18:00:00Z",
                  "last_used_at": null
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Autenticação"
        ],
        "operationId": "getApiKeys",
        "summary": "Listar chaves de API",
        "description": "Lista as chaves ativas da conta, sem o valor completo.\n\n\"last_used_at\" é atualizado no máximo a cada 5 minutos.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "prefix": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "last_used_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "keys": [
                    {
                      "id": "6f1c2b0e-...",
                      "name": "n8n produção",
                      "prefix": "w2_3f9a1c2d",
                      "created_at": "2026-11-23T18:00:00Z",
                      "last_used_at": "2026-11-23T18:05:00Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api-keys/{keyID}": {
      "delete": {
        "tags": [
          "Autenticação"
        ],
        "operationId": "deleteApiKeysByKeyID",
        "summary": "Revogar chave de API",
        "description": "Revoga uma chave. Ela para de funcionar na hora.\n\n404 com \"code\": \"api_key_not_found\" se a chave não existe ou já foi revogada.",
        "parameters": [
          {
            "name": "keyID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/auth/login": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "operationId": "postAuthLogin",
        "summary": "Login",
        "description": "Faz login com e-mail e senha e devolve o token de sessão do painel, válido por 7 dias.\n\nO token de sessão funciona em todas as rotas (Authorization: Bearer <token>), mas expira em 7 dias. Para integrações, crie uma chave de API.",
        "parameters": [],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "email": "seu@email.com",
                "password": "suasenha"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "token": "eyJhbGci...",
                  "email": "seu@email.com"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/billing": {
      "get": {
        "tags": [
          "Plano da conta"
        ],
        "operationId": "getBilling",
        "summary": "Ver plano",
        "description": "Mostra o plano da conta: se está ativo, quantos números ele cobre e se inclui ligações.\n\nCada assinatura cobre um número. Quando uma rota não cabe no plano, a API responde 402 com um código:\n\n• plan_required: a conta não tem plano ativo (enviar, criar instância e ligações ficam bloqueados)\n\n• instance_limit: todos os números do plano já estão em uso\n\n• calls_require_pro: ligações de voz e vídeo são do plano Pro\n\nLer dados, conectar, desconectar e apagar instâncias continuam liberados.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entitlement": {
                      "type": "object",
                      "properties": {
                        "active": {
                          "type": "boolean"
                        },
                        "plan": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "interval": {
                          "type": "string"
                        },
                        "calls": {
                          "type": "boolean"
                        },
                        "instance_limit": {
                          "type": "integer"
                        },
                        "instances_used": {
                          "type": "integer"
                        },
                        "trial_end": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "entitlement": {
                    "active": true,
                    "plan": "pro",
                    "status": "trialing",
                    "interval": "month",
                    "calls": true,
                    "instance_limit": 1,
                    "instances_used": 1,
                    "trial_end": 1795611956
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances": {
      "post": {
        "tags": [
          "Instâncias"
        ],
        "operationId": "postInstances",
        "summary": "Criar instância",
        "description": "Cria uma instância (um número de WhatsApp). Ela nasce desconectada: use GET /instances/{id}/qr para parear.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "label": "Suporte"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "jid": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "id": "11cb9c03-bae4-4da3-a18d-3bf0d28770cf",
                  "label": "Suporte",
                  "jid": "",
                  "status": "disconnected",
                  "created_at": "2026-03-30T12:00:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Instâncias"
        ],
        "operationId": "getInstances",
        "summary": "Listar instâncias",
        "description": "Lista suas instâncias com o status atual de cada uma.\n\nStatus: disconnected, connecting, connected ou logged_out.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "label": {
                        "type": "string"
                      },
                      "jid": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "created_at": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": [
                  {
                    "id": "11cb9c03-...",
                    "label": "Suporte",
                    "jid": "5511999999999@s.whatsapp.net",
                    "status": "connected",
                    "created_at": "2026-03-30T12:00:00Z"
                  }
                ]
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}": {
      "get": {
        "tags": [
          "Instâncias"
        ],
        "operationId": "getInstancesById",
        "summary": "Ver instância",
        "description": "Dados de uma instância.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "jid": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "id": "11cb9c03-...",
                  "label": "Suporte",
                  "jid": "5511999999999@s.whatsapp.net",
                  "status": "connected",
                  "created_at": "2026-03-30T12:00:00Z"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Instâncias"
        ],
        "operationId": "deleteInstancesById",
        "summary": "Apagar instância",
        "description": "Apaga a instância: desconecta do WhatsApp e remove os dados salvos.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/status": {
      "get": {
        "tags": [
          "Instâncias"
        ],
        "operationId": "getInstancesByIdStatus",
        "summary": "Status de conexão",
        "description": "Só o status de conexão da instância.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "jid": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "id": "11cb9c03-...",
                  "status": "connected",
                  "jid": "5511999999999@s.whatsapp.net"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/qr": {
      "get": {
        "tags": [
          "Conexão e QR Code"
        ],
        "operationId": "getInstancesByIdQr",
        "summary": "QR code (stream)",
        "description": "Stream SSE com os QR codes para parear. Deixe a conexão aberta até chegar \"success\" ou \"timeout\".\n\nEventos:\n\n- qr: QR novo, com a imagem PNG em base64\n- success: número pareado\n- timeout: o QR expirou sem ser lido\n- error: falha na conexão\n- close: o servidor encerrou o stream",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Stream SSE",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "example": "event: qr\ndata: {\"code\":\"1@abc...\",\"image\":\"<base64 PNG>\",\"timeout\":60}\n\nevent: qr\ndata: {\"code\":\"1@xyz...\",\"image\":\"<base64 PNG>\",\"timeout\":20}\n\nevent: success\ndata: {\"paired\":true}"
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/pairing-code": {
      "post": {
        "tags": [
          "Conexão e QR Code"
        ],
        "operationId": "postInstancesByIdPairingCode",
        "summary": "Código de pareamento",
        "description": "Pareia pelo número de telefone, sem QR code. Devolve um código de 8 caracteres para digitar no celular.\n\nNo celular: WhatsApp > Dispositivos conectados > Conectar dispositivo > Conectar com número de telefone, e digite o código. O WhatsApp também mostra uma notificação no aparelho.\n\n\"phone\" é o número completo do WhatsApp que vai ser conectado, com DDI e DDD, só dígitos.\n\nO código vale por cerca de 2 minutos e meio. Quando o número conecta, o status da instância vira \"connected\" e chega o webhook \"connected\", igual ao QR.\n\nErros:\n\n- 400 \"invalid_phone\": número fora do formato.\n- 409 \"instance_already_connected\": a instância já está conectada.\n- 502 \"pairing_failed\": o WhatsApp não gerou o código; tente de novo.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "phone": "5511999999999"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "expires_in": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "code": "ABCD1234",
                  "expires_in": 160
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/connect": {
      "post": {
        "tags": [
          "Conexão e QR Code"
        ],
        "operationId": "postInstancesByIdConnect",
        "summary": "Reconectar",
        "description": "Reconecta uma instância já pareada que está desconectada.\n\n409 se ela já estiver conectada.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "status": "connecting"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/disconnect": {
      "post": {
        "tags": [
          "Conexão e QR Code"
        ],
        "operationId": "postInstancesByIdDisconnect",
        "summary": "Desconectar",
        "description": "Desconecta sem desparear. Dá para reconectar depois sem ler o QR de novo.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "status": "disconnected"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/logout": {
      "post": {
        "tags": [
          "Conexão e QR Code"
        ],
        "operationId": "postInstancesByIdLogout",
        "summary": "Desparear número",
        "description": "Despareia o número. Para usar de novo, é preciso ler um QR novo.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "status": "logged_out"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/text": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesText",
        "summary": "Enviar texto",
        "description": "Envia uma mensagem de texto, com menções e pré-visualização de link opcionais.\n\n\"to\" pode ser o número (\"5511999999999\"), o JID (\"5511999999999@s.whatsapp.net\") ou um grupo (\"120363000000000000@g.us\"). Vale para todos os envios.\n\n- mentions (opcional): números ou JIDs a mencionar com @, normalmente em grupo. Se o texto ainda não tiver o \"@<número>\", ele é acrescentado no fim.\n- link_preview (opcional): true mostra título, descrição e imagem do primeiro link do texto, como no celular. A página precisa ter as tags Open Graph; se não der para ler, a mensagem vai sem pré-visualização.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "mentions": {
                    "type": "array",
                    "items": {}
                  },
                  "link_preview": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "text": "Olá! Veja https://w2-api.com",
                "mentions": [],
                "link_preview": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0C5A1B2D3E4F5",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/poll": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesPoll",
        "summary": "Enviar enquete",
        "description": "Envia uma enquete.\n\n- options: de 2 a 12 respostas, sem repetir.\n- selectable_count: quantas respostas cada pessoa pode marcar. 0 ou 1 = escolha única; até o número de opções.\n\nCada voto chega no webhook \"poll_vote\", com o nome das opções escolhidas. Quando a pessoa tira o voto, chega com \"selected_options\": [].\n\nEnquetes recebidas chegam no webhook \"message\" com \"type\": \"poll\" e o campo \"poll\" (name, options, selectable_count).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "options": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "selectable_count": {
                    "type": "integer"
                  }
                }
              },
              "example": {
                "to": "120363000000000000@g.us",
                "name": "Qual horário fica melhor?",
                "options": [
                  "Manhã",
                  "Tarde",
                  "Noite"
                ],
                "selectable_count": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0C5A1B2D3E4F5",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/image": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesImage",
        "summary": "Enviar imagem",
        "description": "Envia uma imagem, por \"url\" ou \"base64\".\n\nPara mandar a imagem como resposta a uma mensagem, preencha os campos quoted_\\* (as regras são as de /messages/reply). Sem \"quoted_message_id\" ela vai como mensagem normal.\n\nOs mesmos campos funcionam em /messages/video, /messages/audio, /messages/document e /messages/sticker.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string"
                  },
                  "mime_type": {
                    "type": "string"
                  },
                  "caption": {
                    "type": "string"
                  },
                  "quoted_message_id": {
                    "type": "string"
                  },
                  "quoted_participant": {
                    "type": "string"
                  },
                  "quoted_text": {
                    "type": "string"
                  },
                  "quoted_type": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "url": "https://exemplo.com/foto.jpg",
                "mime_type": "image/jpeg",
                "caption": "Confira esta imagem!",
                "quoted_message_id": "",
                "quoted_participant": "",
                "quoted_text": "",
                "quoted_type": ""
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/video": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesVideo",
        "summary": "Enviar vídeo",
        "description": "Envia um vídeo, que abre no player do WhatsApp (não vai como arquivo). Por \"url\" ou \"base64\".",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string"
                  },
                  "mime_type": {
                    "type": "string"
                  },
                  "caption": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "url": "https://exemplo.com/video.mp4",
                "mime_type": "video/mp4",
                "caption": "Confira este vídeo!"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/document": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesDocument",
        "summary": "Enviar documento",
        "description": "Envia um arquivo, com legenda opcional.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string"
                  },
                  "mime_type": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "caption": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "url": "https://exemplo.com/contrato.pdf",
                "mime_type": "application/pdf",
                "filename": "contrato.pdf",
                "caption": "Segue o contrato"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/audio": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesAudio",
        "summary": "Enviar áudio",
        "description": "Envia um áudio como mensagem de voz (aparece como áudio gravado na hora, com a onda e a duração).\n\nPode mandar mp3, m4a, wav, ogg etc.: o servidor converte para OGG/Opus e calcula a duração e a onda. \"mime_type\" é ignorado aqui.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "url": "https://exemplo.com/audio.mp3"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/sticker": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesSticker",
        "summary": "Enviar figurinha",
        "description": "Envia uma figurinha (estática ou animada) em WebP, por \"url\" ou \"base64\".\n\nSó WebP. PNG, JPEG e GIF voltam 422, porque o WhatsApp aceitaria e o destinatário veria uma figurinha em branco. Tamanho recomendado: 512x512 px, até uns 100 KB (estática) ou 500 KB (animada).\n\nLargura, altura e animação são lidas do arquivo. \"mime_type\" é ignorado.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "url": "https://exemplo.com/figurinha.webp"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/contact": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesContact",
        "summary": "Enviar contato",
        "description": "Envia um contato. Mande \"name\" e \"phone\" ou um \"vcard\" pronto.\n\nSe vier \"vcard\" (vCard 3.0), ele é usado no lugar de name e phone.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "name": "João Silva",
                "phone": "5511988887777"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/location": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesLocation",
        "summary": "Enviar localização",
        "description": "Envia uma localização, com nome e endereço opcionais.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "latitude": {
                    "type": "number"
                  },
                  "longitude": {
                    "type": "number"
                  },
                  "name": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "latitude": -23.55052,
                "longitude": -46.633308,
                "name": "Av. Paulista",
                "address": "Av. Paulista, 1578 - São Paulo"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/read": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesRead",
        "summary": "Marcar mensagens como lidas",
        "description": "Marca mensagens recebidas como lidas, como se o chat tivesse sido aberto. Para áudios, type \"played\" marca como ouvido.\n\nEm grupo, \"sender\" é o JID de quem mandou a mensagem. Em conversa direta pode ficar vazio.\n\n\"type\": \"read\" (padrão) ou \"played\".",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "message_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "sender": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "chat": "5511999999999@s.whatsapp.net",
                "message_ids": [
                  "3EB0...",
                  "3EB1..."
                ],
                "sender": "",
                "type": "read"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "status": "ok"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/chats/read": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdChatsRead",
        "summary": "Marcar conversa como lida",
        "description": "Marca a conversa inteira como lida ou não lida no WhatsApp do número, como o \"Marcar como não lida\" do celular. O contato não fica sabendo.\n\n\"read\": false marca como não lida. true, ou sem o campo, marca como lida.\n\nIsso não envia confirmação de leitura ao contato. Para isso use /messages/read.\n\nQuando alguém marca a conversa como lida ou não lida no celular, chegam os webhooks chat_read e chat_unread.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "read": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "chat": "5511999999999@s.whatsapp.net",
                "read": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "chat": {
                      "type": "string"
                    },
                    "read": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "status": "ok",
                  "chat": "5511999999999@s.whatsapp.net",
                  "read": false
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/reply": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesReply",
        "summary": "Responder mensagem",
        "description": "Responde a uma mensagem com texto, citando a original.\n\n- quoted_message_id (obrigatório): ID da mensagem respondida.\n- quoted_participant: JID de quem mandou a original. Obrigatório em grupo; em conversa direta pode ficar vazio.\n- quoted_text: texto da original, mostrado na citação.\n- quoted_type: tipo da original (text, image, audio, video, document, sticker, location, contact, ou \"ptt\" para mensagem de voz). Padrão \"text\". Se você citar uma foto sem informar o tipo, a citação aparece como um balão de texto vazio.\n\n- quoted_chat: a conversa onde está a mensagem citada, quando é outra. Serve para o \"Responder em particular\": responder no privado de um contato citando o que ele escreveu num grupo. Mande \"to\" com o contato, \"quoted_chat\" com o JID do grupo e \"quoted_participant\" com quem escreveu (se ficar vazio, vale o próprio \"to\"). O WhatsApp mostra o nome do grupo na citação. Sem quoted_chat, a citação é tratada como uma mensagem da própria conversa: o texto aparece, mas sem o grupo, e tocar nela não leva à mensagem original.\n\nEsses valores vêm do webhook de mensagem ou de GET /instances/{id}/messages. Quando a mensagem recebida já é uma resposta, o webhook traz os quoted_\\* prontos.\n\nPara responder com foto, áudio, vídeo ou documento, use o endpoint da mídia com os mesmos campos quoted_\\*.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "quoted_message_id": {
                    "type": "string"
                  },
                  "quoted_participant": {
                    "type": "string"
                  },
                  "quoted_text": {
                    "type": "string"
                  },
                  "quoted_type": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "text": "Concordo com isso!",
                "quoted_message_id": "3EB0...",
                "quoted_participant": "",
                "quoted_text": "Mensagem original citada",
                "quoted_type": "text"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/{msgID}/edit": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesByMsgIDEdit",
        "summary": "Editar mensagem",
        "description": "Edita o texto de uma mensagem enviada ou a legenda de uma mídia. O WhatsApp só permite editar até uns 15 minutos depois do envio.\n\n{msgID} é o ID da mensagem.\n\nPara editar a legenda de uma mídia, mande \"caption\" e o \"type\" da mídia original (image, video, document, sticker, location, contact):\n\n```json\n{\n  \"chat\": \"5511999999999@s.whatsapp.net\",\n  \"caption\": \"Legenda corrigida\",\n  \"type\": \"image\"\n}\n```\n\nSem o \"type\" certo a legenda não muda: o WhatsApp recebe uma edição de texto e o destinatário não tem onde aplicar.\n\nMande \"text\" ou \"caption\". Sem \"type\", vale \"text\".",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "msgID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "chat": "5511999999999@s.whatsapp.net",
                "text": "Texto corrigido"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/{msgID}/delete": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesByMsgIDDelete",
        "summary": "Apagar mensagem",
        "description": "Apaga uma mensagem para todos.\n\n{msgID} é o ID da mensagem. \"sender\" só é preciso quando um admin apaga a mensagem de outra pessoa no grupo; para apagar as suas, deixe vazio.\n\nTambém aceita DELETE /instances/{id}/messages/{msgID}, com o mesmo corpo.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "msgID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "sender": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "chat": "5511999999999@s.whatsapp.net",
                "sender": ""
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/{msgID}/reaction": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesByMsgIDReaction",
        "summary": "Reagir a mensagem",
        "description": "Reage a uma mensagem com um emoji. Emoji vazio tira a reação.\n\n{msgID} é a mensagem que recebe a reação. \"sender\" é quem mandou essa mensagem; se foi você, deixe vazio.\n\nAs reações dos contatos chegam no webhook \"message\" com \"type\": \"reaction\".",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "msgID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "sender": {
                    "type": "string"
                  },
                  "emoji": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "chat": "5511999999999@s.whatsapp.net",
                "sender": "",
                "emoji": "👍"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/{msgID}/forward": {
      "post": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "postInstancesByIdMessagesByMsgIDForward",
        "summary": "Encaminhar mensagem",
        "description": "Encaminha uma mensagem para outro chat, com a marca \"Encaminhada\". Funciona com texto, imagem, vídeo, áudio, documento, figurinha, localização e contato.\n\n{msgID} é o message_id que veio no webhook ou em GET /instances/{id}/messages. \"to\" é o contato ou grupo de destino.\n\nA mídia não é baixada nem reenviada. Legenda e nome do arquivo vão junto; a citação da mensagem original, não. A partir do 5º encaminhamento o WhatsApp mostra \"Encaminhada com frequência\". Mensagem escrita por você não ganha a marca.\n\nSó dá para encaminhar mensagens que o Whats2 guarda: as recebidas, as enviadas pelo celular e as do histórico. As enviadas pela API não ficam guardadas; reenvie o conteúdo.\n\nErros:\n\n- 404: não existe mensagem com esse ID na instância.\n- 422: a mensagem não pode ser encaminhada (reação, mídia de visualização única, ou mídia recebida antes desta versão; o texto dessas encaminha normal).\n\nCom a fila ligada, a resposta é 202 com status \"queued\", como nos outros envios.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "msgID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "to": "5511888888888"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/{msgID}/status": {
      "get": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "getInstancesByIdMessagesByMsgIDStatus",
        "summary": "Status da mensagem",
        "description": "Último status de uma mensagem enviada: sent, delivered, read, played ou failed.\n\n404 se ainda não chegou nenhum status. O status nunca volta: depois de \"read\", um \"delivered\" atrasado é ignorado.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "msgID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "chat": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    },
                    "is_from_me": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "chat": "5511999999999@s.whatsapp.net",
                  "status": "read",
                  "timestamp": "2026-03-30T14:30:42Z",
                  "is_from_me": true
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/chats": {
      "get": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "getInstancesByIdChats",
        "summary": "Listar conversas",
        "description": "Lista as conversas com a última mensagem de cada uma, da mais recente para a mais antiga.\n\n\"count\" é quantas mensagens da conversa estão salvas.\n\nO histórico antigo vem do celular logo depois de conectar e pode levar alguns segundos para aparecer (webhook history_sync).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "chats": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "chat": {
                            "type": "string"
                          },
                          "last_type": {
                            "type": "string"
                          },
                          "last_message": {
                            "type": "string"
                          },
                          "last_time": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "chats": [
                    {
                      "chat": "5511999999999@s.whatsapp.net",
                      "last_type": "text",
                      "last_message": "Até mais!",
                      "last_time": "2026-03-30T14:30:00Z",
                      "count": 42
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages": {
      "get": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "getInstancesByIdMessages",
        "summary": "Listar mensagens",
        "description": "Lista as mensagens salvas, das mais recentes para as mais antigas.\n\nQuery params:\n\n- chat: filtra por conversa (JID ou número). Sem ele, vem de todas.\n- limit: padrão 100, máximo 500.\n\n\"type\": text, image, video, audio, document, ptv, sticker, location, contact, reaction ou unknown. Cartões de contato trazem vcard, vcards e contacts, como no webhook. Nas mensagens de mídia vêm media_type, mime_type, filename (documentos), media_size e caption, como no webhook. O arquivo não vem aqui: baixe em GET /instances/{id}/messages/{msgID}/media.\n\nEm reações, \"reaction_message_id\" é a mensagem reagida e \"reaction_emoji\" vem vazio quando a reação foi removida. \"participant\" aparece só em grupos. \"is_forwarded\" vem true nas encaminhadas.\n\nOs campos quoted_\\* e mentioned_jids são os mesmos do webhook e só aparecem quando existem. Servem para remontar a conversa se algum webhook se perdeu. Mensagens antigas, de antes dessa versão, vêm sem eles.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "chat",
            "in": "query",
            "required": false,
            "description": "filtra por conversa (JID ou número). Sem ele, vem de todas.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "padrão 100, máximo 500.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "message_id": {
                            "type": "string"
                          },
                          "chat": {
                            "type": "string"
                          },
                          "sender": {
                            "type": "string"
                          },
                          "is_from_me": {
                            "type": "boolean"
                          },
                          "push_name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          },
                          "timestamp": {
                            "type": "string"
                          },
                          "quoted_message_id": {
                            "type": "string"
                          },
                          "quoted_participant": {
                            "type": "string"
                          },
                          "quoted_text": {
                            "type": "string"
                          },
                          "quoted_type": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "messages": [
                    {
                      "message_id": "3EB0...",
                      "chat": "5511999999999@s.whatsapp.net",
                      "sender": "5511999999999@s.whatsapp.net",
                      "is_from_me": false,
                      "push_name": "João",
                      "type": "text",
                      "text": "Pode confirmar?",
                      "timestamp": "2026-03-30T14:30:00Z",
                      "quoted_message_id": "3EB0ORIGINAL...",
                      "quoted_participant": "5511888888888@s.whatsapp.net",
                      "quoted_text": "Seu pedido saiu para entrega",
                      "quoted_type": "text"
                    },
                    {
                      "message_id": "3EB0REACAO...",
                      "chat": "120363000000000000@g.us",
                      "sender": "5511999999999@s.whatsapp.net",
                      "participant": "5511999999999@s.whatsapp.net",
                      "is_from_me": false,
                      "push_name": "João",
                      "type": "reaction",
                      "text": "👍",
                      "timestamp": "2026-03-30T14:31:00Z",
                      "reaction_message_id": "3EB0ORIGINAL...",
                      "reaction_emoji": "👍"
                    },
                    {
                      "message_id": "3EB0FOTO...",
                      "chat": "5511999999999@s.whatsapp.net",
                      "sender": "5511999999999@s.whatsapp.net",
                      "is_from_me": false,
                      "type": "image",
                      "text": "Olha isso",
                      "timestamp": "2026-03-30T14:32:00Z",
                      "media_type": "image",
                      "mime_type": "image/jpeg",
                      "media_size": 184320,
                      "caption": "Olha isso"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/messages/{msgID}/media": {
      "get": {
        "tags": [
          "Mensagens"
        ],
        "operationId": "getInstancesByIdMessagesByMsgIDMedia",
        "summary": "Baixar mídia",
        "description": "Baixa o arquivo de uma mensagem de mídia salva (imagem, vídeo, áudio, documento, figurinha), inclusive as que vieram no histórico.\n\nQuery params:\n\n- chat (opcional): JID da conversa. Se vier e não bater com a mensagem, dá 404.\n\n{msgID} é o message_id do webhook ou de GET /instances/{id}/messages. O arquivo é baixado do WhatsApp na hora; nada fica guardado no Whats2. Serve para o histórico importado e para mídia que passou do limite do webhook (media_unavailable).\n\nSe o WhatsApp já apagou o arquivo, o Whats2 pede ao celular para reenviar. Isso só funciona com o celular ligado e com a mídia ainda nele, e pode levar até 60 segundos.\n\nSó vale para mensagens que o Whats2 guarda: recebidas, enviadas pelo celular e do histórico. As enviadas pela API não ficam guardadas.\n\nErros:\n\n- 404: mensagem desconhecida, sem mídia, ou recebida antes desta versão sem o conteúdo salvo.\n- 410: o WhatsApp não tem mais o arquivo e o celular não conseguiu reenviar.\n- 503: instância desconectada.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "msgID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chat",
            "in": "query",
            "required": false,
            "description": "JID da conversa. Se vier e não bater com a mensagem, dá 404.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "value": "(o arquivo em binário)\nContent-Type: image/jpeg\nContent-Disposition: attachment; filename=\"nota.pdf\"   (só em documentos)"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/chats/presence": {
      "post": {
        "tags": [
          "Conversas"
        ],
        "operationId": "postInstancesByIdChatsPresence",
        "summary": "Digitando / gravando",
        "description": "Mostra \"digitando…\" ou \"gravando áudio…\" para o contato, ou tira o aviso.\n\n\"state\": composing (digitando), recording (gravando áudio) ou paused (para de mostrar).\n\nO aviso some sozinho depois de alguns segundos ou quando a mensagem é enviada. Mostrar \"digitando…\" por alguns segundos antes de responder deixa o atendimento mais natural e ajuda a evitar bloqueios.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "chat": "5511999999999",
                "state": "composing"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/chats/archive": {
      "post": {
        "tags": [
          "Conversas"
        ],
        "operationId": "postInstancesByIdChatsArchive",
        "summary": "Arquivar conversa",
        "description": "Arquiva ou desarquiva uma conversa em todos os aparelhos do número.\n\n\"archive\": false desarquiva. Sem o campo, arquiva. Arquivar também desafixa a conversa.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "archive": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "chat": "5511999999999",
                "archive": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/chats/pin": {
      "post": {
        "tags": [
          "Conversas"
        ],
        "operationId": "postInstancesByIdChatsPin",
        "summary": "Fixar conversa",
        "description": "Fixa ou desafixa uma conversa no topo da lista.\n\nO WhatsApp permite até 3 conversas fixadas.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "pin": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "chat": "5511999999999",
                "pin": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/chats/mute": {
      "post": {
        "tags": [
          "Conversas"
        ],
        "operationId": "postInstancesByIdChatsMute",
        "summary": "Silenciar conversa",
        "description": "Silencia ou reativa as notificações de uma conversa.\n\n\"duration_seconds\": por quanto tempo silenciar. 0 ou sem o campo = para sempre. \"mute\": false reativa.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "mute": {
                    "type": "boolean"
                  },
                  "duration_seconds": {
                    "type": "integer"
                  }
                }
              },
              "example": {
                "chat": "120363000000000000@g.us",
                "mute": true,
                "duration_seconds": 28800
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/chats/delete": {
      "post": {
        "tags": [
          "Conversas"
        ],
        "operationId": "postInstancesByIdChatsDelete",
        "summary": "Apagar conversa",
        "description": "Apaga uma conversa da lista, em todos os aparelhos do número.\n\nSó some da lista deste número; o contato continua com as mensagens. \"delete_media\": true também apaga as mídias da conversa no celular.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "delete_media": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "chat": "5511999999999",
                "delete_media": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/chats/disappearing": {
      "post": {
        "tags": [
          "Conversas"
        ],
        "operationId": "postInstancesByIdChatsDisappearing",
        "summary": "Mensagens temporárias",
        "description": "Liga ou desliga as mensagens temporárias de uma conversa ou grupo.\n\n\"seconds\": 0 (desliga), 86400 (24 horas), 604800 (7 dias) ou 7776000 (90 dias). Em grupo, pode exigir que o número seja admin.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "seconds": {
                    "type": "integer"
                  }
                }
              },
              "example": {
                "chat": "5511999999999",
                "seconds": 604800
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/profile": {
      "get": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "getInstancesByIdProfile",
        "summary": "Ver perfil",
        "description": "Mostra o perfil do próprio número: nome, recado e foto.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jid": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "picture_url": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "jid": "5511999999999@s.whatsapp.net",
                  "name": "Clínica Sorriso",
                  "status": "Atendimento de seg a sex, 8h às 18h",
                  "picture_url": "https://pps.whatsapp.net/..."
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/profile/name": {
      "put": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "putInstancesByIdProfileName",
        "summary": "Mudar nome",
        "description": "Muda o nome que os contatos veem.\n\nDe 1 a 25 caracteres. Em contas comerciais verificadas, o nome verificado não muda por aqui.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "name": "Clínica Sorriso"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/profile/status": {
      "put": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "putInstancesByIdProfileStatus",
        "summary": "Mudar recado",
        "description": "Muda o recado (o \"sobre\") do número.\n\nAté 139 caracteres. Texto vazio apaga o recado.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "status": "Atendimento de seg a sex, 8h às 18h"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/profile/picture": {
      "put": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "putInstancesByIdProfilePicture",
        "summary": "Mudar foto de perfil",
        "description": "Troca a foto de perfil do número, por \"url\" ou \"base64\".\n\nJPEG, PNG ou GIF de pelo menos 96x96. A imagem é cortada no centro em formato quadrado e reduzida para 640x640.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "url": "https://meu-site.com/logo.png"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "picture_id": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "picture_id": "1700000000"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "deleteInstancesByIdProfilePicture",
        "summary": "Remover foto de perfil",
        "description": "Remove a foto de perfil do número.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/privacy": {
      "get": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "getInstancesByIdPrivacy",
        "summary": "Ver privacidade",
        "description": "Mostra as configurações de privacidade do número.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "last_seen": {
                      "type": "string"
                    },
                    "online": {
                      "type": "string"
                    },
                    "profile_photo": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "read_receipts": {
                      "type": "string"
                    },
                    "group_add": {
                      "type": "string"
                    },
                    "call_add": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "last_seen": "contacts",
                  "online": "match_last_seen",
                  "profile_photo": "all",
                  "status": "contacts",
                  "read_receipts": "all",
                  "group_add": "contacts",
                  "call_add": "all"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "putInstancesByIdPrivacy",
        "summary": "Mudar privacidade",
        "description": "Muda uma configuração de privacidade e devolve todas.\n\nValores aceitos em cada \"setting\":\n\n- last_seen, profile_photo, status, group_add: all, contacts, contact_blacklist, none\n- online: all, match_last_seen\n- read_receipts: all, none\n- call_add: all, known\n\nUm valor que não vale para a configuração devolve 400 \"rejected_by_whatsapp\".",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "setting": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "setting": "last_seen",
                "value": "none"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "last_seen": {
                      "type": "string"
                    },
                    "online": {
                      "type": "string"
                    },
                    "...": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "last_seen": "none",
                  "online": "match_last_seen",
                  "...": "..."
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/contacts/{phone}/info": {
      "get": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "getInstancesByIdContactsByPhoneInfo",
        "summary": "Dados do contato",
        "description": "Mostra o que o WhatsApp informa sobre um número: recado, foto e, em contas comerciais, o perfil da empresa.\n\n{phone} é o número com DDI. Se ele não tiver WhatsApp, vem só \"on_whatsapp\": false. O recado e a foto respeitam a privacidade do contato. Para baixar a foto, use /profile-picture.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "phone",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jid": {
                      "type": "string"
                    },
                    "on_whatsapp": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string"
                    },
                    "picture_id": {
                      "type": "string"
                    },
                    "verified_name": {
                      "type": "string"
                    },
                    "is_business": {
                      "type": "boolean"
                    },
                    "business": {
                      "type": "object",
                      "properties": {
                        "address": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "website": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "categories": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "jid": "5511999999999@s.whatsapp.net",
                  "on_whatsapp": true,
                  "status": "Disponível",
                  "picture_id": "1700000000",
                  "verified_name": "Loja Exemplo",
                  "is_business": true,
                  "business": {
                    "address": "Rua Exemplo, 100",
                    "email": "contato@loja.com",
                    "website": [
                      "https://loja.com"
                    ],
                    "categories": [
                      "Varejo"
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/contacts/block": {
      "post": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "postInstancesByIdContactsBlock",
        "summary": "Bloquear contato",
        "description": "Bloqueia ou desbloqueia um contato e devolve a lista de bloqueados.\n\n\"block\": false desbloqueia. Sem o campo, bloqueia.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone": {
                    "type": "string"
                  },
                  "block": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "phone": "5511999999999",
                "block": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "blocked": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "blocked": [
                    "5511999999999@s.whatsapp.net"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/blocklist": {
      "get": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "getInstancesByIdBlocklist",
        "summary": "Listar bloqueados",
        "description": "Lista os contatos bloqueados pelo número.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "blocked": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "blocked": [
                    "5511999999999@s.whatsapp.net"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/check-numbers": {
      "get": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "getInstancesByIdCheckNumbers",
        "summary": "Verificar números",
        "description": "Verifica se números têm WhatsApp, antes de mandar mensagem.\n\nQuery params:\n\n- phones (obrigatório): número com DDI. Repita o parâmetro para vários: ?phones=5511999999999&phones=5511888888888\n\n\"IsIn\": true quando o número tem WhatsApp. \"JID\" é o endereço a usar no \"to\" dos envios. \"VerifiedName\" vem preenchido em contas comerciais verificadas.\n\nPrecisa da instância conectada (503 \"instance_not_connected\").",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "phones",
            "in": "query",
            "required": true,
            "description": "número com DDI. Repita o parâmetro para vários: ?phones=5511999999999&phones=5511888888888",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "Query": {
                            "type": "string"
                          },
                          "JID": {
                            "type": "string"
                          },
                          "IsIn": {
                            "type": "boolean"
                          },
                          "VerifiedName": {}
                        }
                      }
                    }
                  }
                },
                "example": {
                  "results": [
                    {
                      "Query": "+5511999999999",
                      "JID": "5511999999999@s.whatsapp.net",
                      "IsIn": true,
                      "VerifiedName": null
                    },
                    {
                      "Query": "+5511888888888",
                      "JID": "5511888888888@s.whatsapp.net",
                      "IsIn": false,
                      "VerifiedName": null
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/profile-picture": {
      "get": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "getInstancesByIdProfilePicture",
        "summary": "Foto de perfil de contato",
        "description": "URL da foto de perfil de um contato ou grupo.\n\nQuery param obrigatório: jid (número, JID ou grupo ...@g.us). Ex.: ?jid=5511999999999\n\nA URL é do próprio WhatsApp e expira. Baixe a imagem e guarde ela (ou o \"id\", que muda quando a foto muda), não a URL.\n\nSem foto, ou com a foto escondida pela privacidade, a resposta é 200 com { \"url\": \"\", \"id\": \"\" }.\n\n503 se a instância estiver desconectada.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "direct_path": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "url": "https://pps.whatsapp.net/v/t61.../...jpg",
                  "id": "1580000000",
                  "type": "image",
                  "direct_path": "/v/t61.../...jpg"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/contacts": {
      "get": {
        "tags": [
          "Perfil e contatos"
        ],
        "operationId": "getInstancesByIdContacts",
        "summary": "Listar contatos",
        "description": "Lista os contatos que o WhatsApp sincronizou para a instância. Contas comerciais vêm com \"business_name\".\n\nQuery params opcionais:\n\n- q: busca em full_name, first_name, push_name, business_name e jid.\n- limit: de 1 a 200, padrão 50. Não tem paginação; use \"q\" para refinar.\n\nCampos vazios não aparecem. Não é a agenda do celular, é o que o WhatsApp manda para aparelhos conectados. Logo depois de parear a lista pode vir incompleta.\n\n503 se a instância estiver desconectada.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "jid": {
                            "type": "string"
                          },
                          "full_name": {
                            "type": "string"
                          },
                          "first_name": {
                            "type": "string"
                          },
                          "push_name": {
                            "type": "string"
                          },
                          "business_name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "items": [
                    {
                      "jid": "5511999999999@s.whatsapp.net",
                      "full_name": "João Silva",
                      "first_name": "João",
                      "push_name": "Jô",
                      "business_name": "Padaria do João"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/quick-replies": {
      "get": {
        "tags": [
          "Respostas rápidas"
        ],
        "operationId": "getInstancesByIdQuickReplies",
        "summary": "Respostas rápidas",
        "description": "Lista as respostas rápidas (atalhos com \"/\") cadastradas no WhatsApp Business do número. É só leitura: o cadastro é feito no app.\n\nQuery params opcionais:\n\n- q: filtra pelo começo do atalho (?q=sau traz /saudacao), com ou sem a \"/\".\n- refresh=true: busca de novo no WhatsApp antes de listar. Precisa da instância conectada (senão 503). Use se uma resposta apagada no celular continuar aparecendo, ou em números pareados antes desse recurso existir.\n\nSem refresh, a lista vem do cache local, que se atualiza sozinho a cada mudança no celular.\n\n\"shortcut\" vem sem a \"/\"; \"count\" é quantas vezes foi usada. Contas que não são Business recebem lista vazia.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "shortcut": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "keywords": {
                            "type": "array",
                            "items": {}
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "items": [
                    {
                      "shortcut": "saudacao",
                      "message": "Olá! Como posso ajudar?",
                      "keywords": [],
                      "count": 3
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/invite-link": {
      "get": {
        "tags": [
          "Grupos"
        ],
        "operationId": "getInstancesByIdGroupsByJidInviteLink",
        "summary": "Link de convite",
        "description": "Devolve o link de convite do grupo.\n\nO número precisa ser admin do grupo (403 \"not_allowed\" se não for).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "link": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "link": "https://chat.whatsapp.com/AbCdEfGhIjK"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/invite-link/reset": {
      "post": {
        "tags": [
          "Grupos"
        ],
        "operationId": "postInstancesByIdGroupsByJidInviteLinkReset",
        "summary": "Revogar link de convite",
        "description": "Revoga o link de convite atual e gera outro.\n\nO link antigo para de funcionar na hora. Precisa ser admin.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "link": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "link": "https://chat.whatsapp.com/NovoLinkXyZ"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/invite-info": {
      "get": {
        "tags": [
          "Grupos"
        ],
        "operationId": "getInstancesByIdGroupsInviteInfo",
        "summary": "Grupo pelo link",
        "description": "Mostra os dados de um grupo pelo link de convite, sem entrar nele.\n\nQuery params:\n\n- link (obrigatório): o link https://chat.whatsapp.com/... ou só o código.\n\nPara entrar, use POST /groups/join.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "link",
            "in": "query",
            "required": true,
            "description": "o link https://chat.whatsapp.com/... ou só o código.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jid": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "topic": {
                      "type": "string"
                    },
                    "participants": {
                      "type": "array",
                      "items": {}
                    }
                  }
                },
                "example": {
                  "jid": "120363000000000000@g.us",
                  "name": "Clientes VIP",
                  "topic": "...",
                  "participants": []
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/picture": {
      "put": {
        "tags": [
          "Grupos"
        ],
        "operationId": "putInstancesByIdGroupsByJidPicture",
        "summary": "Mudar foto do grupo",
        "description": "Troca a foto do grupo, por \"url\" ou \"base64\".\n\nJPEG, PNG ou GIF de pelo menos 96x96, cortado em quadrado. Precisa ser admin se o grupo só deixa admins editarem.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "url": "https://meu-site.com/grupo.png"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "picture_id": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "picture_id": "1700000000"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Grupos"
        ],
        "operationId": "deleteInstancesByIdGroupsByJidPicture",
        "summary": "Remover foto do grupo",
        "description": "Remove a foto do grupo.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/settings": {
      "put": {
        "tags": [
          "Grupos"
        ],
        "operationId": "putInstancesByIdGroupsByJidSettings",
        "summary": "Permissões do grupo",
        "description": "Muda as permissões do grupo. Mande só o que quer mudar.\n\n- admins_only_messages: só admins mandam mensagens.\n- admins_only_edit: só admins mudam nome, foto e descrição.\n- approval_required: quem entra pelo link precisa ser aprovado.\n- member_add: quem pode adicionar participantes, \"admins\" ou \"all\".\n\nPrecisa ser admin.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "admins_only_messages": {
                    "type": "boolean"
                  },
                  "admins_only_edit": {
                    "type": "boolean"
                  },
                  "approval_required": {
                    "type": "boolean"
                  },
                  "member_add": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "admins_only_messages": true,
                "admins_only_edit": true,
                "approval_required": false,
                "member_add": "admins"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/requests": {
      "get": {
        "tags": [
          "Grupos"
        ],
        "operationId": "getInstancesByIdGroupsByJidRequests",
        "summary": "Pedidos de entrada",
        "description": "Lista os pedidos para entrar no grupo que aguardam aprovação.\n\nSó existe quando o grupo tem \"approval_required\" ligado. Precisa ser admin.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requests": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "jid": {
                            "type": "string"
                          },
                          "requested_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "requests": [
                    {
                      "jid": "5511999999999@s.whatsapp.net",
                      "requested_at": "2026-11-23T18:00:00Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Grupos"
        ],
        "operationId": "postInstancesByIdGroupsByJidRequests",
        "summary": "Aprovar ou recusar pedidos",
        "description": "Aprova ou recusa pedidos para entrar no grupo.\n\n\"action\": approve ou reject.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string"
                  },
                  "participants": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "action": "approve",
                "participants": [
                  "5511999999999"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups": {
      "get": {
        "tags": [
          "Grupos"
        ],
        "operationId": "getInstancesByIdGroups",
        "summary": "Listar grupos",
        "description": "Lista os grupos de que o número participa.\n\nO \"jid\" do grupo é o que vai em {jid} nas outras rotas de grupo e em \"to\" nos envios. \"is_announce\": true quer dizer que só admins mandam mensagem.\n\n503 se a instância estiver desconectada.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "jid": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "topic": {
                            "type": "string"
                          },
                          "is_announce": {
                            "type": "boolean"
                          },
                          "participant_count": {
                            "type": "integer"
                          },
                          "participants": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "jid": {
                                  "type": "string"
                                },
                                "is_admin": {
                                  "type": "boolean"
                                },
                                "is_super_admin": {
                                  "type": "boolean"
                                },
                                "display_name": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "created_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "items": [
                    {
                      "jid": "120363012345678901@g.us",
                      "name": "Equipe de Suporte",
                      "topic": "Canal interno do time",
                      "is_announce": false,
                      "participant_count": 12,
                      "participants": [
                        {
                          "jid": "5511999999999@s.whatsapp.net",
                          "is_admin": true,
                          "is_super_admin": false,
                          "display_name": ""
                        }
                      ],
                      "created_at": "2026-03-30T12:00:00Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Grupos"
        ],
        "operationId": "postInstancesByIdGroups",
        "summary": "Criar grupo",
        "description": "Cria um grupo.\n\n\"subject\" é o nome, com até 25 caracteres. Não coloque o seu número em \"participants\": você entra como criador. Responde 201.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subject": {
                    "type": "string"
                  },
                  "participants": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "subject": "Novo Grupo",
                "participants": [
                  "5511988887777",
                  "5511977776666"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jid": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "topic": {
                      "type": "string"
                    },
                    "is_announce": {
                      "type": "boolean"
                    },
                    "participant_count": {
                      "type": "integer"
                    },
                    "participants": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "jid": {
                            "type": "string"
                          },
                          "is_admin": {
                            "type": "boolean"
                          },
                          "is_super_admin": {
                            "type": "boolean"
                          },
                          "display_name": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "created_at": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "jid": "120363999999999999@g.us",
                  "name": "Novo Grupo",
                  "topic": "",
                  "is_announce": false,
                  "participant_count": 3,
                  "participants": [
                    {
                      "jid": "5511999999999@s.whatsapp.net",
                      "is_admin": true,
                      "is_super_admin": true,
                      "display_name": ""
                    }
                  ],
                  "created_at": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}": {
      "get": {
        "tags": [
          "Grupos"
        ],
        "operationId": "getInstancesByIdGroupsByJid",
        "summary": "Ver grupo",
        "description": "Dados de um grupo: nome, descrição, participantes.\n\n{jid} pode ser o JID completo ou só o número do grupo (o @g.us é completado).\n\nParticipantes:\n\n- jid: o identificador que o WhatsApp usa no grupo (LID ou telefone).\n- lid e phone_number: as duas formas do mesmo participante, inclusive do próprio número da instância. Use phone_number para ligar o participante às mensagens, que chegam com o telefone em \"from\"/\"participant\". Vem vazio quando o WhatsApp ainda não informou o telefone daquele LID.\n- display_name: nome na agenda do celular; sem ele, o nome de perfil (push name); sem ele, o nome comercial. Vazio se não houver nenhum.\n\nOs mesmos campos vêm em GET /groups, ao criar e ao entrar num grupo.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jid": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "topic": {
                      "type": "string"
                    },
                    "is_announce": {
                      "type": "boolean"
                    },
                    "participant_count": {
                      "type": "integer"
                    },
                    "participants": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "jid": {
                            "type": "string"
                          },
                          "lid": {
                            "type": "string"
                          },
                          "phone_number": {
                            "type": "string"
                          },
                          "display_name": {
                            "type": "string"
                          },
                          "is_admin": {
                            "type": "boolean"
                          },
                          "is_super_admin": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "created_at": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "jid": "120363012345678901@g.us",
                  "name": "Equipe de Suporte",
                  "topic": "Canal interno do time",
                  "is_announce": false,
                  "participant_count": 12,
                  "participants": [
                    {
                      "jid": "84374766764057@lid",
                      "lid": "84374766764057@lid",
                      "phone_number": "5511999999999@s.whatsapp.net",
                      "display_name": "Daniel Oliveira",
                      "is_admin": true,
                      "is_super_admin": false
                    }
                  ],
                  "created_at": "2026-03-30T12:00:00Z"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/join": {
      "post": {
        "tags": [
          "Grupos"
        ],
        "operationId": "postInstancesByIdGroupsJoin",
        "summary": "Entrar em grupo",
        "description": "Entra num grupo por link de convite.\n\nMande \"link\" ou só o \"code\" do convite. Convites recebidos por mensagem direta não são aceitos por aqui.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "link": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "link": "https://chat.whatsapp.com/AbCdEf123456"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "value": "{\n  \"jid\": \"120363012345678901@g.us\",\n  \"name\": \"Equipe de Suporte\",\n  \"topic\": \"Canal interno do time\",\n  \"is_announce\": false,\n  \"participant_count\": 13,\n  \"participants\": [ ... ],\n  \"created_at\": \"2026-03-30T12:00:00Z\"\n}"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/participants": {
      "post": {
        "tags": [
          "Grupos"
        ],
        "operationId": "postInstancesByIdGroupsByJidParticipants",
        "summary": "Gerenciar participantes",
        "description": "Adiciona, remove, promove ou rebaixa participantes. O número precisa ser admin do grupo.\n\n\"action\": add, remove, promote ou demote.\n\nO resultado vem por participante. \"error_code\" é o código do WhatsApp: 403 sem permissão, 408 número sem WhatsApp ou que saiu há pouco, 409 já está no grupo, 0 deu certo.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string"
                  },
                  "participants": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "action": "add",
                "participants": [
                  "5511988887777",
                  "5511977776666"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "jid": {
                            "type": "string"
                          },
                          "success": {
                            "type": "boolean"
                          },
                          "error_code": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "results": [
                    {
                      "jid": "5511988887777@s.whatsapp.net",
                      "success": true,
                      "error_code": 0
                    },
                    {
                      "jid": "5511977776666@s.whatsapp.net",
                      "success": false,
                      "error_code": 409
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/mention": {
      "post": {
        "tags": [
          "Grupos"
        ],
        "operationId": "postInstancesByIdGroupsByJidMention",
        "summary": "Mencionar participantes",
        "description": "Manda uma mensagem no grupo marcando as pessoas indicadas.\n\nCada pessoa precisa aparecer como \"@numero\" no texto. Se faltar, o servidor acrescenta no fim. Para escolher onde a marcação fica, já escreva o \"@numero\" no \"text\".",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "mentions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "text": "Reunião às 15h",
                "mentions": [
                  "5511988887777",
                  "5511977776666"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/mention-all": {
      "post": {
        "tags": [
          "Grupos"
        ],
        "operationId": "postInstancesByIdGroupsByJidMentionAll",
        "summary": "Mencionar todos",
        "description": "Manda uma mensagem no grupo marcando todo mundo.\n\n\"text\" é opcional. O servidor busca os participantes e marca todos.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "text": "Aviso importante para todos"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0...",
                  "timestamp": "2026-03-30T14:30:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/leave": {
      "post": {
        "tags": [
          "Grupos"
        ],
        "operationId": "postInstancesByIdGroupsByJidLeave",
        "summary": "Sair do grupo",
        "description": "Sai do grupo.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "status": "left"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/name": {
      "put": {
        "tags": [
          "Grupos"
        ],
        "operationId": "putInstancesByIdGroupsByJidName",
        "summary": "Mudar nome do grupo",
        "description": "Muda o nome do grupo (até 25 caracteres). Em geral exige ser admin.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "name": "Novo nome do grupo"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "status": "ok"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/groups/{jid}/topic": {
      "put": {
        "tags": [
          "Grupos"
        ],
        "operationId": "putInstancesByIdGroupsByJidTopic",
        "summary": "Mudar descrição do grupo",
        "description": "Muda a descrição do grupo. \"topic\" vazio apaga a descrição. Em geral exige ser admin.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "topic": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "topic": "Novo tópico / descrição do grupo"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "status": "ok"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/presence": {
      "post": {
        "tags": [
          "Presença (online/offline)"
        ],
        "operationId": "postInstancesByIdPresence",
        "summary": "Online / offline",
        "description": "Mostra o número como online ou offline para os contatos.\n\n\"state\": available (online) ou unavailable (offline). Ficar offline faz o celular voltar a receber as notificações normalmente.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "state": "available"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/presence/subscribe": {
      "post": {
        "tags": [
          "Presença (online/offline)"
        ],
        "operationId": "postInstancesByIdPresenceSubscribe",
        "summary": "Acompanhar presença",
        "description": "Passa a receber, pelo webhook \"presence\", quando um contato fica online ou offline.\n\n\"ttl_seconds\" é opcional (padrão 2 h). Chamar de novo renova o prazo; o mais simples é chamar sempre que a conversa for aberta. Depois do prazo os eventos param.\n\nChega um evento a cada mudança. Se o contato já estiver online, o \"online: true\" costuma chegar logo depois da chamada.\n\nPontos de atenção:\n\n- Precisa ter webhook configurado.\n- Enquanto houver assinatura ativa, o seu número aparece como online para os contatos. É uma exigência do WhatsApp.\n- Se a instância reconectar, assine de novo.\n- Contatos que escondem o \"visto por último\" podem não gerar eventos.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "ttl_seconds": {
                    "type": "integer"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "ttl_seconds": 7200
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "to": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "status": "subscribed",
                  "to": "5511999999999"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/calls": {
      "post": {
        "tags": [
          "Ligações de voz e vídeo"
        ],
        "operationId": "postInstancesByIdCalls",
        "summary": "Fazer ligação",
        "description": "Liga para um número pelo WhatsApp. O celular da pessoa toca como uma ligação normal e, quando ela atende, o áudio passa pelo WebSocket de áudio da ligação.\n\nComo funciona:\n\n1. Você chama este endpoint. A ligação começa tocando e chega o webhook call.ringing.\n2. Abra logo o WebSocket de áudio (GET .../calls/{callID}/audio). Assim o áudio já está pronto quando a pessoa atender.\n3. Quando ela atende, chega call.accepted.\n4. No fim chega call.ended, ou call.rejected se ela recusar.\n\n501 se as ligações estiverem desligadas no servidor, 503 se a instância estiver desconectada.\n\n503 com \"Retry-After\" também quando o servidor já está no limite de ligações simultâneas. Nesse caso a ligação não foi feita; tente de novo em alguns segundos.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "video": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "to": "5511999999999",
                "video": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "call_id": {
                      "type": "string"
                    },
                    "instance_id": {
                      "type": "string"
                    },
                    "peer": {
                      "type": "string"
                    },
                    "direction": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "video": {
                      "type": "boolean"
                    },
                    "started_at": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "call_id": "89F0B85B5AA8F1ED3570909556B8B647",
                  "instance_id": "11cb9c03-...",
                  "peer": "5511999999999@s.whatsapp.net",
                  "direction": "outgoing",
                  "status": "ringing",
                  "video": false,
                  "started_at": "2026-11-09T13:23:19Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Ligações de voz e vídeo"
        ],
        "operationId": "getInstancesByIdCalls",
        "summary": "Histórico de ligações",
        "description": "Histórico de ligações feitas e recebidas, das mais recentes para as mais antigas.\n\n?limit= é opcional (padrão 50).\n\nStatus: ringing (feita, tocando), ringing_in (recebida, tocando), accepted (em andamento), rejected, ended ou failed.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "call_id": {
                        "type": "string"
                      },
                      "instance_id": {
                        "type": "string"
                      },
                      "peer": {
                        "type": "string"
                      },
                      "direction": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "started_at": {
                        "type": "string"
                      },
                      "ended_at": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": [
                  {
                    "call_id": "89F0B85B5AA8F1ED3570909556B8B647",
                    "instance_id": "11cb9c03-...",
                    "peer": "5511999999999@s.whatsapp.net",
                    "direction": "outgoing",
                    "status": "ended",
                    "started_at": "2026-11-09T13:23:19Z",
                    "ended_at": "2026-11-09T13:27:20Z"
                  }
                ]
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/calls/{callID}/accept": {
      "post": {
        "tags": [
          "Ligações de voz e vídeo"
        ],
        "operationId": "postInstancesByIdCallsByCallIDAccept",
        "summary": "Atender ligação",
        "description": "Atende uma ligação recebida. Ela fica tocando até você atender ou recusar.\n\nComo funciona:\n\n1. Alguém liga para o número e chega o webhook call.offer, com o call_id e status \"ringing_in\".\n2. Abra o WebSocket de áudio e chame este endpoint (ou /reject para recusar).\n3. Quando o áudio conecta, chega call.accepted. Por isso a resposta daqui ainda vem com \"ringing_in\".\n4. No fim chega call.ended.\n\nSe a pessoa for atendida pelo próprio celular do número, a ligação termina aqui com call.ended.\n\n404 se a ligação não existe ou já acabou. 409 se ela já não está tocando. 503 se o servidor está no limite de ligações simultâneas: a ligação continua tocando, e você pode tentar de novo ou recusar.\n\nSe a ligação chegar com o servidor já no limite, o Whats2 recusa na hora e manda só call.rejected com reason \"server_busy\", sem call.offer.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "callID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "call_id": {
                      "type": "string"
                    },
                    "instance_id": {
                      "type": "string"
                    },
                    "peer": {
                      "type": "string"
                    },
                    "direction": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "started_at": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "call_id": "0092D7A5CC5455F3A215FC7D98C58160",
                  "instance_id": "11cb9c03-...",
                  "peer": "5541999999999@s.whatsapp.net",
                  "direction": "incoming",
                  "status": "ringing_in",
                  "started_at": "2026-11-09T12:46:23Z"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/calls/{callID}/reject": {
      "post": {
        "tags": [
          "Ligações de voz e vídeo"
        ],
        "operationId": "postInstancesByIdCallsByCallIDReject",
        "summary": "Recusar ligação",
        "description": "Recusa uma ligação recebida que ainda está tocando.\n\nGera o webhook call.rejected. 404 se a ligação não existe; 409 se ela já não está tocando.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "callID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "call_id": {
                      "type": "string"
                    },
                    "direction": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "...": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "call_id": "0092D7A5CC5455F3A215FC7D98C58160",
                  "direction": "incoming",
                  "status": "rejected",
                  "reason": "rejected",
                  "...": "..."
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/calls/{callID}/end": {
      "post": {
        "tags": [
          "Ligações de voz e vídeo"
        ],
        "operationId": "postInstancesByIdCallsByCallIDEnd",
        "summary": "Encerrar ligação",
        "description": "Desliga a ligação. Se ela ainda estiver tocando, cancela.\n\n?reason= é opcional (padrão \"hangup\") e aparece no histórico e no call.ended.\n\n404 quer dizer que a ligação já tinha acabado, por exemplo porque a pessoa desligou antes. Pode tratar como encerrada.\n\nFechar o WebSocket de áudio não desliga a ligação. Ela continua, em silêncio, até este endpoint ser chamado ou a pessoa desligar.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "callID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "call_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "ended_at": {
                      "type": "string"
                    },
                    "...": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "call_id": "89F0B85B5AA8F1ED3570909556B8B647",
                  "status": "ended",
                  "reason": "hangup",
                  "ended_at": "2026-11-09T13:27:20Z",
                  "...": "..."
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/calls/{callID}/audio": {
      "get": {
        "tags": [
          "Ligações de voz e vídeo"
        ],
        "operationId": "getInstancesByIdCallsByCallIDAudio",
        "summary": "Áudio da ligação (WebSocket)",
        "description": "WebSocket com o áudio da ligação nos dois sentidos, em tempo real. É por aqui que um atendente no navegador ou um robô de voz fala com a pessoa.\n\nEndereço: wss://<servidor>/instances/{id}/calls/{callID}/audio?token=<JWT>\n\nO token vai na URL porque o WebSocket do navegador não manda header. Tem que ser o token da conta dona da instância.\n\nFormato: PCM 16 bits little-endian, mono, 16 kHz, em mensagens binárias.\n\n- Você recebe a voz da pessoa em pedaços de 640 bytes (20 ms), sem interrupção: quando ela fica calada, o celular para de mandar áudio e o Whats2 manda silêncio no lugar, no ritmo normal. Durante o toque não vem nada: o primeiro áudio só chega depois que a pessoa atende. Assim um robô de voz percebe que a pessoa terminou de falar.\n- Você manda a sua voz em pedaços de qualquer tamanho. Pode mandar mais rápido que o tempo real, como a fala inteira de um TTS de uma vez: o servidor guarda até cerca de 1 s e segura o envio enquanto isso estiver cheio, sem perder nada.\n- Enquanto você não manda nada, a pessoa ouve silêncio.\n\nAbra o WebSocket logo depois de criar a ligação ou de receber call.offer. Se esperar o call.accepted, a pessoa fica alguns segundos sem ouvir nada.\n\nQuando a ligação acaba, o servidor fecha o WebSocket com o motivo \"call ended\". 404 se a ligação não existe ou já acabou.\n\nExemplo no navegador:\n\nconst ws = new WebSocket(`wss://<servidor>/instances/${id}/calls/${callID}/audio?token=${token}`)\n\nws.binaryType = 'arraybuffer'\n\nws.onmessage = ev => tocar(new Int16Array(ev.data))   // voz da pessoa\n\nws.send(pcm16kMono.buffer)                            // sua voz (Int16Array)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "callID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "value": "101 Switching Protocols (WebSocket)"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/calls/{callID}/video": {
      "get": {
        "tags": [
          "Ligações de voz e vídeo"
        ],
        "operationId": "getInstancesByIdCallsByCallIDVideo",
        "summary": "Vídeo da ligação (WebSocket)",
        "description": "WebSocket com o vídeo da ligação nos dois sentidos. O vídeo trafega em H.264 já codificado: quem usa a API codifica a própria câmera e decodifica a da pessoa (no navegador, com WebCodecs).\n\nEndereço: wss://<servidor>/instances/{id}/calls/{callID}/video?token=<JWT>\n\nPara fazer uma chamada de vídeo, crie a ligação com \"video\": true. Em uma ligação de voz já em andamento, ligue a câmera com POST .../video/start.\n\nMensagens binárias, nos dois sentidos: um quadro H.264 por mensagem, no formato Annex-B (com start codes), perfil baseline. Mande no ritmo da câmera (15 quadros por segundo funciona bem); o servidor cuida do tempo.\n\nMensagens de texto (JSON) que o servidor manda:\n\n- {\"type\":\"keyframe\"}: a pessoa precisa de um quadro completo. Mande um keyframe em seguida.\n- {\"type\":\"state\",\"active\":true,\"upgrade\":false,\"orientation\":1}: a pessoa ligou ou desligou a câmera, pediu para virar vídeo (upgrade) ou girou o celular. Gire a imagem dela em orientation × 90° no sentido horário.\n\nComece a decodificar só a partir de um keyframe. Fechar o WebSocket não desliga a ligação. 404 se a ligação não existe ou já acabou.\n\nExemplo no navegador (codificar a câmera):\n\nconst enc = new VideoEncoder({ output: c => { const b = new Uint8Array(c.byteLength); c.copyTo(b); ws.send(b) }, error: console.error })\n\nenc.configure({ codec: 'avc1.42E01F', width: 640, height: 480, framerate: 15, latencyMode: 'realtime', avc: { format: 'annexb' } })",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "callID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "value": "101 Switching Protocols (WebSocket)"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/calls/{callID}/video/{action}": {
      "post": {
        "tags": [
          "Ligações de voz e vídeo"
        ],
        "operationId": "postInstancesByIdCallsByCallIDVideoByAction",
        "summary": "Ligar ou desligar câmera",
        "description": "Liga ou desliga a sua câmera numa ligação em andamento. action: start (liga a câmera; numa ligação de voz, pede para virar vídeo), accept (aceita o pedido da pessoa para virar vídeo) ou stop (desliga a sua câmera; o áudio e o vídeo da pessoa continuam).\n\n409 se a ação não vale nesse momento, 404 se a ligação não existe ou já acabou.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "callID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "action",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "value": "{\n  \"call_id\": \"89F0B85B5AA8F1ED3570909556B8B647\",\n  \"status\": \"accepted\",\n  \"video\": true,\n  ...\n}"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/scheduled": {
      "post": {
        "tags": [
          "Envios agendados"
        ],
        "operationId": "postInstancesByIdScheduled",
        "summary": "Agendar mensagem",
        "description": "Agenda uma mensagem para uma data e hora. Vale para qualquer tipo de envio.\n\n\"type\": text, reply, image, video, document, audio, sticker, contact, location, poll, status_text, status_image ou status_video.\n\n\"message\" é o mesmo corpo do endpoint de envio daquele tipo (por exemplo, /messages/image para \"image\"). Nos tipos status_\\* não vai \"to\". Campo desconhecido devolve 400, para um erro de digitação não virar um envio errado.\n\n\"send_at\" é data e hora no formato RFC 3339, com fuso (-03:00 para Brasília) ou em UTC (Z). Até 90 dias à frente.\n\nNa hora marcada (com até 5 segundos de diferença), a mensagem entra no envio normal e chega o webhook \"scheduled_sent\", com o \"message_id\". Depois vêm message_sent, message_delivered etc., como em qualquer envio.\n\nSe o número estiver desconectado na hora, o envio é tentado de novo a cada minuto por até 30 minutos. Depois disso, ou se o conteúdo for inválido, chega \"scheduled_failed\" com o motivo.\n\nPara mídia, prefira \"url\": o arquivo é baixado na hora do envio. \"base64\" é aceito até 1 MB no total. Limite de 10.000 envios pendentes por conta.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string"
                  },
                  "send_at": {
                    "type": "string"
                  },
                  "message": {
                    "type": "object",
                    "properties": {
                      "to": {
                        "type": "string"
                      },
                      "text": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "example": {
                "type": "text",
                "send_at": "2026-12-01T09:00:00-03:00",
                "message": {
                  "to": "5511999999999",
                  "text": "Bom dia! Lembrete da sua consulta hoje às 14h."
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "instance_id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "send_at": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "attempts": {
                      "type": "integer"
                    },
                    "created_at": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "id": "4b1f0c2e-...",
                  "instance_id": "...",
                  "type": "text",
                  "send_at": "2026-12-01T12:00:00Z",
                  "status": "scheduled",
                  "attempts": 0,
                  "created_at": "2026-11-23T18:00:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Envios agendados"
        ],
        "operationId": "getInstancesByIdScheduled",
        "summary": "Listar agendamentos",
        "description": "Lista os envios agendados da instância, por data de envio.\n\nQuery params:\n\n- status: scheduled, sent, failed ou canceled. Sem ele, vêm todos.\n- limit: padrão 100, máximo 500.\n\n\"status\": scheduled (aguardando), sending (saindo agora), sent (entregue ao envio, com \"message_id\"), failed (com \"error\") ou canceled.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "scheduled, sent, failed ou canceled. Sem ele, vêm todos.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "padrão 100, máximo 500.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "send_at": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "attempts": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "items": [
                    {
                      "id": "4b1f0c2e-...",
                      "type": "text",
                      "send_at": "2026-12-01T12:00:00Z",
                      "status": "scheduled",
                      "attempts": 0
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/scheduled/{schedID}": {
      "get": {
        "tags": [
          "Envios agendados"
        ],
        "operationId": "getInstancesByIdScheduledBySchedID",
        "summary": "Ver agendamento",
        "description": "Mostra um envio agendado, com o conteúdo da mensagem.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "schedID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "send_at": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "message_id": {
                      "type": "string"
                    },
                    "sent_at": {
                      "type": "string"
                    },
                    "message": {
                      "type": "object",
                      "properties": {
                        "to": {
                          "type": "string"
                        },
                        "text": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "id": "4b1f0c2e-...",
                  "type": "text",
                  "send_at": "2026-12-01T12:00:00Z",
                  "status": "sent",
                  "message_id": "3EB0C5A1B2D3E4F5",
                  "sent_at": "2026-12-01T12:00:03Z",
                  "message": {
                    "to": "5511999999999",
                    "text": "Bom dia! ..."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Envios agendados"
        ],
        "operationId": "deleteInstancesByIdScheduledBySchedID",
        "summary": "Cancelar agendamento",
        "description": "Cancela um envio que ainda não saiu.\n\n409 \"scheduled_not_pending\" se ele já foi enviado, falhou ou já estava cancelado. 404 \"scheduled_not_found\" se o ID não existe.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "schedID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/status/text": {
      "post": {
        "tags": [
          "Status (stories)"
        ],
        "operationId": "postInstancesByIdStatusText",
        "summary": "Status de texto",
        "description": "Publica um status de texto, com fundo colorido.\n\n- text: até 700 caracteres.\n- background_color e text_color: \"#RRGGBB\". Padrão: fundo verde e texto branco.\n- font: 0 (padrão), 1 (manuscrita), 2 (negrito), 3, 4 ou 5 (outras fontes do WhatsApp).\n\nO status aparece para os contatos que a privacidade de status do número permite e some em 24 horas.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "background_color": {
                    "type": "string"
                  },
                  "text_color": {
                    "type": "string"
                  },
                  "font": {
                    "type": "integer"
                  }
                }
              },
              "example": {
                "text": "Promoção de Black Friday até domingo!",
                "background_color": "#1F7A4D",
                "text_color": "#FFFFFF",
                "font": 2
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0C5A1B2D3E4F5",
                  "timestamp": "2026-11-23T18:00:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/status/image": {
      "post": {
        "tags": [
          "Status (stories)"
        ],
        "operationId": "postInstancesByIdStatusImage",
        "summary": "Status de imagem",
        "description": "Publica uma foto no status, por \"url\" ou \"base64\".\n\nMesmos campos de /messages/image, sem \"to\".",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "caption": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "url": "https://meu-site.com/promo.jpg",
                "caption": "Só hoje!"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0C5A1B2D3E4F5",
                  "timestamp": "2026-11-23T18:00:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/status/video": {
      "post": {
        "tags": [
          "Status (stories)"
        ],
        "operationId": "postInstancesByIdStatusVideo",
        "summary": "Status de vídeo",
        "description": "Publica um vídeo no status, por \"url\" ou \"base64\".\n\nMesmos campos de /messages/video, sem \"to\". O WhatsApp limita vídeos de status a cerca de 60 segundos.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "caption": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "url": "https://meu-site.com/promo.mp4",
                "caption": "Só hoje!"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "message_id": "3EB0C5A1B2D3E4F5",
                  "timestamp": "2026-11-23T18:00:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/channels": {
      "get": {
        "tags": [
          "Canais"
        ],
        "operationId": "getInstancesByIdChannels",
        "summary": "Listar canais",
        "description": "Lista os canais que o número segue ou administra.\n\n\"role\": owner, admin, subscriber ou guest.\n\nPara publicar num canal que o número administra, use os envios normais com \"to\" igual ao JID do canal (\"...@newsletter\"): /messages/text, /messages/image, /messages/video, /messages/document, /messages/audio e /messages/sticker. Também vale no envio agendado.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "channels": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "jid": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "invite_link": {
                            "type": "string"
                          },
                          "subscribers": {
                            "type": "integer"
                          },
                          "verified": {
                            "type": "boolean"
                          },
                          "picture_url": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "muted": {
                            "type": "boolean"
                          },
                          "state": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "channels": [
                    {
                      "jid": "120363000000000000@newsletter",
                      "name": "Novidades da Loja",
                      "description": "...",
                      "invite_link": "https://whatsapp.com/channel/0029Va...",
                      "subscribers": 1240,
                      "verified": false,
                      "picture_url": "https://...",
                      "role": "owner",
                      "muted": false,
                      "state": "active",
                      "created_at": "2026-01-10T12:00:00Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Canais"
        ],
        "operationId": "postInstancesByIdChannels",
        "summary": "Criar canal",
        "description": "Cria um canal administrado pelo número.\n\n\"description\" e \"picture\" são opcionais. A foto é cortada em quadrado, como nas outras rotas de foto.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "picture": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "example": {
                "name": "Novidades da Loja",
                "description": "Ofertas e lançamentos",
                "picture": {
                  "url": "https://meu-site.com/logo.png"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jid": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "...": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "jid": "120363000000000000@newsletter",
                  "name": "Novidades da Loja",
                  "role": "owner",
                  "...": "..."
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/channels/invite-info": {
      "get": {
        "tags": [
          "Canais"
        ],
        "operationId": "getInstancesByIdChannelsInviteInfo",
        "summary": "Canal pelo link",
        "description": "Mostra um canal pelo link de convite.\n\nQuery params:\n\n- link (obrigatório): o link https://whatsapp.com/channel/... ou só o código.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "link",
            "in": "query",
            "required": true,
            "description": "o link https://whatsapp.com/channel/... ou só o código.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jid": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "subscribers": {
                      "type": "integer"
                    },
                    "...": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "jid": "120363000000000000@newsletter",
                  "name": "...",
                  "subscribers": 1240,
                  "...": "..."
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/channels/{jid}": {
      "get": {
        "tags": [
          "Canais"
        ],
        "operationId": "getInstancesByIdChannelsByJid",
        "summary": "Ver canal",
        "description": "Mostra um canal pelo JID.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jid": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "...": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "jid": "120363000000000000@newsletter",
                  "name": "...",
                  "...": "..."
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/channels/{jid}/follow": {
      "post": {
        "tags": [
          "Canais"
        ],
        "operationId": "postInstancesByIdChannelsByJidFollow",
        "summary": "Seguir canal",
        "description": "Passa a seguir um canal.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/channels/{jid}/unfollow": {
      "post": {
        "tags": [
          "Canais"
        ],
        "operationId": "postInstancesByIdChannelsByJidUnfollow",
        "summary": "Deixar de seguir canal",
        "description": "Deixa de seguir um canal.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/channels/{jid}/mute": {
      "post": {
        "tags": [
          "Canais"
        ],
        "operationId": "postInstancesByIdChannelsByJidMute",
        "summary": "Silenciar canal",
        "description": "Silencia ou reativa as notificações de um canal.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mute": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "mute": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/channels/{jid}/messages": {
      "get": {
        "tags": [
          "Canais"
        ],
        "operationId": "getInstancesByIdChannelsByJidMessages",
        "summary": "Publicações do canal",
        "description": "Lista as publicações recentes de um canal, da mais nova para a mais antiga.\n\nQuery params:\n\n- count: quantas trazer, padrão 50, máximo 100.\n- before: \"server_id\" para buscar as anteriores a ele (paginação).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          },
          {
            "name": "jid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "count",
            "in": "query",
            "required": false,
            "description": "quantas trazer, padrão 50, máximo 100.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "\"server_id\" para buscar as anteriores a ele (paginação).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "server_id": {
                            "type": "integer"
                          },
                          "message_id": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          },
                          "timestamp": {
                            "type": "string"
                          },
                          "views": {
                            "type": "integer"
                          },
                          "reactions": {
                            "type": "object",
                            "properties": {
                              "❤️": {
                                "type": "integer"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "messages": [
                    {
                      "server_id": 152,
                      "message_id": "3EB0...",
                      "type": "text",
                      "text": "Chegou a coleção de verão!",
                      "timestamp": "2026-11-23T15:00:00Z",
                      "views": 830,
                      "reactions": {
                        "❤️": 41
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/webhook": {
      "put": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "putInstancesByIdWebhook",
        "summary": "Configurar webhook",
        "description": "Define a URL que recebe os eventos da instância por POST e, se quiser, quais eventos ela recebe.\n\n**Filtro de eventos**\n\n\"events\" é opcional. Sem ele, ou com [], chegam todos. \"call.\\*\" vale para todas as ligações. A lista completa está em GET /webhook-events; um nome errado devolve 400 \"invalid_events\".\n\n**Assinatura**\n\nTodo POST traz o header X-W2-Signature: t=<timestamp>,v1=<assinatura>. A assinatura é o HMAC-SHA256, em hexadecimal, de \"<timestamp>.<corpo cru>\" com o \"secret\" como chave. Para conferir, calcule o mesmo HMAC sobre o corpo exatamente como chegou e compare. Recuse se não bater ou se o timestamp tiver mais de 5 minutos.\n\nNode.js:\n\nconst [t, v1] = sig.split(',').map(p => p.split('=')[1])\n\nconst ok = crypto.createHmac('sha256', secret).update(t + '.' + rawBody).digest('hex') === v1\n\nO \"secret\" se mantém quando você troca a URL. Para gerar outro, use POST /instances/{id}/webhook/rotate-secret.\n\nTambém vêm os headers X-W2-Event (nome do evento) e X-W2-Instance (ID da instância).\n\n**Entrega**\n\nResposta 2xx confirma a entrega. Erro de rede ou 5xx tenta de novo; 3xx e 4xx não, porque são considerados erro de configuração.\n\nEventos\n\nConexão: connected, disconnected, logged_out (o número foi despareado).\n\nMensagens: message (qualquer mensagem recebida, e também as enviadas pelo celular do número, com is_from_me: true).\n\nHistórico: history_sync (chega depois de conectar, às vezes em vários lotes).\n\nStatus das enviadas: message_sent (✓), message_delivered (✓✓), message_read (✓✓ azul, só se a pessoa deixa a confirmação de leitura ligada), message_played (áudio ouvido), message_failed.\n\nConversa lida no celular: chat_read (alguém do número leu a conversa no celular ou em outro aparelho) e chat_unread (marcou como não lida).\n\nPresença: presence (só para contatos assinados em /presence/subscribe).\n\nLigações: call.offer (recebida, tocando), call.ringing (feita, tocando), call.accepted (atendida, com áudio), call.rejected, call.ended.\n\nEnquetes: poll_vote (alguém votou ou tirou o voto numa enquete).\n\nEnvios agendados: scheduled_sent (saiu na hora marcada, com o message_id) e scheduled_failed (não saiu, com o motivo).\n\nTodo evento vem neste formato:\n\n```json\n{\n  \"event\": \"message\",\n  \"instance_id\": \"11cb9c03-...\",\n  \"timestamp\": \"2026-03-30T14:30:00Z\",\n  \"data\": { ... }\n}\n```\n\n**Mensagem de texto**\n\n\"data\": {\n\n\"message_id\": \"3EB0...\",\n\n\"from\": \"5511999999999@s.whatsapp.net\",\n\n\"chat\": \"5511999999999@s.whatsapp.net\",\n\n\"is_group\": false,\n\n\"push_name\": \"João\",\n\n\"type\": \"text\",\n\n\"text\": \"Olá!\"\n\n}\n\n\"type\" pode ser text, image, video, audio, document, ptv, sticker, location, contact, reaction ou unknown (tipos que ainda não tratamos, como enquete). Status/stories e mensagens internas do WhatsApp não geram evento. Fotos de um álbum chegam uma a uma. Em grupo vem também \"participant\", com quem mandou.\n\n**Resposta a outra mensagem**\n\nVem \"is_reply\": true e os campos da mensagem citada:\n\n\"data\": {\n\n\"message_id\": \"3EB0NOVA...\",\n\n\"text\": \"Pode confirmar?\",\n\n\"is_reply\": true,\n\n\"quoted_message_id\": \"3EB0ORIGINAL...\",\n\n\"quoted_participant\": \"5511888888888@s.whatsapp.net\",\n\n\"quoted_text\": \"Seu pedido saiu para entrega\",\n\n\"quoted_type\": \"text\",\n\n...\n\n}\n\nEsses valores podem ir direto para /messages/reply. Vale também para mídia. Quando a resposta cita uma mensagem de outra conversa (\"Responder em particular\" a partir de um grupo), vem também \"quoted_chat\" com o JID do grupo. Quem foi marcado com \"@numero\" vem em \"mentioned_jids\".\n\n**Reação**\n\n\"data\": {\n\n\"message_id\": \"3EB0REACAO...\",\n\n\"type\": \"reaction\",\n\n\"reaction_message_id\": \"3EB0ORIGINAL...\",\n\n\"reaction_emoji\": \"👍\",\n\n...\n\n}\n\n\"reaction_message_id\" é a mensagem que recebeu a reação. Quando a pessoa tira a reação chega outro evento com \"reaction_emoji\": \"\". Uma reação nova da mesma pessoa substitui a anterior.\n\n**Cartão de contato**\n\n\"data\": {\n\n\"message_id\": \"3AAD6AE0...\",\n\n\"type\": \"contact\",\n\n\"text\": \"ALUCAR Porto Seguro\",\n\n\"vcard\": \"BEGIN:VCARD\n\nVERSION:3.0\n\nFN:ALUCAR Porto Seguro\n\nitem1.TEL;waid=5573999999999:+55 73 99999-9999\n\nEND:VCARD\",\n\n\"vcards\": [\"BEGIN:VCARD...\"],\n\n\"contacts\": [\n\n```json\n{ \"name\": \"ALUCAR Porto Seguro\", \"phone\": \"5573999999999\", \"phones\": [\"5573999999999\"] }\n```\n\n],\n\n...\n\n}\n\n\"vcard\" é o cartão do jeito que o WhatsApp entregou. Quando a pessoa manda vários contatos de uma vez, \"vcards\" e \"contacts\" trazem todos, e \"vcard\" é o primeiro. Em \"contacts\", \"phone\" é o número com DDI, só dígitos, pronto para enviar mensagem. GET /messages traz os mesmos campos.\n\n**Mensagem encaminhada**\n\nOs mesmos campos, com \"is_forwarded\": true e \"forwarding_score\" (quantas vezes já foi encaminhada).\n\nMídia (imagem, áudio, vídeo, documento, figurinha)\n\n\"data\": {\n\n\"message_id\": \"3EB0...\",\n\n\"media_type\": \"image\",\n\n\"mime_type\": \"image/jpeg\",\n\n\"caption\": \"Veja isso!\",\n\n\"media_size\": 48213,\n\n\"media_base64\": \"iVBORw0KGgoAAAANSUhEUgAA...\",\n\n...\n\n}\n\n\"media_base64\" é o arquivo inteiro. Documentos trazem \"filename\". Figurinhas vêm como \"sticker\" em image/webp.\n\nSe o arquivo for grande demais, o evento chega sem \"media_base64\", com \"media_unavailable\": true e \"media_unavailable_reason\" (media_too_large ou download_failed). Mostre a mensagem normalmente, avisando que a mídia está no celular.\n\n**Status de mensagem enviada**\n\n```json\n{\n  \"event\": \"message_read\",\n  \"data\": {\n    \"message_id\": \"3EB0...\",\n    \"chat\": \"5511999999999@s.whatsapp.net\",\n    \"status\": \"read\",\n    \"timestamp\": \"2026-03-30T14:30:42Z\",\n    \"is_from_me\": true\n  }\n```\n\n}\n\nVale também para as mensagens enviadas pelo celular do número. Em grupo chega um evento por participante, com \"participant\". GET .../messages/{msgID}/status traz o status mais avançado.\n\n**Conversa lida no celular**\n\n```json\n{\n  \"event\": \"chat_read\",\n  \"data\": {\n    \"chat\": \"5511999999999@s.whatsapp.net\",\n    \"read\": true,\n    \"message_ids\": [\"3EB0...\", \"3EB1...\"],\n    \"source\": \"receipt\",\n    \"timestamp\": \"2026-03-30T14:31:10Z\",\n    \"is_from_me\": false\n  }\n```\n\n}\n\nChega quando alguém abre a conversa no celular do número (ou em outro aparelho conectado) e lê mensagens recebidas. Use para zerar as não lidas da conversa. \"message_ids\" são as mensagens lidas, e em grupo vem \"participant\" com quem as mandou.\n\n\"source\": \"receipt\" quando a conversa foi aberta e lida. \"source\": \"mark\" quando foi marcada pelo menu da lista de conversas, e aí não vem \"message_ids\". \"Marcar como não lida\" gera chat_unread, com \"read\": false.\n\n**Histórico**\n\n\"data\": { \"messages\": 128, \"conversations\": 12, \"progress\": 100 }\n\nQuantas mensagens e conversas vieram no lote e o progresso em %. Depois disso, consulte /chats e /messages.\n\n**Presença**\n\n\"data\": {\n\n\"from\": \"5511999999999@s.whatsapp.net\",\n\n\"online\": true,\n\n\"last_seen\": \"2026-03-30T14:29:55Z\"\n\n}\n\n\"last_seen\" não vem quando o contato esconde o \"visto por último\".\n\n**Ligação**\n\n```json\n{\n  \"event\": \"call.accepted\",\n  \"data\": {\n    \"call_id\": \"89F0B85B5AA8F1ED3570909556B8B647\",\n    \"peer\": \"5511999999999@s.whatsapp.net\",\n    \"direction\": \"outgoing\",\n    \"status\": \"accepted\",\n    \"started_at\": \"2026-11-09T13:23:19Z\"\n  }\n```\n\n}\n\n\"direction\": outgoing (feita por você) ou incoming (recebida). call.ended e call.rejected trazem também \"ended_at\" e \"reason\" (hangup, timeout, accepted_elsewhere, server_busy...).\n\n**Voto em enquete**\n\n```json\n{\n  \"event\": \"poll_vote\",\n  \"data\": {\n    \"poll_message_id\": \"3EB0C5A1B2D3E4F5\",\n    \"chat\": \"120363000000000000@g.us\",\n    \"voter\": \"5511999999999@s.whatsapp.net\",\n    \"is_from_me\": false,\n    \"selected_options\": [\"Tarde\"],\n    \"timestamp\": \"2026-11-23T18:00:00Z\"\n  }\n```\n\n}\n\n\"selected_options\" traz o nome das opções. Vem [] quando a pessoa tira o voto. Em enquetes que o Whats2 nunca viu (criadas antes desta versão), as opções não têm nome e chegam contadas em \"unknown_options\".\n\n**Envio agendado**\n\n```json\n{\n  \"event\": \"scheduled_sent\",\n  \"data\": {\n    \"scheduled_id\": \"4b1f0c2e-...\",\n    \"type\": \"text\",\n    \"send_at\": \"2026-12-01T12:00:00Z\",\n    \"message_id\": \"3EB0C5A1B2D3E4F5\"\n  }\n```\n\n}\n\n\"scheduled_failed\" traz \"error\" no lugar de \"message_id\".",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "url": "https://meu-servidor.com/webhook",
                "events": [
                  "message",
                  "message_read",
                  "call.*"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "secret": {
                      "type": "string"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "url": "https://meu-servidor.com/webhook",
                  "secret": "whsec_8b1f...",
                  "events": [
                    "message",
                    "message_read",
                    "call.*"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getInstancesByIdWebhook",
        "summary": "Ver webhook",
        "description": "Mostra o webhook da instância: URL, secret de assinatura e filtro de eventos.\n\n404 com \"code\": \"webhook_not_set\" se a instância não tem webhook. Webhooks criados antes da assinatura existir ganham um secret na primeira consulta.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "secret": {
                      "type": "string"
                    },
                    "events": {
                      "type": "array",
                      "items": {}
                    }
                  }
                },
                "example": {
                  "url": "https://meu-servidor.com/webhook",
                  "secret": "whsec_8b1f...",
                  "events": []
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "deleteInstancesByIdWebhook",
        "summary": "Remover webhook",
        "description": "Remove o webhook da instância.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/instances/{id}/webhook/rotate-secret": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "postInstancesByIdWebhookRotateSecret",
        "summary": "Gerar novo secret",
        "description": "Gera um secret de assinatura novo. O anterior para de valer na hora.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID da instância"
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "secret": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "secret": "whsec_41c9..."
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Instância não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-events": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getWebhookEvents",
        "summary": "Listar eventos",
        "description": "Lista os nomes de evento que o filtro do webhook aceita.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "events": [
                    "message",
                    "message_sent",
                    "message_delivered",
                    "message_read",
                    "message_played",
                    "message_failed",
                    "chat_read",
                    "chat_unread",
                    "poll_vote",
                    "presence",
                    "history_sync",
                    "scheduled_sent",
                    "scheduled_failed",
                    "connected",
                    "disconnected",
                    "logged_out",
                    "call.offer",
                    "call.ringing",
                    "call.accepted",
                    "call.rejected",
                    "call.ended"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Sem credencial, chave revogada ou token expirado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Erro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Chave de API (w2_…), criada em Minha conta ou em POST /api-keys."
      },
      "Bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Chave de API (w2_…) ou o token de sessão do login (expira em 7 dias)."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Mensagem legível; o texto pode mudar."
          },
          "code": {
            "type": "string",
            "description": "Identificador estável do erro (snake_case).",
            "examples": [
              "instance_not_connected"
            ]
          }
        }
      }
    }
  }
}
