Twilio SMS and MMS Python Quickstart

This Python Quickstart compendium will take you through all the steps you'll need to add SMS and MMS capabilities to your Python web application. The quickstarts we've put together will take you through every common SMS scenario, from sending and receiving SMSes and MMSes to more advanced topics like conversation tracking. We will show API endpoints as well as demonstrate usage of the Twilio Python Helper Library.


Twilio Messaging allows you to:

  1. Receive SMS and MMS messages to your Twilio phone numbers and reply back
  2. Send messages using Twilio's REST API
  3. Track conversations
  4. Send SMS and MMS text messages during phone calls

Send Messages Via the REST API

You can send SMS and MMS messages using Twilio's REST API.

To send a message, make an HTTP POST to Twilio with the body of the message and the phone number you want to send it to. Messages must be sent from Twilio message-enabled phone numbers due to the architecture of the global SMS/MMS network.

Receive and Reply to Messages

When you buy a message-enabled Twilio phone number, you can associate that phone number with a Message URL. When someone sends a text message to that phone number, Twilio makes an HTTP request to your URL with the body of the message and the sender's phone number. You can then respond to the message by returning a reply message in the HTTP response to Twilio.

Track Conversations Across Multiple Messages

Using standard HTTP cookies, you can share state across multiple messages allowing you to treat separate messages between any pair of phone numbers as a conversation. You can also store data about the conversation in the cookie for future reference.

Send Text Messages During Phone Calls

You can also use the TwiML <Sms> verb inside your existing Twilio voice calls to send a message during a phone conversation.

Frequently Asked Questions

For specific details on what you can and can't accomplish using Twilio Message please refer to the Message FAQ. We've compiled a large number of frequently asked questions there to help you add Twilio's capabilities to your application - as well as troubleshoot when things go wrong.

Before You Begin the Quickstarts...

Most of these tutorials assume you can run Flask on a server available over the internet, and that you have the twilio-python library installed. If not, see our guide to setting up your local Python development environment.

You can begin by opening the Quickstart navigation or clicking the link below.

First: Send Messages via the Twilio API and Library in Python »

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.