Twilio SMS
By twilio
Updated a month ago

Twilio SMS API Documentation

Twilio's Programmable SMS API helps you add robust messaging capabilities to your applications. Please read pricing details carefully.

Learn more about this API
GETFetch an Account Resource
Message Resource
POSTUpdate a Message Resource
GETFetch Multiple Message Resources
GETFetch a Message Resource
DELETEDelete a Message Resource
POSTSend SMS (Create a Message Resource)
Media Resource
GETRead Multiple Media Resources
GETFetch a Media Resource
DELETEDelete a Media Resouce
GETMessaging Pricing by Country
Service Resource
POSTUpdate a Service Resource
GETRead Multiple Service Resources
DELETEDelete a Service Resource
GETFetch a Service Resource
POSTCreate a Service Resource
Phone Numbers
GETAvailable Mobile Phone Numbers
GETFetch a Phone Number
GETAvailable Local Phone Numbers
POSTUpdate a Phone Number
DELETEDelete a Phone Number
GETFetch Multiple Phone Numbers
POSTBuy a Phone Number
POSTSend SMS (Create a Message Resource)

When creating a new message via the API, you must include the To parameter. This value should be either a destination phone number or a Channel address. You also need to pass a Body or MediaUrl containing the message's content.

Header Parameters
Required Parameters
REQUIREDA Twilio phone number in E.164 format, an alphanumeric sender ID, or a Channel Endpoint address that is enabled for the type of message you want to send. Phone numbers or short codes purchased from Twilio also work here. You cannot, for example, spoof messages from a private cell phone number. If you are using messaging_service_sid, this parameter must be empty.
REQUIREDThe text of the message you want to send. Can be up to 1,600 characters in length.
REQUIREDThe destination phone number in E.164 format for SMS/MMS or Channel user address for other 3rd-party channels.
REQUIREDThe SID of the Account that created the Message resources to update. Obtained from the Get AccountSid Endpoint.
Optional Parameters
OPTIONALWhether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: true or false.
OPTIONALWhether to forcefully whitelist a from:to pair. Can be: true or false.
OPTIONALThe SID of the application that should receive message status. We POST a message_sid parameter and a message_status parameter with a value of sent or failed to the application's message_status_callback. If a status_callback parameter is also passed, it will be ignored and the application's message_status_callback parameter will be used.
OPTIONALHow long in seconds the message can remain in our outgoing message queue. After this period elapses, the message fails and we call your status callback. Can be between 1 and the default value of 14,400 seconds. After a message has been accepted by a carrier, however, we cannot guarantee that the message will not be queued after this period. We recommend that this value be at least 5 seconds.
OPTIONALThe URL we should call using the status_callback_method to send status information to your application. If specified, we POST these message status changes to the URL: queued, failed, sent, delivered, or undelivered. Twilio will POST its standard request parameters as well as some additional parameters including MessageSid, MessageStatus, and ErrorCode. If you include this parameter with the messaging_service_sid, we use this URL instead of the Status Callback URL of the Messaging Service. URLs must contain a valid hostname and underscores are not allowed.
OPTIONALThe SID of the Messaging Service you want to associate with the Message. Set this parameter to use the Messaging Service Settings and Copilot Features you have configured and leave the from parameter empty. When only this parameter is set, Twilio will use your enabled Copilot Features to select the from phone number for delivery.
OPTIONALA JSON string that represents an interactive message. An interactive message is a category of messages that includes a list picker, a time picker, and an Apple Pay request.
OPTIONALThe URL of the media to send with the message. The media can be of type gif, png, and jpeg and will be formatted correctly on the recipient's device. Other types of media are also accepted. The media size limit is 5MB. To send more than one image in the message body, provide multiple media_url parameters in the POST request. You can include up to 10 media_url parameters per message. You can send images in an SMS message in only the US and Canada.
OPTIONALWhether to confirm delivery of the message. Set this value to true if you are sending messages that have a trackable user action and you intend to confirm delivery of the message using the Message Feedback API. This parameter is false by default.
OPTIONALThe maximum total price in US dollars that you will pay for the message to be delivered. Can be a decimal value that has up to 4 decimal places. All messages are queued for delivery and the message cost is checked before the message is sent. If the cost exceeds max_price, the message will fail and a status of Failed is sent to the status callback. If MaxPrice is not set, the message cost is not checked.
Code Snippet
Install SDK
Response ExampleSchema

Install SDK for (Node.js)Unirest

OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication