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

Quickstarts for the WhatsApp Business API with Twilio


The WhatsApp Business API with Twilio is the quickest way to integrate messaging on WhatsApp into your web application. Using the same Twilio API mechanics you know, quickly add WhatsApp capabilities to your communications options.

Just looking for how to get started? After the below links we show the general steps you'll need to take to get started with WhatsApp and Twilio.


The WhatsApp Business API with Twilio: Quickstarts

the-whatsapp-business-api-with-twilio-quickstarts page anchor

Our WhatsApp Quickstart shows you a common WhatsApp integration with Twilio Programmable Messaging using six popular web languages as well as cURL. If you're looking for the fastest way to test the ins and outs of working with WhatsApp in Twilio, try the quickstart in your language of choice or cURL:


Sending a Message with the Twilio Programmable Messaging API for WhatsApp

sending-a-message-with-the-twilio-programmable-messaging-api-for-whatsapp page anchor

Once you're set up, here's how you'll send messages for 6 web languages and cURL.

Send a Message with WhatsAppLink to code sample: Send a Message with WhatsApp
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createMessage() {
11
const message = await client.messages.create({
12
body: "Hello there!",
13
from: "whatsapp:+14155238886",
14
to: "whatsapp:+15005550006",
15
});
16
17
console.log(message.body);
18
}
19
20
createMessage();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"api_version": "2010-04-01",
4
"body": "Hello there!",
5
"date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
6
"date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
7
"date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
8
"direction": "outbound-api",
9
"error_code": null,
10
"error_message": null,
11
"from": "whatsapp:+14155238886",
12
"num_media": "0",
13
"num_segments": "1",
14
"price": null,
15
"price_unit": null,
16
"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"status": "queued",
19
"subresource_uris": {
20
"media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
21
},
22
"tags": {
23
"campaign_name": "Spring Sale 2022",
24
"message_type": "cart_abandoned"
25
},
26
"to": "whatsapp:+15005550006",
27
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
28
}

What's Next with WhatsApp?

whats-next-with-whatsapp page anchor

The quickstart will take you down the quickest path to a WhatsApp integration. For more advanced integrations and details about working with WhatsApp, Twilio, see our full API Reference and Overview.


Rate this page: