Connect your WhatsApp number
Let your Speko agent answer and place WhatsApp calls on your own WhatsApp Business number, through your own Meta app.
When a customer taps Call in your WhatsApp chat, Meta sends the call to the app you connect, and your Speko agent answers. Your number stays in your WhatsApp Business Account. Speko reads it with a token you give it and never changes its settings.
Before you start
You need a phone number on the WhatsApp Cloud API and its phone number ID (WhatsApp Manager, Phone numbers). Meta does not support calling on a number that is also in use with the WhatsApp Business app.
Turn on calling for the number (WhatsApp Manager, Phone numbers, Call settings). Speko connects a number with calling off, but no calls reach it until you turn calling on.
Choose the app that receives calls
Meta sends the number's calls webhooks to a Meta app. Pick the app first, because you connect the number with that app's credentials.
- A dedicated app. Use it when no other system needs the number's call events. In the same Meta business, create a new app with the WhatsApp product, and subscribe it to your WhatsApp Business Account with
POST /<WABA_ID>/subscribed_apps, using a token of the new app. A Meta app has one callback URL, so use one dedicated app for each number you connect. - The app you already have. Use it when that app must keep receiving every webhook. Your webhook then forwards the call deliveries to Speko.
From the app you picked, collect:
- The app secret (App Dashboard, App settings, Basic).
- A system user access token issued for that same app, with the
whatsapp_business_managementandwhatsapp_business_messagingpermissions, and assigned to the WhatsApp Business Account that owns the number.
Connect the number
Send the token, the app secret, and the phone number ID to Speko. agentId is optional. Without it, the number does not answer calls until you set an agent.
curl https://api.speko.dev/v1/whatsapp/connections \
-H "Authorization: Bearer $SPEKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"accessToken": "EAAG...",
"appSecret": "8f2c...",
"phoneNumberId": "1484527921401132",
"agentId": "agent_..."
}'The API key needs the speko:credentials scope, because the request carries your Meta credentials. Listing numbers needs speko:read, changing a number's agent needs speko:write, and disconnecting needs speko:credentials. Speko checks the token and the app secret with Meta, then returns the connection:
{
"id": "5c0d6a3e-...",
"webhookUrl": "https://api.speko.dev/webhooks/whatsapp/c/Qm9...",
"verifyToken": "c2Vj...",
"number": {
"id": "0b7e...",
"phoneNumberId": "1484527921401132",
"e164": "+15551234567",
"displayName": "Acme Support",
"agentId": "agent_...",
"callingStatus": "enabled",
"callingStatusCheckedAt": "2026-11-17T10:00:00.000Z",
"connection": { "id": "5c0d6a3e-...", "kind": "customer_app", "webhookUrl": "https://api.speko.dev/webhooks/whatsapp/c/Qm9...", "verifyToken": "c2Vj..." },
"createdAt": "2026-11-17T10:00:00.000Z"
}
}Speko encrypts the token and the app secret and never returns them. Sending the same request again returns the same connection. Keep the webhookUrl and the verifyToken for the next step. GET /v1/whatsapp/numbers shows them again.
If Speko refuses the request:
WHATSAPP_TOKEN_INVALIDmeans that Meta rejected the token, or that the token cannot read numbers. Generate a new system user token with both permissions.WHATSAPP_APP_SECRET_INVALIDmeans that the app secret does not belong to the app that issued the token. Send the secret and a token of the same app.WHATSAPP_NUMBER_NOT_FOUNDmeans that Meta found no number with this ID that the token can read. Check the phone number ID, and assign the system user to the WhatsApp Business Account.WHATSAPP_NUMBER_NOT_CLOUD_APImeans that the number is not registered on the Cloud API, or runs on the On-Premises API. Register it on the Cloud API first.WHATSAPP_NUMBER_ON_BUSINESS_APPmeans that the number is also in use with the WhatsApp Business app. Meta supports calling only on a number used with the Cloud API alone.WHATSAPP_NUMBER_ALREADY_CONNECTEDmeans that another connection already holds this number. Disconnect that connection first.WHATSAPP_GRAPH_UNAVAILABLEmeans that Speko could not reach Meta. Try again.
Point Meta at Speko
With a dedicated app
- In the dedicated app's App Dashboard, open WhatsApp, then Configuration.
- Set Callback URL to your
webhookUrland Verify token to yourverifyToken, then click Verify and save. - Subscribe the webhook to the
callsfield only. Leavemessageson your existing app, so your chat bot keeps receiving messages.
With the app you already have
When your webhook receives a delivery with a calls change, send a POST to the webhookUrl of each connected number that appears in a calls change, with:
- The request body exactly as Meta sent it, byte for byte.
- The
X-Hub-Signature-256header unchanged. Content-Type: application/json.
Speko checks the signature against the raw bytes. If your code parses the JSON and serializes it again, the bytes change and Speko drops the delivery. Read the raw body before your framework parses it.
Answer Meta only after Speko answers. If a forward fails, answer Meta with an error, so that Meta delivers the batch again. Meta then also redelivers the other updates in the batch, so your own handling must accept a repeat.
import express from 'express';
// The webhookUrl Speko returned for each connected phone number ID.
const spekoWebhookUrls: Record<string, string> = {
'1484527921401132': 'https://api.speko.dev/webhooks/whatsapp/c/Qm9...',
};
type MetaDelivery = {
entry?: Array<{ changes?: Array<{ field?: string; value?: { metadata?: { phone_number_id?: string } } }> }>;
};
const app = express();
app.post('/meta-webhook', express.raw({ type: 'application/json' }), async (req, res) => {
const body: Buffer = req.body;
const delivery: MetaDelivery = JSON.parse(body.toString('utf8'));
const urls = new Set(
(delivery.entry ?? [])
.flatMap((entry) => entry.changes ?? [])
.filter((change) => change.field === 'calls')
.map((change) => spekoWebhookUrls[change.value?.metadata?.phone_number_id ?? ''])
.filter((url): url is string => url !== undefined),
);
const forwarded = await Promise.all(
[...urls].map((url) =>
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Hub-Signature-256': req.get('X-Hub-Signature-256') ?? '',
},
body,
signal: AbortSignal.timeout(10_000),
}).then(
(reply) => reply.ok,
() => false,
),
),
);
res.sendStatus(forwarded.every(Boolean) ? 200 : 503);
});Forward within a few seconds. Speko drops an incoming call that Meta stamped more than 120 seconds before it arrives, because the caller has most likely hung up.
Check the connection
Call the number from WhatsApp. The agent answers, and the call shows in Sessions with the WhatsApp channel.
If the call never reaches the agent:
- Run
GET /v1/whatsapp/numbers. AcallingStatusofdisabledmeans calling is off in WhatsApp Manager. Speko re-reads the status from Meta at most every 10 minutes. - Check that the number has an
agentId. - Check the app secret. Speko answers
200to a delivery whose signature does not match and does nothing with it, so Meta shows no error. - In the forwarding setup, check that the forwarder sends the raw body and the original
X-Hub-Signature-256header.
Change the agent
curl -X PATCH https://api.speko.dev/v1/whatsapp/numbers/<number id> \
-H "Authorization: Bearer $SPEKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "agentId": "agent_..." }'Send "agentId": null to stop answering calls on the number. One agent answers at most one WhatsApp number. The same agent can also answer a phone number.
Disconnect
curl -X DELETE https://api.speko.dev/v1/whatsapp/connections/<connection id> \
-H "Authorization: Bearer $SPEKO_API_KEY"Speko ends any call in progress on the number, deletes the stored token and app secret, and removes the number from the list. If Speko cannot end a call, callsNotEnded in the response counts it, and the call ends when the caller hangs up. A call that Speko was still placing counts too. It hangs up as soon as Meta confirms it. A repeated request returns callsNotEnded: null, because it cannot know how the first one went. The webhook URL keeps answering 200 but starts no calls. Past sessions stay. To connect the number again, create a new connection. You get a new webhookUrl and verifyToken, so update your Meta app or your forwarder.
Call a WhatsApp user
Your agent can also call a WhatsApp user. Send channel: "whatsapp" to POST /v1/sessions/phone:
curl https://api.speko.dev/v1/sessions/phone \
-H "Authorization: Bearer $SPEKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "channel": "whatsapp", "to": "+77719889995", "agentId": "agent_123" }'fromnames one of your workspace's WhatsApp numbers. Leave it out to call from the WhatsApp number the agent answers.- The user must first give your WhatsApp number permission to call them. Without it, Meta refuses the call and the API returns 403
WHATSAPP_CALL_PERMISSION_REQUIRED. - Meta does not allow business-initiated calls from numbers in the United States, Canada, Egypt, Vietnam or Nigeria. A call from such a number returns 403
WHATSAPP_OUTBOUND_UNAVAILABLE. - If the user declines, the session ends as
failedwith end reasonsip_declined. - A call from a disconnected number returns
CALLER_ID_NOT_OUTBOUND. Connect the number again first. - A phone call (no
channel, orchannel: "phone") from a WhatsApp number returns 400CALLER_ID_WHATSAPP_NUMBER. A WhatsApp number has no phone line. Sendchannel: "whatsapp", or call from one of your phone numbers. - Speko bills the agent minute only. Meta bills the call to the WhatsApp Business Account that owns the number.
telephonyoptions (AMD, DTMF, region) apply to phone calls only and are refused.
Limits
- One number per connection, and one dedicated Meta app per number when you use dedicated apps.
- Speko connects at most 30 calls per minute on one connection, and handles at most 120 call events and call statuses per minute on it. It drops the extra ones.
- A WhatsApp call cannot be transferred to a phone number. This is a WhatsApp rule.
- Some countries restrict WhatsApp voice calls.