This guide explains how to use the Twilio Senders API to register a phone number on the WhatsApp Business Platform (Twilio calls this a WhatsApp Sender) to begin sending and receiving messages on WhatsApp using the Twilio APIs.
If your use case does not require registering several WhatsApp Senders, then Twilio highly recommends using WhatsApp Self Sign-up in the Twilio Console to register your WhatsApp Senders rather than via the Senders API.
The Twilio Senders API is currently available as a Public Beta product. This means that some features (including Twilio SDK support) for configuring your WhatsApp Sender via the REST API are not yet implemented, and others may be changed without notice before the product is declared Generally Available. Managing your WhatsApp Senders through the Twilio Console is Generally Available.
Public Beta products are not covered by a Twilio SLA.
The resources for sending and receiving Messages with a WhatsApp Sender are Generally Available.
Meta requires all phone numbers registered on WhatsApp to have their ownership verified as a part of the registration process before they can send and receive messages. This is done by sending a verification code via either SMS or an automated voice call. If using a Twilio Phone Number with SMS capability, then Twilio will do this automatically as a part of the registration process outline below.
ONLINE
status before moving to the next one.There is no API to change the display name (i.e. profile.name
property in the Senders API). Meta reviews display name asynchronously after the WhatsApp Sender is registered. Before registering WhatsApp Senders in bulk, verify the display name is not rejected by Meta with a single WhatsApp Sender before continuing. If the display name is rejected by WhatsApp, the phone number's messaging limit will drop to 250 business-initiated messages per 24-hour period and may risk disconnection by WhatsApp. Resolving this requires submitting a support ticket to Twilio.
You may purchase a Twilio number using our Phone Number APIs, or bring your own non-Twilio phone number (BYON). We recommend using a Twilio Phone Number that has SMS capabilities, as then Twilio will do the verification step automatically for you.
If using a Twilio Voice-only phone number, you will need to configure it to make sure you can receive the verification code, before moving on to the next step.
See our support article Which Twilio Phone Numbers are Compatible with WhatsApp? for more information.
Run the following cURL command, substituting the following required information:
sender_id
field
profile.name
)You may optionally include the following additional information:
webhooks.callbackUrl
and webhooks.fallbackUrl
) and outbound message status updates (webhooks.statusCallbackUrl
)This will create your WhatsApp sender in Twilio's system, add it to the WABA connected to your Twilio account, and trigger the verification code from Meta.
Make a note of the WhatsApp Sender's SID (starting with an XE
), as you will need it in the next step.
1## Create Sender2curl -X "POST" "https://messaging.twilio.com/v2/Channels/Senders" \3-H "Content-Type: application/json; charset=utf-8" \4-u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" \5-d $'{6"sender_id": "whatsapp:+15017122661",7"profile": {8"address": "101 Spear Street, San Francisco, CA",9"emails": [10"support@twilio.com"11],12"vertical": "Other",13"logo_url": "https://www.twilio.com/logo.png",14"description": "We\'re excited to see what you build!",15"about": "Hello! We are Twilio.",16"name": "Twilio",17"websites": [18"https://twilio.com",19"https://help.twilio.com"20]21},22"webhook": {23"callback_method": "POST",24"callback_url": "https://demo.twilio.com/welcome/sms/reply/"25}26}'
1{2"status": "CREATING",3"sender_id": "whatsapp:+15017122661",4"sid": "XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",5"configuration": {6"waba_id": "12345678912345"7},8"profile": {9"about": "Hello! This is Twilio's official account.",10"name": "Twilio",11"vertical": "Other",12"websites": [13{14"website": "https://twilio.com",15"label": "Website"16},17{18"website": "https://help.twilio.com",19"label": "Website"20}21],22"address": "101 Spear Street, San Francisco, CA",23"logo_url": "https://www.twilio.com/logo.png",24"emails": [25{26"email": "support@twilio.com",27"label": "Email"28}29],30"description": "We're excited to see what you build!"31},32"webhook": {33"callback_method": "POST",34"callback_url": "https://demo.twilio.com/welcome/sms/reply/"35},36"url": "https://messaging.twilio.com/v2/Channels/Senders/XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",37"properties": null38}
Once you receive the verification code, you must update your WhatsApp Sender with it by making the following cURL command substituing the code you received.
1## Verify Sender2curl -X "POST" "https://messaging.twilio.com/v2/Channels/Senders/XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \3-H 'Content-Type: text/plain; charset=utf-8' \4-u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" \5-d '{6"configuration": {7"verification_code": "123456"8}9}'
1{2"sid": "XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",3"sender_id": "whatsapp:+15558675310",4"status": "VERIFYING",5"profile": {6"about": "Hello! This is Twilio's official account.",7"name": "Twilio",8"vertical": "Other",9"websites": [10{11"website": "https://twilio.com",12"label": "Website"13},14{15"website": "https://help.twilio.com",16"label": "Website"17}18],19"address": "101 Spear Street, San Francisco, CA",20"logo_url": "https://www.twilio.com/logo.png",21"emails": [22{23"email": "support@twilio.com",24"label": "Email"25}26],27"description": "We're excited to see what you build!"28},29"webhook": {30"callback_method": "POST",31"callback_url": "https://demo.twilio.com/welcome/sms/reply/",32"fallback_method": "POST",33"fallback_url": "",34"status_callback_url": "",35"status_callback_method": "POST"36},37"url": "https://messaging.twilio.com/v2/Channels/Senders/XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",38"configuration": {39"waba_id": "123456789"40},41"properties": {42"messaging_limit": "1K Customers/24hr",43"quality_rating": "HIGH"44}45}
In order to verify that the WhatsApp Sender was successfully registered, you will need to make the following request to fetch the WhatsApp Sender. In the response, check the status to make sure that it shows as ONLINE
. If it still notes that it is PENDING_VERIFICATION
then you will need to return to Step 2 in order to request another verification code.
Note that a WhatsApp Sender may briefly show as OFFLINE
when registering. If that happens, please wait a few minutes and fetch the WhatsApp Sender again. If it is still showing as OFFLINE
then open a support ticket.
Once the WhatsApp Sender shows as ONLINE
you may begin sending and receiving messages on WhatsApp using the Twilio APIs. Congrats!
Now that you have a WhatsApp Sender registered, here are some other must reads when building your WhatsApp integration using Twilio.
Last updated July 2024