Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this pageProducts used

Registering WhatsApp Senders via API


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.

(information)

Info

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.

(warning)

Public Beta

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(link takes you to an external page) is Generally Available.

Public Beta products are not covered by a Twilio SLA(link takes you to an external page).

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.


Before you get started

before-you-get-started page anchor
  1. Note that Meta limits the number of WhatsApp Senders you may have in a single WhatsApp Business Account (WABA), and as a result, Twilio account or subaccount . (Twilio only supports a single WABA per unique ASID.) As a result, onboard numbers one by one, waiting until each one successfully returns an ONLINE status before moving to the next one.
  2. If you are not using the WhatsApp Tech Provider Program to onboard customers as an ISV, you must first register a number using WhatsApp Self Sign-up in the Twilio Console.
  3. Delete any numbers already registered on WhatsApp though either the business app or consumer app. Learn how to delete your WhatsApp account(link takes you to an external page) .
  4. If using a Twilio Voice or non-Twilio phone number (BYON), make sure it is not associated with an IVR system (interactive voice response) or any computer-operated phone system that prohibits receiving an verification code via SMS or voice call.
  5. Choose a display name carefully, as it must strictly follow Meta's display name guidelines(link takes you to an external page) .
(warning)

Display name changes are manual

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.


Quick start guide using cURL

quick-start-guide-using-curl page anchor

1. Choose a phone number

1-choose-a-phone-number page anchor

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?(link takes you to an external page) for more information.

2. Create the WhatsApp Sender and trigger the verification code

2-create-the-whatsapp-sender-and-trigger-the-verification-code page anchor

Run the following cURL command, substituting the following required information:

  • your phone number (in e.164 format) within the sender_id field
    • For AR (+54) and MX (+52) numbers, WhatsApp requires the format "+549" and "+521", respectively.
  • your WhatsApp Sender's display name ( profile.name )
  • Twilio Account SID
  • Twilio Auth Token

You may optionally include the following additional information:

  • additional profile details that will be displayed publicly to end-users
  • webhooks that Twilio will use to send inbound messages ( 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.

Verification via SMSVerification via Voice
curl

_26
## Create Sender
_26
curl -X "POST" "https://messaging.twilio.com/v2/Channels/Senders" \
_26
-H "Content-Type: application/json; charset=utf-8" \
_26
-u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" \
_26
-d $'{
_26
"sender_id": "whatsapp:+15017122661",
_26
"profile": {
_26
"address": "101 Spear Street, San Francisco, CA",
_26
"emails": [
_26
"support@twilio.com"
_26
],
_26
"vertical": "Other",
_26
"logo_url": "https://www.twilio.com/logo.png",
_26
"description": "We\'re excited to see what you build!",
_26
"about": "Hello! We are Twilio.",
_26
"name": "Twilio",
_26
"websites": [
_26
"https://twilio.com",
_26
"https://help.twilio.com"
_26
]
_26
},
_26
"webhook": {
_26
"callback_method": "POST",
_26
"callback_url": "https://demo.twilio.com/welcome/sms/reply/"
_26
}
_26
}'

Output

_38
{
_38
"status": "CREATING",
_38
"sender_id": "whatsapp:+15017122661",
_38
"sid": "XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_38
"configuration": {
_38
"waba_id": "12345678912345"
_38
},
_38
"profile": {
_38
"about": "Hello! This is Twilio's official account.",
_38
"name": "Twilio",
_38
"vertical": "Other",
_38
"websites": [
_38
{
_38
"website": "https://twilio.com",
_38
"label": "Website"
_38
},
_38
{
_38
"website": "https://help.twilio.com",
_38
"label": "Website"
_38
}
_38
],
_38
"address": "101 Spear Street, San Francisco, CA",
_38
"logo_url": "https://www.twilio.com/logo.png",
_38
"emails": [
_38
{
_38
"email": "support@twilio.com",
_38
"label": "Email"
_38
}
_38
],
_38
"description": "We're excited to see what you build!"
_38
},
_38
"webhook": {
_38
"callback_method": "POST",
_38
"callback_url": "https://demo.twilio.com/welcome/sms/reply/"
_38
},
_38
"url": "https://messaging.twilio.com/v2/Channels/Senders/XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_38
"properties": null
_38
}

3. Verify the WhatsApp Sender

3-verify-the-whatsapp-sender page anchor
(information)

This step is not required for Twilio SMS-capable phone numbers. You may skip it.

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.

If you are not using a Twilio SMS-capable phone number, you may need to verify your Sender before it will show as ONLINE. When the API call is made to create a WhatsApp Sender, Meta will send an OTP by either SMS (default) or a Voice call. A WhatsApp Sender will then be in PENDING_VERIFICATION until you update the Sender with the OTP you received.

curl

_10
## Verify Sender
_10
curl -X "POST" "https://messaging.twilio.com/v2/Channels/Senders/XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
_10
-H 'Content-Type: text/plain; charset=utf-8' \
_10
-u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" \
_10
-d '{
_10
"configuration": {
_10
"verification_code": "123456"
_10
}
_10
}'

Output

_45
{
_45
"sid": "XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"sender_id": "whatsapp:+15558675310",
_45
"status": "VERIFYING",
_45
"profile": {
_45
"about": "Hello! This is Twilio's official account.",
_45
"name": "Twilio",
_45
"vertical": "Other",
_45
"websites": [
_45
{
_45
"website": "https://twilio.com",
_45
"label": "Website"
_45
},
_45
{
_45
"website": "https://help.twilio.com",
_45
"label": "Website"
_45
}
_45
],
_45
"address": "101 Spear Street, San Francisco, CA",
_45
"logo_url": "https://www.twilio.com/logo.png",
_45
"emails": [
_45
{
_45
"email": "support@twilio.com",
_45
"label": "Email"
_45
}
_45
],
_45
"description": "We're excited to see what you build!"
_45
},
_45
"webhook": {
_45
"callback_method": "POST",
_45
"callback_url": "https://demo.twilio.com/welcome/sms/reply/",
_45
"fallback_method": "POST",
_45
"fallback_url": "",
_45
"status_callback_url": "",
_45
"status_callback_method": "POST"
_45
},
_45
"url": "https://messaging.twilio.com/v2/Channels/Senders/XEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_45
"configuration": {
_45
"waba_id": "123456789"
_45
},
_45
"properties": {
_45
"messaging_limit": "1K Customers/24hr",
_45
"quality_rating": "HIGH"
_45
}
_45
}

4. Confirm the WhatsApp Sender is registered

4-confirm-the-whatsapp-sender-is-registered page anchor

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.

(information)

Info

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!

What's Next?

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


Rate this page: