Python SMS

Send an SMS from Python, or a free push alert instead

For alerts to your own phone, PushPiper is free from Python: 10,000 push messages a month on 10 devices, no carrier fees. For real SMS, Python works with Twilio, Amazon SNS or Textbelt: Twilio charges $0.0083 per segment plus carrier surcharges, and SNS about $0.01195 per message. SMS splits after 160 characters, while PushPiper delivers up to 1,024.

How Python SMS options compare with push alerts

If your Python script sends updates to customers, you need an SMS provider like Twilio or Amazon SNS. If your script just alerts you when a job fails or a server runs out of space, push notifications avoid carrier surcharges and registration paperwork. You don't need to lease a phone number or register a business brand just to message yourself.

The table below compares costs and setup steps for each option when sending alerts from Python.

RouteUS price per messageSetup before the first message
Twilio$0.0083 plus $0.0035 to $0.0050 carrier feesAccount, number, 10DLC or toll-free verification
Amazon SNSAbout $0.01195AWS account, registered number
Textbelt1 free a day, paid from $0.0129None for the free text
PushPiper pushFree up to 10,000 a monthSign in, install the app, create an app token

Send SMS with Twilio in Python

Twilio sends text messages through its REST API using the official Python client.

  1. Sign up for Twilio and copy your Account SID and Auth Token from the console.
  2. Buy an SMS number or verify your personal number for trial testing.
  3. Register for A2P 10DLC or toll-free verification for US messaging.
  4. Install the library with pip install twilio.
Twilio (Python)
import os
from twilio.rest import Client

client = Client(os.environ["TWILIO_ACCOUNT_SID"], os.environ["TWILIO_AUTH_TOKEN"])

message = client.messages.create(
    body="Disk on web-1 is 95% full",
    from_="+15017122661",
    to="+15558675310",
)
print(message.sid)

Set your credentials in your environment or replace os.environ["TWILIO_ACCOUNT_SID"] and os.environ["TWILIO_AUTH_TOKEN"] directly in your script. Set from_ to your Twilio number and to to your destination in E.164 format.

Twilio charges $0.0083 per segment, plus carrier pass-through fees:

  • AT&T: $0.0035 per segment
  • T-Mobile: $0.0045 per segment
  • Verizon and US Cellular: $0.0050 per segment
  • Other carriers: $0.0042 per segment

A message to T-Mobile costs $0.0128 per segment, and failed messages incur a $0.001 fee. In the US, A2P 10DLC standard brand registration costs $44 one-time, campaign vetting costs $15 one-time, and campaign monthly fees run from $1.50 to $10. Low-volume brands cost $4 one-time plus $15 vetting and $1.50 to $10 monthly. Sole proprietors pay $4 brand, $15 vetting, and $2 monthly. You can check Twilio SMS pricing in the US, with every fee added up or read about 10DLC registration: what it costs and when you can skip it.

Send SMS with Amazon SNS in Python

Amazon SNS delivers SMS through AWS End User Messaging using the boto3 library.

  1. Create an AWS account and configure credentials locally.
  2. Register a US origination identity in the AWS console.
  3. Install the SDK with pip install boto3.
Amazon SNS (Python)
import boto3

sns = boto3.client("sns", region_name="us-east-1")
sns.publish(PhoneNumber="+15558675310", Message="Disk on web-1 is 95% full")

Set region_name to your AWS region like us-east-1. Update PhoneNumber with your E.164 phone number and adjust Message.

Amazon SNS has no free tier for SMS. Outbound texts to US numbers cost about $0.01195 each ($0.00774 base plus $0.00421 carrier fee). US sending requires a registered origination identity:

  • 10DLC numbers cost $1 a month, plus $10 a month for the campaign ($2 low-volume) and a $4.50 one-time brand fee.
  • Toll-free numbers cost $2 a month with required verification.
  • Short codes cost $650 setup plus $995 a month.

Send a free test SMS with Textbelt

Textbelt provides a simple HTTP endpoint that requires no SDK or account setup for quick tests.

Textbelt (Python)
import requests

result = requests.post(
    "https://textbelt.com/text",
    data={"phone": "5557727420", "message": "Disk on web-1 is 95% full", "key": "textbelt"},
    timeout=10,
).json()
print(result)

Change phone to your recipient's number and set message. Keep key as "textbelt" to use the daily free allowance.

  • Textbelt allows 1 free text per day with key="textbelt".
  • Paid credits cost $3 for 50 texts ($0.06 each) up to $45 for 3,500 texts (about $0.0129 each).
  • Its open source version relies on carrier email-to-text gateways.

Carrier email gateways are shutting down. AT&T ended email-to-text on June 17, 2025, and Verizon is ending vtext.com and vzwpix.com by March 31, 2027. See our guide to free SMS APIs in 2026, and the free alternative for alerts.

Send push alerts with PushPiper in Python

If you only need notifications on your own devices, PushPiper sends push alerts via an HTTP request without telecom fees.

  1. Open PushPiper and sign up free with Google.
  2. Install the app via your browser. On iPhone and iPad (iOS/iPadOS 16.4+), open the app in Safari, tap Share, and tap Add to Home Screen. On Android, macOS, Windows, and Linux, install via Chrome, Edge, Firefox, or Safari.
  3. Create an application token and copy your user key.
PushPiper (Python)
import requests

requests.post(
    "https://api.pushpiper.com/1/messages.json",
    data={
        "token": "APP_TOKEN",
        "user": "USER_KEY",
        "title": "web-1",
        "message": "Disk on web-1 is 95% full",
        "priority": 1,
    },
    timeout=10,
).raise_for_status()

Replace APP_TOKEN with your 30-character token (starts with a) and USER_KEY with your 30-character key (starts with u).

PushPiper priority levels:

  • -2: Lowest, inbox only.
  • -1: Low, silent banner.
  • 0: Normal, respects device quiet hours.
  • 1: High urgency, bypasses PushPiper quiet hours.
  • 2: Emergency, repeats every retry seconds (minimum 30) until acknowledged or expired (up to 10,800 seconds).

PushPiper has no native iOS or Android app in app stores yet, does not send SMS or make calls, and has no on-call escalation schedules. Free covers 10,000 messages a month across 10 devices at EUR 0. See Twilio alternatives for alerts and notifications.

Character limits and message formatting

SMS messages follow strict telecom segment limits:

  • GSM-7 encoding allows 160 characters per segment, splitting into 153-character chunks for longer texts.
  • Emoji and non-Latin text trigger UCS-2 encoding, cutting limits to 70 characters (67 per segment when split). Each segment is billed separately.

PushPiper doesn't split messages. It allows up to 1,024 characters in message and 250 in title. If your message exceeds 1,024 characters, the API rejects it with an HTTP 400 error, so trim long text before posting.

Sources

Questions and answers

Can I send an SMS from Python without paying for a subscription?

Textbelt sends 1 free text daily using the Textbelt key. Beyond that single text, SMS delivery requires buying credits or paying per message.

Why did my Python SMS cost more than the base rate?

Carriers add pass-through fees between $0.0035 and $0.0050 per segment on top of provider pricing. Messages longer than 160 GSM-7 characters (or 70 UCS-2 characters when using emoji or non-Latin scripts) split into multiple billed segments.

Does PushPiper require installing an app from an app store?

PushPiper installs directly through your browser as a Web Push application. On iOS 16.4 or later, open Safari, tap Share, and choose Add to Home Screen.

What happens when I exceed my monthly PushPiper quota?

When you reach 10,000 messages on the Free plan, the API returns an HTTP 429 response. Quotas reset on the 1st of each month at 00:00 UTC.

Can I send file attachments with Python alerts?

PushPiper lets you attach one file up to 5 MB (images, PDF, text, audio, or MP4) directly to a notification using the attachment field.

Free for 10,000 messages a month

Sign in with Google and send your first ping in a minute.

Get started for free