Learn how to send SMS in Python with Twilio, Vonage, and Plivo, plus Courier's multi-channel API. Compare setup, code samples, pros, and cons.
Updated Jul 6, 2026
With the advancement of technology and the internet, sending a message to another person has become easier. However, SMS marketing still has the highest reach and a response rate compared to the average email response rate. Therefore, SMS is a powerful tool for customer engagement that allows businesses to send timely, concise, and personalized messages.
This post discusses three different options to send text messages (SMS) with Python. I'll share each method's pros and cons, so you can select the best method that fits your needs.
Twilio APIs provide seamless communication with the users via voice, SMS, video, or chat. Many companies use it to send SMS notifications such as password resets or alerts.
To use Twilio in your project, you'll need a Twilio Account. If you don't have one already, you can sign up for your free trial account here.
To send SMS, you'll also require an SMS-enabled Twilio phone number which you can search and buy from the Twilio console - Buy a Number page.
Install dependencies
You can install the Twilio library from the console if you don't already have the Python helper library installed, using pip:
pip install twilio
Initialize the dependencies
Create a file named send-sms.py and add the code below. You can find the Account SID and Auth Token in your Twilio console and set the environment variables.
import osaccount_sid = os.environ['TWILIO_ACCOUNT_SID']auth_token = os.environ['TWILIO_AUTH_TOKEN']
Send an SMS
from twilio.rest import Clientclient = Client(account_sid, auth_token)message = client.messages \.create(body='Hello there from Twilio SMS API',from_ = FROM_NUMBER,to = TO_NUMBER)print(message.sid)
Here, you can replace the FROM_NUMBER from the number you purchased earlier and the TO_NUMBER from the message recipient's number.
Apart from Python, Twilio provides SDKs on C#, Node.js, PHP, Java, Go, and Ruby.
Vonage provides a simple yet powerful way to deliver voice and SMS messages. They offer a set of APIs for sending SMS notifications, sending SMS messages in bulk, and many more. It is perfect for sales personnel, general brand owners, or comms agents who need to distribute information across multiple channels with their users.
To complete this tutorial, you'll need a Vonage Account. If you don't have one already, you can create a new account and start developing with free credit.
Install dependencies
To install the Vonage Python SDK using pip:
pip install vonage
Or to upgrade the installed Vonage Python SDK using pip:
pip install vonage --upgrade
Instead, you can clone the repository via the command line:
git clone git@github.com:Vonage/vonage-python-sdk.git
Initialize the dependencies
Now, create a file named send-sms.py and include the following code. You can find the API key and API Secret from the Vonage API dashboard.
import osVONAGE_API_KEY = os.environ['VONAGE_API_KEY']VONAGE_API_SECRET = os.environ['VONAGE_API_SECRET']#Create a client instance and then pass the client to the Sms instanceclient = vonage.Client(key=VONAGE_API_KEY, secret=VONAGE_API_SECRET)sms = vonage.Sms(client)
Instead of creating a client instance, you can directly pass the key and secret to the constructor.
Send an SMS
Sending an SMS using the Vonage API is very easy, and you can use the following code to do that.
response = sms.send_message({"from": VONAGE_BRAND_NAME,"to": TO_NUMBER,"text": "Hello there from Vonage SMS API",})if response["messages"][0]["status"] == "0":print("Message Details: ", response)print("Message sent successfully.")else:print(f"Message failed with error: {response['messages'][0]['error-text']}")
Apart from Python, Vonage SDKs are available in C#, Node.js, PHP, Ruby, Java, and .NET too.
Plivo is a cloud-based API platform that enables real-time communications to applications. It provides SDKs and RESTful API to integrate SMS, voice, video, push notifications, and many other forms of communication into the mobile, web, and IoT applications.
You need a Plivo account and an SMS-enabled phone number to get started.
Install dependencies
You can install the Plivo SDK using pip:
pip install plivo
Initialize the dependencies
Create a file named send-sms.py and add the following code to it. The Auth ID and Auth Token can be found in the Account section at the top of the Plivo console.
import osauth_id = os.environ['PLIVO_ACCOUNT_ID']auth_token = os.environ['PLIVO_AUTH_TOKEN']
Send an SMS
import plivoclient = plivo.RestClient('<auth_id>','<auth_token>')message_created = client.messages.create(src = FROM_NUMBER,dst = TO_NUMBER,text='Hello there from Plivo SMS API!')
Note that if you're using a Plivo trial account, you can only send messages using the numbers that have been verified with Plivo.
Plivo SDKs are available in .NET, Go, Java, Python, PHP, Node.js, and Ruby.
Apart from the methods mentioned above, you can use a multi-channel notification service like Courier to send SMS via a mobile notification channel that covers push, in-app, email, and more from a uniform API.
With the modern application requirements, using a multi-channel notification service like Courier can streamline your notification flow by creating all the relevant channels with them a single API.
For this demonstration, I will be using Courier since it supports well-known SMS providers like Twilio, Plivo, MessageBird, and more.
Creating a Courier account
You can create a free Courier account by signing up at https://app.courier.com/signup.
Creating a new channel
After logging in, add an SMS provider. Open the Channels tab in the Courier dashboard, choose an SMS provider from the list (for example, Twilio, Plivo, or MessageBird), enter the credentials the provider asks for, and install it. Courier routes your SMS through whichever provider you configure, so you can switch or add providers later without changing your code.
Creating a notification
Open the Designer tab and create a notification. Add an SMS channel, then compose the message body. Publish your changes so the template is ready to send.
Install the Courier SDK
Install the Courier Python SDK using pip:
pip install trycourier
Then send your SMS notification. Store your API key in an environment variable rather than hardcoding it, and send to a user profile that already has a phone number on file:
import osfrom courier import Courierclient = Courier(api_key=os.environ["COURIER_API_KEY"])response = client.send.message(message={"to": {"user_id": "user-123",},"template": "NEDRQK62TWM70MHT84S6FKSXM4VT","data": {"name": "Nomen Nescio",},})print(response.request_id)
Courier stores the recipient's phone number on their user profile, so you send to a user_id and Courier resolves the SMS destination for you. You can also pass a phone_number directly under to if you prefer. Replace the template value with the ID of the notification you published, and use data to pass any variables your template references.
Note: You can customize the above code based on your requirements. Refer to the Courier documentation for more details.
Install a provider SDK with pip (for example pip install twilio, pip install vonage, pip install plivo, or pip install trycourier), store your API credentials in environment variables, then call the SDK's send method with a recipient number and a message body. Each provider in this guide includes a runnable Python example.
It depends on your needs. Twilio, Vonage, and Plivo are single-provider SDKs that talk directly to one SMS gateway. Courier is a multi-channel option: one API sends SMS through providers like Twilio, Plivo, or MessageBird and can extend the same code to push, email, and in-app without a rewrite.
Yes. Twilio, Vonage, and Plivo each require an SMS-enabled number that you purchase and verify in their console. With Courier you configure the number inside the SMS provider you connect, so the number lives with that provider rather than in your Python code.
Loop over a list of recipients and call the send method once per recipient, or use a provider feature built for bulk sends. With Courier you can send to a list or audience so a single API call fans out to many users across the channels you configure.
The SDKs are free and open source, but the SMS delivery itself is billed per message by the provider. Twilio, Vonage, and Plivo charge per SMS, and Courier bills based on notification volume across channels. Most providers offer trial credit so you can test before you pay.
With single-provider SDKs you would integrate each channel separately. With Courier the same client.send.message call can deliver push, email, and in-app notifications alongside SMS, so you add channels by configuring them in the dashboard instead of changing your code.
In this article, I've discussed different service providers that you can use to send SMS with Python. With basic knowledge of Python, you should now be able to choose the most suitable provider and integrate it into your application to send SMS.
Keep exploring
One API, every channel
Courier gives you one API for email, SMS, push, and chat, with templates, routing, retries, and delivery logs built in.
Last updated Jul 6, 2026. Code samples are illustrative; provider APIs and pricing change over time, so check each provider’s docs before relying on them.
© 2026 Courier. All rights reserved.