Send an SMS

In this guide, we’ll see how to use Plivo APIs to send SMS messages from your web application. Let’s have a look at some prerequisites before we dive into the code.

  • Plivo Auth Id and Auth Token: You will find your Plivo Auth Id and Auth Token on the home screen of your Plivo Console. Click here to sign-up for a Plivo account if you haven’t already!
  • Plivo Server-side SDK: The code in this tutorial uses Plivo’s Python Server-side SDK. To get started with the SDK in the language of your choice, visit the Server-side SDKs page.
  • Plivo Phone Number: You must have a SMS-enabled Plivo phone number to send messages to the US and Canada. You can purchase numbers from the Numbers section of your Plivo Console. It is also possible to purchase numbers using the Numbers API.

Sending Messages Using Plivo REST API

This tutorial will show you how to send an outbound Short Message Service (SMS) (i.e., text message) using Plivo’s REST API. This can be used in any web or mobile application that requires communication with end users via SMS text messages including delivery notifications, system alerts, two-factor authentication and even rideshare alerts.

Plivo’s Message API supports Unicode UTF-8 encoded texts, which means that you can send messages in any language. The Message API also automatically splits long messages at 160 characters and concatenates them into a single SMS on the receiver’s end. Delivery reports are also automatically supported in networks where they are provided by the operator.

To send an SMS, we’ll need to make an HTTP POST request to the Message API.


Getting Started

  1. Sign up for a Plivo trial account.
  2. Check out our server-side SDKs page and install the right helper based on the programming language you want to use.
  3. Buy a Plivo phone number (optional).
    Note: A phone number is required only for sending SMS to US and Canadian phone numbers. However, country-specific carrier conditions may still apply. You can buy a US or Canadian phone number through the Buy Numbers tab on your Plivo account UI.
  4. Use a web hosting service to host your web application. There are many inexpensive cloud hosting providers that you can use for just a few dollars a month. Follow the instructions of your hosting provider to host your web application.
    Note: If you are using a Plivo Trial account for this example, you can only send sms to phone numbers that have been verified with Plivo. Phone numbers can be verified at the Sandbox Numbers page.


  1. Copy the relevant code below into a text file and save it.
  2. Replace Your AUTH_ID and Your AUTH_TOKEN with the AUTH ID and AUTH TOKEN found on your Plivo Console.
  3. Add your 'src' (source) phone number. This will show up as your Sender ID.
    • In order to send text messages to phones in the US or Canada, you will need to purchase a SMS-enabled US or Canadian phone number from Plivo and use it as the 'src' number. You can buy a Plivo number from the Buy Numbers tab on your Plivo Console and filter the Phone Numbers by selecting SMS in the features option to buy SMS enabled numbers.
    • Be sure that the phone number is in E.164 format (e.g., +14153336666).
    • For other countries, this can be either a Alpha Sender ID or Numeric Sender ID based on the Sender ID support for the respective countries, to know more you can refer to the Sender ID Usage guide
  4. Add your 'dst' (destination) phone numbers. This is the phone number you will be sending SMS text messages to. Be sure that the phone number is in E.164 format (e.g., +15671234567).
    Note: If you are using a trial account, your destination number needs to be verified with Plivo. Phone numbers can be verified at the Sandbox Numbers page.
  5. Edit the 'text' field with your SMS text message.
    Note: Text messages that are longer than 160 characters are concatenated and billed separately as individual text messages.
  6. Make the 'HTTP POST' request to Plivo. If successful, Plivo will queue your SMS and deliver it to your recipients at a base rate of 1 message per second.
    Advanced Hack: Check out our full Message API docs to see all the parameters and functionalities you can use.