# WhatsApp

Bonga connects to WhatsApp in two ways. Both produce senders in discovery, so one integration can address either.

## Linked WhatsApp

Pair a phone from **Dashboard → Channels → WhatsApp → Linked number**. Scan the QR code with the WhatsApp app. The session lives on Bonga's gateway, and the phone remains the source of truth for the account.

Use it for:

- support desks answering an existing business number;
- low-volume transactional messages;
- media, polls, locations, contacts, reactions, revokes and groups;
- teams that want a shared inbox on a number they already own.

Limits to know:

- Meta may restrict unofficial sessions; keep volume human-paced.
- The phone must stay reachable occasionally for the session to remain valid.
- Production OTP over linked sessions is disabled by default.

The session appears as a sender with a `linked_whatsapp` connection type. REST operations cover sending, device status, groups, chats, contacts and message actions under `/api/v1/whatsapp/devices/*`.

## WhatsApp Cloud API

Cloud API is the official Meta path. Connect a Meta Business account in **Dashboard → Channels → WhatsApp → Cloud API**, then verify the phone number ID and WABA. Bonga stores the system-user token encrypted and resolves it per send.

Use it for:

- official, policy-compliant messaging at scale;
- approved templates, including authentication templates for OTP;
- media, interactive messages and delivery receipts;
- a number that must not depend on a phone staying online.

Setup requires a Meta app, a system user with `whatsapp_business_messaging`, the WABA and phone number ID, and webhook configuration. The full walkthrough is in [Connect WhatsApp Cloud API](/guides/facebook-whatsapp-cloud-api) and [Meta Embedded Signup](/guides/meta-embedded-signup).

## Sending

Use the v2 messaging contract for new integrations:

```bash
curl -X POST 'https://api.bonga.africa/api/v2/messages' \
  -H "Authorization: Bearer $BONGA_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: otp-9182' \
  --data '{
    "channel": "whatsapp",
    "from": "snd_example03",
    "to": "+254712345678",
    "content": { "type": "template", "template_id": "order_ready" }
  }'
```

The v1 device routes remain available for media, groups, polls and message actions that v2 does not yet expose.

## Receiving and the inbox

Inbound messages and status receipts land in the shared inbox and are available to automations. Cloud API webhooks are verified with `X-Hub-Signature-256`. Linked sessions poll and stream through Bonga's gateway.

## Best practices

- Send from a dedicated number, not a personal one.
- Warm new numbers slowly and keep complaint rates low.
- Use templates for business-initiated Cloud sends.
- Do not use unofficial sessions for OTP or bulk marketing.
- Keep one sender per use case so analytics and quality signals stay readable.

## Next

- [WhatsApp Cloud API](/docs/whatsapp-cloud)
- [Messaging API v2](/docs/messaging-api-v2)
- [Inbox and Messenger](/docs/inbox)
