Skip to contentSkip to navigationSkip to topbar
On this page

Messaging API Overview


The Programmable Messaging REST API helps you add robust messaging capabilities to your applications.

Use the REST API to complete the following activities:


Base URLs

base-urls page anchor

To ensure data privacy, Twilio serves its APIs over HTTPS.

Messaging-related APIs use three base URLs:

Twilio API base URL

twilio-api-base-url page anchor

The following API resources that process SMS messages point to the Base URL of https://api.twilio.com/2010-04-01.

The following API Resources that manage Messaging Services point to https://messaging.twilio.com/v1.

The following API Resources that report on deactivated phone numbers and process toll-free verification requests also point to https://messaging.twilio.com/v1.

The API resource that reports on per-country SMS pricing points to the https://pricing.twilio.com/v1 base URL.


To authenticate requests to the Twilio APIs, Twilio supports HTTP Basic authentication(link takes you to an external page). Use your API key as the username and your API key secret as the password. You can create an API key either in the Twilio Console or using the API.

Note: Twilio recommends using API keys for authentication in production apps. 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(link takes you to an external page).

Learn more about Twilio API authentication.

1
curl -G https://api.twilio.com/2010-04-01/Accounts \
2
-u $TWILIO_API_KEY:$TWILIO_API_KEY_SECRET

Use the Programmable Messaging API

use-the-programmable-messaging-api page anchor
(information)

Info

Twilio monitors messages to prevent content violating the Acceptable Use Policy(link takes you to an external page) (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.

Looking for information on how to receive and reply to messages? Check out the Receive and Reply to Messages Guide.

Fetch, list, update, and delete messages

fetch-list-update-and-delete-messages page anchor

Use the Message Resource to fetch, list, and delete Messages associated with your Account.

Redact messages by updating a Message Resource.

Fetch, list, and delete media

fetch-list-and-delete-media page anchor

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.

Manage your Messaging Services

manage-your-messaging-services page anchor

Create, fetch, read, update, and delete Messaging Services with the Service Resource.

Manage your Messaging Services' senders with:

Check SMS pricing by country

check-sms-pricing-by-country page anchor

Check inbound and outbound SMS message pricing with the Country Pricing Resource.

Retrieve a list of deactivated US phone numbers

retrieve-a-list-of-deactivated-us-phone-numbers page anchor

Fetch a list of all US phone numbers that were deactivated on a given day with the Deactivations Resource.

Verify if your toll-free number complies with regulations

verify-if-your-toll-free-number-complies-with-regulations page anchor

Show your toll-free number complies with US and Canadian SMS regulations. Submit, fix, and remove toll-free verification (TFV) requests with the Verifications resource