ballerinax/twilio Ballerina library



The Twilio API provides capability to access its platform for communications. These APIs connects the software layer and communications networks around the world to allow users to call and message anyone, globally.

This module supports Twilio Basic API version 2010-04-01.


Before using this connector in your Ballerina application, complete the following:

  1. Create a Twilio account.

  2. Obtain a Twilio phone number.

!!! Tip

If you use a trail account, you may need to verify your recipient phone numbers before having any communication with them.

  1. Obtain a Twilio Account Auth Token.

  2. If you want to use WhatsApp service, Configure your Twilio phone number to use WhatsApp services. For instructions, see Twilio Documentation - Manage and Configure Your WhatsApp-enabled Twilio Numbers.

  3. Configure the connector with obtained tokens.


To use the Twilio connector in your Ballerina application, update the .bal file as follows:

Step 1 - Import connector

Import the Twilio module to your Ballerina program as follows. You can use configurable variables to provide the necessary credentials.

import ballerinax/twilio;

Step 2 - Create a new connector instance

To create a new connector instance, add a configuration as follows:

configurable string accountSId = ?;
configurable string authToken = ?;

twilio:ConnectionConfig twilioConfig = {
    auth: {
        accountSId: accountSId,
        authToken: authToken

twilio:Client twilioClient = new (twilioConfig);

Step 3 - Invoke connector operation

  1. Invoke the connector operation using the client as follows:
public function main() returns error? {
    twilio:Account response = check twilioClient->getAccountDetails();
  1. Use bal run command to compile and run the Ballerina program.

You can find more samples here


import ballerinax/twilio;Copy


Released date: about 1 year ago

Version: 3.2.0

License: Apache-2.0


Platform: any

Ballerina version: 2201.4.1

GraalVM compatible: Yes

Pull count

Total: 0

Current verison: 853

Weekly downloads

Source repository


Communication/Call & SMS



Other versions

See more...