Skip to main content
This guide shows the normal production flow for a WaGo customer deployment. The user runs the WaGo binary on their server, then their own app calls the HTTP API.

Architecture

Your app or dashboard
  -> WaGo HTTP API
  -> WhatsApp connection
  -> WhatsApp users and groups

WaGo webhook
  -> Your backend webhook receiver
  -> Your database, jobs, CRM, inbox, or automation
Keep WaGo and your app separated:
PartResponsibility
WaGoWhatsApp session, QR scan, sending, receiving, media, calls, webhooks.
Your backendUser login, permissions, token ownership, business rules, database, billing, webhook processing.
Your frontendSession status UI, QR display, inbox UI, send forms, call UI.

Step 1: Store the WaGo token in your app

Each connected WhatsApp account uses a WaGo session token. Your app should map that token to your own user, team, workspace, or customer. If the token does not exist yet, create it with POST /session/init from a trusted backend. See Create a token for the full admin flow. Example database shape:
FieldExample
workspace_idworkspace_123
wago_tokencustomer-token-1
wago_jid[email protected]
webhook_urlhttps://app.example.com/wago/webhook
connectedtrue
logged_intrue
Do not expose your admintoken to the frontend. If your product creates WaGo tokens for users, do that from your backend.

Step 2: Configure webhooks

Set the webhook URL for the token:
curl -X POST http://localhost:1337/webhook \
  -H "Content-Type: application/json" \
  -H "token: YOUR_TOKEN" \
  -d '{
    "WebhookURL": "https://app.example.com/wago/webhook"
  }'
Then connect with the event types your app needs:
curl -X POST http://localhost:1337/session/connect \
  -H "Content-Type: application/json" \
  -H "token: YOUR_TOKEN" \
  -d '{
    "Subscribe": ["Message", "ReadReceipt", "Presence", "ChatPresence", "Call", "LoggedOut"],
    "Immediate": true,
    "Phone": ""
  }'
Use ["All"] when building the first version. Reduce the list when your app is stable.

Step 3: Show scan status

Your frontend can poll:
curl -H "token: YOUR_TOKEN" \
  http://localhost:1337/session/status
Use these fields:
FieldMeaning
ConnectedWaGo has an active WhatsApp connection.
LoggedInThe device has been scanned and authenticated.
JidThe connected WhatsApp account. Store it after scan.
EventsSubscribed event types.
If the session is not logged in, fetch the QR:
curl -H "token: YOUR_TOKEN" \
  http://localhost:1337/session/qr
Render QRCode as an image in your UI.

Step 4: Send a message

curl -X POST http://localhost:1337/send/text \
  -H "Content-Type: application/json" \
  -H "token: YOUR_TOKEN" \
  -d '{
    "Phone": "15551234567",
    "Body": "Hello from WaGo"
  }'
Store the returned message ID. You need it for read receipts, message status, reactions, edits, and delete operations.

Step 5: Receive messages

Your webhook receives form data:
Form fieldUse
tokenFind the customer/session in your database.
jsonDataParse as JSON and process the event.
fileOptional uploaded media file when WaGo forwards downloaded media.
Minimal receiver behavior:
  1. Parse form data.
  2. Parse jsonData.
  3. Store the raw event.
  4. Store key indexes such as token, type, message ID, chat JID, sender JID, and timestamp.
  5. Save uploaded files before responding.
  6. Respond with 2xx quickly.
  7. Queue slow actions after the response.
See Webhook events for event examples.

Step 6: Handle media

For outbound media, choose one of two patterns:
PatternUse when
Base64 data URLFiles are small and already available in your app.
Direct URLFiles are large or already stored in object storage/CDN.
For inbound media, use webhook file forwarding if enabled. If you do not receive the file, use the media metadata from the message event and call the matching download endpoint.

Step 7: Production troubleshooting flow

When something fails, check in this order:
  1. GET /server/ok to confirm the binary is reachable.
  2. GET /session/status to confirm token, connection, and login.
  3. GET /webhook to confirm webhook URL and subscriptions.
  4. Server logs for the request status and WhatsApp error.
  5. Your webhook receiver logs for delivery and parse errors.
  6. The local API explorer at http://localhost:1337/api for a direct endpoint test.

Common production mistakes

ProblemFix
Frontend uses admintokenMove admin calls to your backend.
QR page never updatesPoll /session/status and refresh /session/qr only when needed.
Messages send but app does not updateSubscribe to ReadReceipt and store webhook events.
Media fails through proxyIncrease request body size and timeout limits.
Webhooks arrive multiple timesDeduplicate by message ID or event key.
Browser calls fail in productionUse HTTPS for both your app and WaGo API.
Calls work locally but not for some usersNetwork may require TURN, which is currently marked coming soon.