Sending SMS from Python takes a single HTTPS request. Here is a working example against the eSMS Africa API, and what to do with the response.

Send an SMS

Post to the send endpoint with your API key in the Authorization header:

import requests

r = requests.post(
    "https://sms.esmsafrica.io/api/messages/send",
    headers={"Authorization": "Bearer esms_live_..."},
    json={"to": "+254712345678", "text": "Hello from eSMS Africa", "sender_id": "eSMS"},
)
print(r.json())
The response returns the message id, the number of segments, the encoding and the cost, so you can reconcile spend.

Handle the result

Store the returned message id. Delivery is asynchronous, so the final status (delivered, failed) arrives later - either poll the message-status endpoint or, better, receive a delivery webhook so your app is notified in real time.

Validate first

Before a bulk run, pass your numbers through the validate endpoint to drop malformed or non-mobile numbers - it is free and saves you paying to text dead numbers.

Get started

Grab a free API key and send a test SMS: start free.