Messaging

Programmable Messaging API

Integrate a single API to reliably send and receive SMS, MMS, and WhatsApp messages.

Build global messaging into your
app with a few lines of code

prog-message-api-chart.png

Send notifications, alerts, and marketing messages on multiple channels with one API that has software for managing phone numbers, deliverability, compliance, and replies.

Capabilities

Dozens of features. No additional
coding required.

  • Node.js
  • Node.js
  • C#
  • PHP
  • Ruby
  • C#
  • PHP
  • Python
  • Ruby
  • Java
  • Python
  • Java
  • curl
  • curl
// Download the Node helper library from twilio.com/docs/node/install// These vars are your accountSid and authToken from twilio.com/user/accountconstaccountSid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';constauthToken='your_auth_token';constclient=require('twilio')(accountSid,authToken);client.messages.create({body:'All in the game, yo',to:'+14108675310',from:'+15005550006',},(err,sms)=>{process.stdout.write(sms.sid);});
// Download the Node helper library from twilio.com/docs/node/install// These consts are your accountSid and authToken from https://www.twilio.com/consoleconstaccountSid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';constauthToken='your_auth_token';constclient=require('twilio')(accountSid,authToken);client.messages.create({body:'All in the game, yo',to:'+14108675310',from:'+15005550006',}).then(sms=>process.stdout.write(sms.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/installusingSystem;usingTwilio;classExample{staticvoidMain(string[]args){// Find your Account Sid and Auth Token at twilio.com/user/accountstringAccountSid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";stringAuthToken="your_auth_token";vartwilio=newTwilioRestClient(AccountSid,AuthToken);varmessage=twilio.SendMessage("+15005550006","+14108675310","All in the game, yo");Console.WriteLine(message.Sid);}}
<?php// Get the PHP helper library from https://twilio.com/docs/libraries/phprequire_once'/path/to/twilio-php/Services/Twilio.php';// Loads the library// Your Account Sid and Auth Token from twilio.com/user/account$accountSid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";$authToken="your_auth_token";$client=newServices_Twilio($accountSid,$authToken);$message=$client->account->messages->create(array('To'=>'+15005550006','From'=>'+14108675310','Body'=>'All in the game, yo'));echo$message->sid;
# Get twilio-ruby from twilio.com/docs/ruby/installrequire'twilio-ruby'# Get your Account Sid and Auth Token from twilio.com/user/accountaccount_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token='your_auth_token'@client=Twilio::REST::Client.new(account_sid,auth_token)message=@client.account.messages.create(body:'All in the game, yo',to:'+14108675310',from:'+15005550006')putsmessage.sid
// Download the twilio-csharp library from twilio.com/docs/libraries/csharpusingSystem;usingTwilio;usingTwilio.Rest.Api.V2010.Account;usingTwilio.Types;classExample{staticvoidMain(string[]args){// Find your Account Sid and Auth Token at twilio.com/consoleconststringaccountSid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";conststringauthToken="your_auth_token";TwilioClient.Init(accountSid,authToken);varto=newPhoneNumber("+15005550006");varmessage=MessageResource.Create(to,from:newPhoneNumber("+14108675310"),body:"All in the game, yo");Console.WriteLine(message.Sid);}}
<?php// Get the PHP helper library from https://twilio.com/docs/libraries/phprequire_once'/path/to/vendor/autoload.php';// Loads the libraryuseTwilio\Rest\Client;// Your Account Sid and Auth Token from twilio.com/user/account$sid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";$token="your_auth_token";$client=newClient($sid,$token);$sms=$client->messages->create("+14108675310",array("from"=>"+15005550006","body"=>"All in the game, yo"));echo$sms->sid;
# Download the Python helper library from twilio.com/docs/python/installfromtwilio.restimportTwilioRestClient# Your Account Sid and Auth Token from twilio.com/user/accountaccount_sid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"auth_token="your_auth_token"client=TwilioRestClient(account_sid,auth_token)message=client.messages.create(body="All in the game, yo",to="+14108675310",from_="+15005550006")print(message.sid)
# Get twilio-ruby from twilio.com/docs/ruby/installrequire'twilio-ruby'# Get your Account SID and Auth Token from twilio.com/consoleaccount_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token='your_auth_token'@client=Twilio::REST::Client.new(account_sid,auth_token)message=@client.messages.create(body:'All in the game, yo',to:'+14108675310',from:'+15005550006')putsmessage.sid
// Install the Java helper library from twilio.com/docs/java/installimportcom.twilio.sdk.TwilioRestClient;importcom.twilio.sdk.TwilioRestException;importcom.twilio.sdk.resource.factory.MessageFactory;importcom.twilio.sdk.resource.instance.Message;importorg.apache.http.NameValuePair;importorg.apache.http.message.BasicNameValuePair;importjava.util.ArrayList;importjava.util.List;publicclassExample{// Find your Account Sid and Token at twilio.com/user/accountpublicstaticfinalStringACCOUNT_SID="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";publicstaticfinalStringAUTH_TOKEN="your_auth_token";publicstaticvoidmain(String[]args)throwsTwilioRestException{TwilioRestClientclient=newTwilioRestClient(ACCOUNT_SID,AUTH_TOKEN);// Build a filter for searchList<NameValuePair>params=newArrayList<>();params.add(newBasicNameValuePair("Body","All in the game, yo"));params.add(newBasicNameValuePair("To","+14108675310"));params.add(newBasicNameValuePair("From","+15005550006"));MessageFactorymessageFactory=client.getAccount().getMessageFactory();Messagemessage=messageFactory.create(params);System.out.println(message.getSid());}}
# Download the Python helper library from twilio.com/docs/python/installfromtwilio.restimportClient# Your Account Sid and Auth Token from twilio.com/user/accountaccount_sid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"auth_token="your_auth_token"client=Client(account_sid,auth_token)message=client.messages.create(body="All in the game, yo",to="+5571981265131",from_="")print(message.sid)
// Install the Java helper library from twilio.com/docs/java/installimportcom.twilio.Twilio;importcom.twilio.rest.api.v2010.account.Message;importcom.twilio.type.PhoneNumber;publicclassExample{// Find your Account Sid and Token at twilio.com/user/accountpublicstaticfinalStringACCOUNT_SID="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";publicstaticfinalStringAUTH_TOKEN="your_auth_token";publicstaticvoidmain(String[]args){Twilio.init(ACCOUNT_SID,AUTH_TOKEN);Messagesms=Message.creator(newPhoneNumber("+14108675310"),newPhoneNumber("15005550006"),"All in the game, yo").create();System.out.println(sms.getSid());}}
curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages \    -d "Body=All%20in%20the%20game%2C%20yo"\    -d "To=%2B14108675310"\    -d "From=%2B15005550006"\    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \    -d "Body=All%20in%20the%20game%2C%20yo"\    -d "To=%2B14108675310"\    -d "From=%2B15005550006"\    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'

High-volume messaging with compliance built in

  • High-volume global senders: Select Short Codes, Alphanumeric Sender IDs, and High-Throughput Toll-Free numbers
  • Advanced Opt-Out: Customize opt-ins and opt-outs for local regulations and languages in the Console
  • Message redaction: Redact the last 4 digits of phone numbers and the message body to protect sensitive customer data
  • Alphanumeric Sender ID alerts: Get automatic alerts when sending to countries that require pre-registered Alphanumeric Sender IDs
  • Node.js
  • C#
  • PHP
  • Ruby
  • Python
  • Java
  • curl
// Download the Node helper library from twilio.com/docs/libraries/node// These consts are your accountSid and authToken from https://www.twilio.com/consoleconstaccountSid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';constauthToken='your_auth_token';constclient=require('twilio')(accountSid,authToken);constopts={friendlyName:'My First Service',statusCallback:'http://requestb.in/1234abcd',};client.messaging.services.create(opts).then(response=>{console.log(response);}).catch(error=>{console.log(error);});
// Download the twilio-csharp library from twilio.com/docs/libraries/csharpusingSystem;usingTwilio;usingTwilio.Rest.Messaging.V1;classExample{staticvoidMain(string[]args){// Find your Account SID and Auth Token at twilio.com/consoleconststringaccountSid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";conststringauthToken="your_auth_token";conststringserviceFriendlyName="My First Service";TwilioClient.Init(accountSid,authToken);varservice=ServiceResource.Create(serviceFriendlyName);Console.WriteLine(service.Sid);}}
<?php// Get the PHP helper library from https://twilio.com/docs/libraries/phprequire_once'/path/to/vendor/autoload.php';// Loads the libraryuseTwilio\Rest\Client;$account_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';$auth_token='your_auth_token';$twilio=newClient($account_sid,$auth_token);$service=$twilio->messaging->v1->services->create("My First Service",array('statusCallback'=>"http://requestb.in/1234abcd"));
# Get twilio-ruby from twilio.com/docs/libraries/rubyrequire'twilio-ruby'# Get your Account SID and Auth Token from twilio.com/consoleaccount_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token='your_auth_token'# Initialize Twilio Client@client=Twilio::REST::Client.new(account_sid,auth_token)@service=@client.messaging.v1.services.create(friendly_name:'My First Service',status_callback:'http://requestb.in/1234abcd')puts@service.sid
# Download the Python helper library from twilio.com/docs/python/installfromtwilio.restimportClient# Your Account Sid and Auth Token from twilio.com/consoleaccount_sid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"auth_token="your_auth_token"client=Client(account_sid,auth_token)service=client.messaging \
.services \
.create(friendly_name="My First Service")print(service.sid)
importcom.twilio.Twilio;importcom.twilio.rest.messaging.v1.Service;publicclassExample{// Find your Account Sid and Token at twilio.com/consolepublicstaticfinalStringACCOUNT_SID="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";publicstaticfinalStringAUTH_TOKEN="your_auth_token";publicstaticvoidmain(String[]args){// Initialize the clientTwilio.init(ACCOUNT_SID,AUTH_TOKEN);Serviceservice=Service.creator("My First Service").create();}}
curl 'https://messaging.twilio.com/v1/Services' -X POST \    --data-urlencode 'FriendlyName=My First Service'\    --data-urlencode 'StatusCallback=http://requestb.in/1234abcd'\    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token

A local experience—even as you scale globally

  • Hyper-local senders: Choose from over 65,000 prefixes that include local, national, and toll-free numbers
  • Sticky Sender: Send messages from the same sender ID or phone number for a consistent experience
  • Area Code and Country Geomatch: Auto-select a phone number based on consumer area code (US-only) or country
  • Node.js
  • C#
  • PHP
  • Ruby
  • Python
  • Java
  • curl
// Download the helper library from https://www.twilio.com/docs/node/install// Your Account Sid and Auth Token from twilio.com/console// DANGER! This is insecure. See http://twil.io/secureconstaccountSid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';constauthToken='your_auth_token';constclient=require('twilio')(accountSid,authToken);client.messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').media('MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch().then(media=>console.log(media.contentType));
// Install the C# / .NET helper library from twilio.com/docs/csharp/installusingSystem;usingTwilio;usingTwilio.Rest.Api.V2010.Account.Message;classProgram{staticvoidMain(string[]args){// Find your Account Sid and Token at twilio.com/console// DANGER! This is insecure. See http://twil.io/secureconststringaccountSid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";conststringauthToken="your_auth_token";TwilioClient.Init(accountSid,authToken);varmedia=MediaResource.Fetch(pathMessageSid:"MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",pathSid:"MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");Console.WriteLine(media.ContentType);}}
<?php// Update the path below to your autoload.php,// see https://getcomposer.org/doc/01-basic-usage.mdrequire_once'/path/to/vendor/autoload.php';useTwilio\Rest\Client;// Find your Account Sid and Auth Token at twilio.com/console// DANGER! This is insecure. See http://twil.io/secure$sid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";$token="your_auth_token";$twilio=newClient($sid,$token);$media=$twilio->messages("MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")->media("MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")->fetch();print($media->contentType);
# Download the helper library from https://www.twilio.com/docs/ruby/installrequire'rubygems'require'twilio-ruby'# Your Account Sid and Auth Token from twilio.com/console# DANGER! This is insecure. See http://twil.io/secureaccount_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token='your_auth_token'@client=Twilio::REST::Client.new(account_sid,auth_token)media=@client.messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').media('MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetchputsmedia.content_type
# Download the helper library from https://www.twilio.com/docs/python/installfromtwilio.restimportClient# Your Account Sid and Auth Token from twilio.com/console# DANGER! This is insecure. See http://twil.io/secureaccount_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token='your_auth_token'client=Client(account_sid,auth_token)media=client.messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
.media('MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
.fetch()print(media.content_type)
// Install the Java helper library from twilio.com/docs/java/installimportcom.twilio.Twilio;importcom.twilio.rest.api.v2010.account.message.Media;publicclassExample{// Find your Account Sid and Token at twilio.com/console// DANGER! This is insecure. See http://twil.io/securepublicstaticfinalStringACCOUNT_SID="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";publicstaticfinalStringAUTH_TOKEN="your_auth_token";publicstaticvoidmain(String[]args){Twilio.init(ACCOUNT_SID,AUTH_TOKEN);Mediamedia=Media.fetcher("MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch();System.out.println(media.getContentType());}}
curl -X GET 'https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Media/MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json'\-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token

Message content delivered with accuracy

  • Intelligent Concatenation: Automatically segment long messages with a header that carriers use for reassembly
  • Smart Encoding: Send SMS messages in the most compact encoding possible (fall back to UCS-2 for non GSM-7 characters)
  • MMS Converter: Automatically convert MMS to an SMS with linked media for carriers that don’t support MMS
  • Node.js
  • C#
  • PHP
  • Ruby
  • Python
  • Java
  • curl
  • twilio-cli
// Download the helper library from https://www.twilio.com/docs/node/install// Your Account Sid and Auth Token from twilio.com/console// DANGER! This is insecure. See http://twil.io/secureconstaccountSid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';constauthToken='your_auth_token';constclient=require('twilio')(accountSid,authToken);client.messages.create({from:'+15017122661',body:'body',to:'+15558675310'}).then(message=>console.log(message.sid));
// Install the C# / .NET helper library from twilio.com/docs/csharp/installusingSystem;usingTwilio;usingTwilio.Rest.Api.V2010.Account;classProgram{staticvoidMain(string[]args){// Find your Account Sid and Token at twilio.com/console// DANGER! This is insecure. See http://twil.io/secureconststringaccountSid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";conststringauthToken="your_auth_token";TwilioClient.Init(accountSid,authToken);varmessage=MessageResource.Create(from:newTwilio.Types.PhoneNumber("+15017122661"),body:"body",to:newTwilio.Types.PhoneNumber("+15558675310"));Console.WriteLine(message.Sid);}}
<?php// Update the path below to your autoload.php,// see https://getcomposer.org/doc/01-basic-usage.mdrequire_once'/path/to/vendor/autoload.php';useTwilio\Rest\Client;// Find your Account Sid and Auth Token at twilio.com/console// DANGER! This is insecure. See http://twil.io/secure$sid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";$token="your_auth_token";$twilio=newClient($sid,$token);$message=$twilio->messages->create("+15558675310",// to["from"=>"+15017122661","body"=>"body"]);print($message->sid);
# Download the helper library from https://www.twilio.com/docs/ruby/installrequire'rubygems'require'twilio-ruby'# Your Account Sid and Auth Token from twilio.com/console# DANGER! This is insecure. See http://twil.io/secureaccount_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token='your_auth_token'@client=Twilio::REST::Client.new(account_sid,auth_token)message=@client.messages.create(from:'+15017122661',body:'body',to:'+15558675310')putsmessage.sid
# Download the helper library from https://www.twilio.com/docs/python/installfromtwilio.restimportClient# Your Account Sid and Auth Token from twilio.com/console# DANGER! This is insecure. See http://twil.io/secureaccount_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token='your_auth_token'client=Client(account_sid,auth_token)message=client.messages.create(from_='+15017122661',body='body',to='+15558675310')print(message.sid)
// Install the Java helper library from twilio.com/docs/java/installimportcom.twilio.Twilio;importcom.twilio.rest.api.v2010.account.Message;importcom.twilio.type.PhoneNumber;publicclassExample{// Find your Account Sid and Token at twilio.com/console// DANGER! This is insecure. See http://twil.io/securepublicstaticfinalStringACCOUNT_SID="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";publicstaticfinalStringAUTH_TOKEN="your_auth_token";publicstaticvoidmain(String[]args){Twilio.init(ACCOUNT_SID,AUTH_TOKEN);Messagemessage=Message.creator(newcom.twilio.type.PhoneNumber("+15558675310"),newcom.twilio.type.PhoneNumber("+15017122661"),"body").create();System.out.println(message.getSid());}}
curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \--data-urlencode "From=+15017122661"\--data-urlencode "Body=body"\--data-urlencode "To=+15558675310"\-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
#Installthetwilio-clifromhttps://twil.io/clitwilioapi:core:messages:create\--from +15017122661 \--body body \--to +15558675310

Programmatic control over queued and incoming messages

  • SMS validity period: Dictate how long to attempt delivery of queued messages before failing with an error
  • Inbound webhooks: Send either an HTTP POST or an HTTP GET request to a specified URL for incoming messages
  • Conversations API: Configure inbound messages to create a Conversation Resource, with the Conversations API, for archivable message threads
  • Node.js
  • Node.js
  • C#
  • PHP
  • Ruby
  • C#
  • PHP
  • Python
  • Ruby
  • Java
  • Python
  • Java
  • curl
// Twilio CredentialsconstaccountSid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';constauthToken='your_auth_token';// require the Twilio module and create a REST clientconstclient=require('twilio')(accountSid,authToken);client.messages.create({to:'+15558675310',from:'+15017122661',body:'McAvoy or Stewart? These timelines can get so confusing.',statusCallback:'http://requestb.in/1234abcd',},(err,message)=>{console.log(message.sid);});
// Twilio CredentialsconstaccountSid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';constauthToken='your_auth_token';// require the Twilio module and create a REST clientconstclient=require('twilio')(accountSid,authToken);client.messages.create({to:'+15558675310',from:'+15017122661',body:'McAvoy or Stewart? These timelines can get so confusing.',statusCallback:'http://requestb.in/1234abcd',}).then(message=>console.log(message.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/installusingSystem;usingTwilio;classExample{staticvoidMain(string[]args){// Find your Account Sid and Auth Token at twilio.com/user/accountstringAccountSid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";stringAuthToken="your_auth_token";vartwilio=newTwilioRestClient(AccountSid,AuthToken);varmessage=twilio.SendMessage("+15017122661","+15558675310","McAvoy or Stewart? These timelines can get so confusing.","http://requestb.in/1234abcd");Console.WriteLine(message.Sid);}}
<?php// this line loads the library require('/path/to/twilio-php/Services/Twilio.php');$account_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';$auth_token='your_auth_token';$client=newServices_Twilio($account_sid,$auth_token);$client->account->messages->create(array('To'=>"+15558675310",'From'=>"+15017122661",'Body'=>"McAvoy or Stewart? These timelines can get so confusing.",'StatusCallback'=>"http://requestb.in/1234abcd"));
require'rubygems'# not necessary with ruby 1.9 but included for completenessrequire'twilio-ruby'# put your own credentials hereaccount_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token='your_auth_token'# set up a client to talk to the Twilio REST APIclient=Twilio::REST::Client.newaccount_sid,auth_tokenbody='McAvoy or Stewart? These timelines can get so confusing.'client.account.messages.create(from:'+15017122661',to:'+15558675310',body:body,status_callback:'http://requestb.in/1234abcd')
// Download the twilio-csharp library from twilio.com/docs/libraries/csharpusingSystem;usingTwilio;usingTwilio.Rest.Api.V2010.Account;usingTwilio.Types;classExample{staticvoidMain(string[]args){// Find your Account Sid and Auth Token at twilio.com/consoleconststringaccountSid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";conststringauthToken="your_auth_token";TwilioClient.Init(accountSid,authToken);varto=newPhoneNumber("+15017122661");varmessage=MessageResource.Create(to,from:newPhoneNumber("+15558675310"),body:"McAvoy or Stewart? These timelines can get so confusing.",statusCallback:newUri("http://requestb.in/1234abcd"));Console.WriteLine(message.Sid);}}
<?php// Get the PHP helper library from https://twilio.com/docs/libraries/phprequire_once'/path/to/vendor/autoload.php';// Loads the libraryuseTwilio\Rest\Client;// Your Account Sid and Auth Token from twilio.com/user/account$sid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";$token="your_auth_token";$client=newClient($sid,$token);$client->messages->create('+15558675310',array('from'=>'+15017122661','body'=>"McAvoy or Stewart? These timelines can get so confusing.",'statusCallback'=>"http://requestb.in/1234abcd"));
fromtwilio.restimportTwilioRestClient# put your own credentials hereACCOUNT_SID="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"AUTH_TOKEN="your_auth_token"client=TwilioRestClient(ACCOUNT_SID,AUTH_TOKEN)client.messages.create(to="+15558675310",from_="+15017122661",body="McAvoy or Stewart? These timelines can get so confusing.",status_callback="http://requestb.in/1234abcd")
require'rubygems'# not necessary with ruby 1.9 but included for completenessrequire'twilio-ruby'# put your own credentials hereaccount_sid='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token='your_auth_token'# set up a client to talk to the Twilio REST API@client=Twilio::REST::Client.new(account_sid,auth_token)@client.messages.create(from:'+15017122661',to:'+15558675310',body:'McAvoy or Stewart? These timelines can get so confusing.',status_callback:'http://requestb.in/1234abcd')
// You may want to be more specific in your importsimportjava.util.*;importcom.twilio.sdk.*;importcom.twilio.sdk.resource.factory.*;importcom.twilio.sdk.resource.instance.*;importcom.twilio.sdk.resource.list.*;importjava.util.ArrayList;importjava.util.List;importorg.apache.http.NameValuePair;importorg.apache.http.message.BasicNameValuePair;publicclassTwilioTest{// Find your Account Sid and Token at twilio.com/user/accountpublicstaticfinalStringACCOUNT_SID="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";publicstaticfinalStringAUTH_TOKEN="your_auth_token";publicstaticvoidmain(String[]args)throwsTwilioRestException{TwilioRestClientclient=newTwilioRestClient(ACCOUNT_SID,AUTH_TOKEN);// Build the parametersList<NameValuePair>params=newArrayList<NameValuePair>();params.add(newBasicNameValuePair("To","+15558675310"));params.add(newBasicNameValuePair("From","+15017122661"));params.add(newBasicNameValuePair("Body","McAvoy or Stewart? These timelines can get so confusing."));params.add(newBasicNameValuePair("StatusCallback","http://requestb.in/1234abcd"));MessageFactorymessageFactory=client.getAccount().getMessageFactory();Messagemessage=messageFactory.create(params);System.out.println(message.getSid());}}
fromtwilio.restimportClient# put your own credentials hereaccount_sid="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"auth_token="your_auth_token"client=Client(account_sid,auth_token)client.messages.create(to="+15558675310",from_="+15017122661",body="McAvoy or Stewart? These timelines can get so confusing.",status_callback="http://requestb.in/1234abcd")
// Install the Java helper library from twilio.com/docs/java/installimportcom.twilio.Twilio;importcom.twilio.rest.api.v2010.account.Message;importcom.twilio.type.PhoneNumber;publicclassExample{// Find your Account Sid and Token at twilio.com/user/accountpublicstaticfinalStringACCOUNT_SID="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";publicstaticfinalStringAUTH_TOKEN="your_auth_token";publicstaticvoidmain(String[]args){Twilio.init(ACCOUNT_SID,AUTH_TOKEN);Messagemessage=Message.creator(newPhoneNumber("+15558675310"),newPhoneNumber("+15017122661"),"McAvoy or Stewart? These timelines can get so confusing.").setStatusCallback("http://requestb.in/1234abcd").create();System.out.println(message.getSid());}}
curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json'\--data-urlencode 'To=+15558675310'\--data-urlencode 'From=+15017122661'\--data-urlencode 'Body=McAvoy or Stewart? These timelines can get so confusing.'\--data-urlencode 'StatusCallback=http://requestb.in/1234abcd'\-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token

Full transparency into message deliverability and engagement

  • Status Callbacks: See a message’s delivery status with the REST API using its unique identifier (SID) or provide a StatusCallback URL
  • Messaging Insights: Real-time analytics for monitoring and troubleshooting message delivery and engagement

Get Started

Start sending messages in the
language you know

Resources

SMS quickstart

Quickly learn how to send messages using your language of choice.

Get started with SMS

WhatsApp Business API for Twilio quickstart

Easily add WhatsApp capabilities using the same Twilio API mechanics you know.

Get started with WhatsApp

Track delivery status of messages

Learn how to track the delivery status of messages you send with Programmable Messaging in your web application.

See tutorial

Receive and reply to messages

Learn how to use Programmable Messaging to respond to incoming SMS messages in your web application.

See tutorial

API reference

Programmable Messaging API

Add robust messaging capabilities to your applications with our Programmable Messaging API.

See docs

WhatsApp Business API

Use one REST API to send notifications with the world’s most popular messaging app, WhatsApp.

See docs

Pricing

Flexible pricing options

Choose a simple pricing structure that’s right for you: Pay as you go, volume discounts, or committed-use discounts based on your monthly volume.

Why Twilio

Build on Twilio. Code with Confidence.

Best-in-class channel APIs to keep the conversation going across all channels

Global reach and unrivaled scale that supports over
8 million developers

Powerful serverless tools and fully-programmable solutions that deploy in minutes

Enterprise-grade security and reliability, powering over 190,000 respected brands