Several accounts
Work with workspaces that connect several WhatsApp numbers, Instagram accounts, Messenger Pages or websites.
A workspace can connect several WhatsApp numbers, Instagram accounts, Messenger Pages and Website Chat sites. Each is an account with an id. Webhook events and endpoints name accounts by that id. Conversations and messages from the API don't name their account.
Conversations belong to one account
A customer who writes to two of your numbers has two conversations. Tell them apart by the conversation's id, not by the customer's phone number.
Which account a webhook is about
Every message.received event names the account the customer wrote to:
{
"data": {
"account": { "id": "11", "channel": "WHATSAPP" }
}
}data.account is null for a conversation that has no account.
Webhooks for some accounts only
An endpoint receives events from every account unless you list some in accountIds:
curl -X POST 'https://api.chatwise.so/v1/webhook-endpoints' \
-H "Authorization: Bearer $CHATWISE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"name": "Support number only",
"url": "https://example.com/webhooks/chatwise",
"events": ["message.received"],
"accountIds": ["11"]
}'Without accountIds, or with an empty list, the endpoint also receives events from accounts you connect later. The API has no route that lists accounts. The ids are in webhook events. Once a channel has several accounts, the dashboard lets you choose them by name.
Which number a template is sent from
Both send routes take from: one of the workspace's connected WhatsApp numbers, digits only.
{
"to": "12025550147",
"channel": "WHATSAPP",
"templateId": "123456789012345",
"from": "12025550199"
}Without from, the message goes out from a connected number on the template's WhatsApp Business Account: the one the customer last wrote to, else the oldest. So with several numbers the sender depends on the customer: send from to choose it yourself. The answer's from says which number was used.
A template belongs to one WhatsApp Business Account, and only numbers on that account can send it:
- Send by id refuses a
fromon another account with a 400. - Send by name looks the template up on the account of the
fromnumber. Withoutfrom, it takes the first approved template with that name, on any account.
A from that isn't connected is refused with a 400, whose data.accounts lists the connected numbers.