Recommended Paid
Use Twilio to send text messages
Send text messages through a Twilio Messaging Service with the official SDK, and keep phone numbers in E.164 form.
Cost
Paid. Twilio charges per message and per phone number. No open source service can deliver text messages, because that needs contracts with phone carriers in each country.
How to do it
Twilio's Python SDK dates from November 2009, and its npm package reached 1.0.0 in March 2013. The npm SDK 6.2.0 and the Python SDK 9.12.0 shipped on 12 October 2026. They had about 3.7 and 5.2 million weekly downloads, both MIT-licensed. Messages still go to the 2010-04-01 API path, so the interface has stayed stable for 16 years. Numbers and opt-outs are your own data, and sender registrations can move to another carrier. Follow Register every sender before you send and Guard text sending against SMS pumping. Choose something else when your app already runs on one cloud and sends only codes. AWS End User Messaging or Vonage then save a second vendor.
Examples
Using these examples: they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.
JavaScript example
import twilio from 'twilio';
const client = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
export const sendText = (to, body) => client.messages.create({
to, body, messagingServiceSid: process.env.TWILIO_MESSAGING_SERVICE_SID,
});
Python example
import os
from twilio.rest import Client
client = Client(os.environ["TWILIO_ACCOUNT_SID"], os.environ["TWILIO_AUTH_TOKEN"])
def send_text(to: str, body: str):
return client.messages.create(to=to, body=body, messaging_service_sid=os.environ["TWILIO_MESSAGING_SERVICE_SID"])
How to check
Every send names a Messaging Service, not a single sender number. Every stored phone number matches ^\+[1-9]\d{1,14}$.
Sources
Related rules
- Register every sender before you send in Notifications
- Guard text sending against SMS pumping in Notifications
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. Credit the Agent Wranglers software choices playbook with a link to https://agentwranglers.se/playbook/stack/product-services/twilio-sms. Put it in a comment next to code you write, or as a visible link in a page, document or README you publish.