Carriers around the world route text messages to the Twilio cloud.
Twilio receives the text and makes a request to your application.
Your app receives that request and responds with XML back to Twilio.
curl -X POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/SMS/Messages \
--data-urlencode "To=+14155551212" \
--data-urlencode "From=+14158675309" \
--data-urlencode "Body=Hello world" \
-u {AccountSid}:{AuthToken}
The number you want to text. Can be any valid mobile number.
The number the text message will be sent from.
The message you want to send, in any language.
<SMS> a response right from TwiML
<Redirect> control flow to another endpoint in your app and trigger other app logic
| 1 | <Response> |
| 2 | <Sms> |
| 3 | Thanks for texting the Alexander Graham Bell |
| 4 | hotline! An interesting fact about A.G.B. - |
| 5 | he once tried to save a president's life. |
| 6 | </Sms> |
| 7 | <Redirect> |
| 8 | http://myserver.com/handlePostFlightSms |
| 9 | </Redirect> |
| 10 | </Response> |
<Dial> keypad digits, and POST the result to your server, where your application decides what to do
<Dial> supports netstin other TwiML verbs in order to let your app gather digits from the caller while <Say> ‘ing or <Play> ‘ing
| 1 | <Response> |
| 2 | <Gather numDigits="1" action="foo.php"> |
| 3 | <Play>welcome.php<Play> |
| 4 | <Say> |
| 5 | Press "1" to be connected to hear |
| 6 | about Alexander Graham Bell, the |
| 7 | inventor of the telephone. Press "2" |
| 8 | to hear why Thomas Edison was a |
| 9 | dastardly villian. |
| 10 | </Say> |
| 11 | </Gather> |
| 12 | </Response> |
<Play> keypad digits, and POST the result to your server, where your application decides what to do
<Play> supports netstin other TwiML verbs in order to let your app gather digits from the caller while <Say> ‘ing or <Play> ‘ing
| 1 | <Response> |
| 2 | <Gather numDigits="1" action="foo.php"> |
| 3 | <Play>welcome.php<Play> |
| 4 | <Say> |
| 5 | Press "1" to be connected to hear |
| 6 | about Alexander Graham Bell, the |
| 7 | inventor of the telephone. Press "2" |
| 8 | to hear why Thomas Edison was a |
| 9 | dastardly villian. |
| 10 | </Say> |
| 11 | </Gather> |
| 12 | </Response> |
<Say> keypad digits, and POST the result to your server, where your application decides what to do
<Say> supports netstin other TwiML verbs in order to let your app gather digits from the caller while <Say> ‘ing or <Play> ‘ing
| 1 | <Response> |
| 2 | <Gather numDigits="1" action="foo.php"> |
| 3 | <Play>welcome.php<Play> |
| 4 | <Say> |
| 5 | Press "1" to be connected to hear |
| 6 | about Alexander Graham Bell, the |
| 7 | inventor of the telephone. Press "2" |
| 8 | to hear why Thomas Edison was a |
| 9 | dastardly villian. |
| 10 | </Say> |
| 11 | </Gather> |
| 12 | </Response> |
<Conference> keypad digits, and POST the result to your server, where your application decides what to do
<Conference> supports netstin other TwiML verbs in order to let your app gather digits from the caller while <Say> ‘ing or <Play> ‘ing
| 1 | <Response> |
| 2 | <Gather numDigits="1" action="foo.php"> |
| 3 | <Play>welcome.php<Play> |
| 4 | <Say> |
| 5 | Press "1" to be connected to hear |
| 6 | about Alexander Graham Bell, the |
| 7 | inventor of the telephone. Press "2" |
| 8 | to hear why Thomas Edison was a |
| 9 | dastardly villian. |
| 10 | </Say> |
| 11 | </Gather> |
| 12 | </Response> |
Twilio talks to your web app via webhooks - realtime HTTP requests to your web app. When your users call, twilio will answer and synchronously make a webhook request to your app and ask for TwiML instructions about how to proceed with the call. The platform is a well-behaved HTTP client, and even supports cookies.
We designed Twilio for web developers like you who want to build applications that communicate. That's why Twilio supports a rich REST API as well as helper libraries for your favorite programming language. No need to learn some foreign software or hardware stack to make a phone ring. Use the tools you know, and rock the phone grid.
If robustness and reliability are as important to your application as they are to us, you'll be writing tests to ensure your customers always have a great experience. With Twilio's Test Credentials you can test those pesky telecom edge-cases, from buying a phone-number in Portugal to placing a call to Peru. All without spending a penny.
REST API request & parameter details and examples of constructing requests
Step by step guides walk through building basic web apps that control the phone network.
Create an account and build an app that makes phone calls in under five minutes flat. No credit card required.