Messaging API Overview
The Programmable Messaging REST API helps you add robust messaging capabilities to your applications.
With the REST API, you can:
- Send messages
- Fetch, list, update, and delete messages
- Fetch, list, and delete media
- Manage your short codes
- Track message feedback
- Manage your Messaging Services
- Check SMS pricing by country
- Retrieve a list of deactivated US phone numbers
Twilio's APIs are served over HTTPS. To ensure data privacy, unencrypted HTTP is not supported.
The following API Resources use https://api.twilio.com/2010-04-01
as the base URL:
- Message Resource
- MessageFeedback Resource
- Media Resource
API Resources related to Messaging Services use https://messaging.twilio.com/v1
:
- Messaging Services Service Resource
- Messaging Services PhoneNumber Subresource
- Messaging Services ShortCode Subresource
- Messaging Services AlphaSender Subresource
- Messaging Services ChannelSender Subresource
The Deactivations Resource also uses the https://messaging.twilio.com/v1
base URL.
Pricing information for Messaging uses the https://pricing.twilio.com/v1
base URL.
To authenticate requests to the Twilio APIs, Twilio supports HTTP Basic authentication. Use your API key as the username and your API key's secret as the password. You can create an API key either in the Twilio Console or using the API.
Note: Twilio doesn't recommend using your Account SID and Auth Token in production. For local testing, you can use your Account SID as the username and your Auth token as the password. You can find your Account SID and Auth Token in the Twilio Console.
Learn more about Twilio API authentication.
1curl -G https://api.twilio.com/2010-04-01/Accounts \2-u $TWILIO_API_KEY:$TWILIO_API_KEY_SECRET
Info
Twilio monitors messages to prevent content violating the Acceptable Use Policy (AUP). This helps to ensure that Twilio Messaging is seen as a trustworthy, high engagement channel and will not slow down the delivery of messages.
If a message you send has violated the AUP, it will be returned and you will receive an error code which identifies the necessary changes you need to make before sending it again.
To send an outbound message, send a POST
request to the Message Resource.
-
To send media messages, use the
MediaUrl
parameter in the request. -
To schedule an outbound Message to be sent in the future, use the
ScheduleType
andSendAt
parameters in the request. -
To send messages with shortened links, use the
ShortenUrls
parameter in the request.- Note: This feature is available only if you are using Messaging Services.
Looking for information on how to receive and reply to messages? Check out the Receive and Reply to Messages Guide.
Use the Message Resource to fetch, list, and delete Messages associated with your Account.
Redact messages by updating a Message Resource.
Twilio creates a Media Subresource when an incoming or outgoing Message Resource contains media.
You can fetch, list, and delete Media Subresources.
Fetch, list, and update your Account's short codes with the ShortCode Resource.
Track user-reported outcomes of Messages with the MessageFeedback Subresource.
Create, fetch, read, update, and delete Messaging Services with the Service Resource.
Manage your Messaging Services' senders with:
See inbound and outbound SMS message pricing with the Country Pricing Resource.
Fetch a list of all US phone numbers that were deactivated on a given day with the Deactivations Resource.
-
Send and receive messages in your programming language of choice by using one of Twilio's Helper Libraries. For step-by-step instructions on how to send and receive messages with a Helper Library, choose a quickstart below:
-
Check out the Blog for inspiration on how you can build Messaging applications with a variety of languages and tools.
-
For help troubleshooting your Programmable Messaging application, check out the docs on Debugging Common Issues and Debugging Tools.
-
Learn more about Twilio's Global Infrastructure, which allows you to control where your application's Twilio-related data is routed, processed, and stored.