Migração 100% grátis na contratação semestral · nossa equipe migra tudo de qualquer provedor · novos clientes Migrar agora
Agente de IA no WhatsApp na API Oficial da Meta · somos Tech Provider aprovado · orçamento sob consulta Pedir orçamento
VPS com OpenClaw pré-instalado · a partir de R$ 56,90/mês · gerenciada pela Rollin Quero a VPS
VPS com Hermes Agent pré-instalado · a partir de R$ 56,90/mês · gerenciada pela Rollin Quero a VPS
Hospedagem com 30 dias de garantia · Não gostou? Devolvemos 100%, sem perguntas. Ver hospedagem

Connect a WhatsApp number to EvolutionAPI

Step-by-step guide to connecting a WhatsApp number to EvolutionAPI, from the first QR code to a test message and a webhook receiving events.

This guide takes you from a server with EvolutionAPI already running to the first message delivering a webhook to your API. Total time: ~10 minutes.

Prerequisites

  • EvolutionAPI running on a public HTTPS domain (e.g. https://evo.sua-empresa.com.br)
  • AUTHENTICATION_API_KEY set in the EvolutionAPI .env
  • A dedicated WhatsApp number (do not use your personal one)
  • Access to the phone to scan the QR code

Step 1: create the instance

curl -X POST https://evo.sua-empresa.com.br/instance/create \
  -H "Content-Type: application/json" \
  -H "apikey: SEU_API_KEY" \
  -d '{
    "instanceName": "atendimento",
    "qrcode": true,
    "integration": "WHATSAPP-BAILEYS"
  }'

The response looks something like this:

{
  "instance": {
    "instanceName": "atendimento",
    "instanceId": "abc-123",
    "status": "created"
  },
  "hash": { "apikey": "..." },
  "qrcode": {
    "code": "2@...",
    "base64": "data:image/png;base64,iVBORw0KGgo..."
  }
}

Step 2: open the QR code

Step 3: scan it in WhatsApp

  1. On the phone with the number you are connecting, open WhatsApp

  2. Tap the three dots → Linked devices (Android) or Settings → Linked devices (iOS)

  3. Tap Link a device

  4. Point the camera at the QR code

  5. Wait 2-5 seconds. EvolutionAPI registers the session automatically.

Step 4: confirm the connection

curl https://evo.sua-empresa.com.br/instance/connectionState/atendimento \
  -H "apikey: SEU_API_KEY"

Expected response:

{
  "instance": {
    "instanceName": "atendimento",
    "state": "open"
  }
}

Possible states:

  • open: connected and ready
  • connecting: pairing (wait)
  • close: disconnected (needs a new QR code)

Step 5: send a test message

curl -X POST https://evo.sua-empresa.com.br/message/sendText/atendimento \
  -H "Content-Type: application/json" \
  -H "apikey: SEU_API_KEY" \
  -d '{
    "number": "5511999999999",
    "text": "Olá! Sou o agente automatizado da Rollin Host. Como posso ajudar?"
  }'

Step 6: configure the webhook

To receive events (incoming messages), point a webhook:

curl -X POST https://evo.sua-empresa.com.br/webhook/set/atendimento \
  -H "Content-Type: application/json" \
  -H "apikey: SEU_API_KEY" \
  -d '{
    "webhook": {
      "enabled": true,
      "url": "https://sua-api.exemplo.com/whats-in",
      "events": ["MESSAGES_UPSERT", "CONNECTION_UPDATE"],
      "webhookByEvents": false
    }
  }'

See Webhooks in EvolutionAPI for payload details and best practices.

Step 7: test the webhook

Send a message to the connected number (from another phone). Within ~1s, your URL receives a POST with:

{
  "event": "messages.upsert",
  "instance": "atendimento",
  "data": {
    "key": {
      "remoteJid": "5511999999999@s.whatsapp.net",
      "fromMe": false,
      "id": "..."
    },
    "pushName": "João Silva",
    "message": {
      "conversation": "Oi, gostaria de informações"
    },
    "messageTimestamp": 1735689600
  }
}

Troubleshooting

ProblemLikely causeHow to fix it
QR code does not appearWrong AUTHENTICATION_API_KEYCheck the apikey header
State stays at connecting foreverQR code expired before scanningGenerate a new one: /instance/connect/atendimento
Sent message returns 400Number not in 5511... formatNo +, no spaces, no -
Webhook never arrivesURL is not HTTPSWebhooks only work with valid HTTPS
Webhook arrives but with 401/403Your API requires authUse webhook_by_events + a secret URL path

Keep the connection stable

The WhatsApp Web session drops from time to time (network outages, app updates). EvolutionAPI reconnects on its own as long as the number has not been banned. If it drops often:

  • Confirm the phone is online (active SIM, internet)
  • Do not open WhatsApp Web on your computer with the same number
  • Do not try to pair it on 2 EvolutionAPI instances at the same time
  • Server with swap configured (without swap, OOM kills the session)

Next steps

Last updated: