Skip to main content

Samples

Below are practical examples of how to use the WhatsApp Calling API to initiate, accept, and end calls. Each scenario shows the sequence of requests and responses, as well as the webhooks received. For details about the endpoints and their parameters, see the Calling API. To understand webhook events, see Webhooks.

Scenario A — Call initiated by the company (outbound)

In this scenario, your company initiates a call to a WhatsApp user.

Step 1: Check call permission

Before initiating a call, verify that your company has permission to call the user. Meta imposes call limitations that may vary based on communication history. Request:
Response:
The calling.permission.status field can be no_permission, temporary, or permanent. Consult the actions table to determine if you can initiate a call and what the limits are (maximum calls per period).

Step 2: Initiate the call

If the permission is confirmed and you have available calls, initiate the call by sending the SDP (Session Description Protocol) offer. Request:
Response:

Step 3: End the call

When the call terminates (user hangs up, you want to end it, etc.), send the termination request with the call_id that you obtained from the start webhook (connect) or in the response body. Request:
Response:

Step 4: Receive the termination webhook

After the call is terminated, you receive a webhook at the configured calls_webhook for the number with the terminate event. The delivered webhook is the raw Meta envelope with the structure below:
The object inside calls[] contains information about how the call ended: direction indicates who initiated the termination, duration is the time in seconds, and status shows whether it was completed successfully or not.

Scenario B — Call received from a user (inbound)

In this scenario, a WhatsApp user initiates a call to your company.

Step 1: Receive the call start webhook

When a user attempts to call your number, you receive a webhook at calls_webhook with the connect event. This webhook contains the call_id (in the id field) and the user’s SDP offer.
Use the id field (example: wacid.HBgM...) as the call_id for the next actions (accept or reject). The connection.webrtc.sdp is the user’s SDP offer.

Step 2: Accept the call (or reject)

You can accept the call by responding with your own SDP or reject it. To accept: Request:
Response:
To reject the call: Request:
Response:

Step 3: End the call

When the active call terminates (one of the parties hangs up), you end the call: Request:
Response:

Step 4: Receive the termination webhook

After termination, you receive a webhook with the terminate event:
The terminate webhook is the same for both scenarios (outbound and inbound). Use the direction, duration, and status fields to record details about how the call ended.