Sendexa LogoDocs
SDK
v0.1.0

Python SDK

The official Python SDK for Sendexa. One package, one client, every API — SMS, OTP, WhatsApp, Email, Voice, and Webhook verification.

Zero Dependencies

Built on the Python standard library — urllib and hmac only. No pip bloat.

Universal

Works in Django, Flask, FastAPI, AWS Lambda, and plain scripts.

Fully Typed

Complete TypedDicts for every request and response. Passes mypy strict.

Python 3.9+

Supports Python 3.9 and above. No external type-stub packages needed.

Installation
Bash
pip install sendexa
Initialise the Client

Create one client instance per application and reuse it — it is stateless and safe to share across threads and requests.

Python
import os
from sendexa import Sendexa
client = Sendexa(
api_key=os.environ["SENDEXA_API_KEY"],
api_secret=os.environ["SENDEXA_API_SECRET"],
)
API Examples

Send single and bulk SMS messages with delivery tracking.

Python
# Send a single SMS
response = client.sms.send(
to="0244123456",
from_="MyBrand",
message="Your order #1234 has been confirmed!",
)
print(response["data"]["messageId"], response["data"]["status"])
# Send bulk SMS
client.sms.send_bulk(
from_="MyBrand",
message="Hello from MyBrand!", # shared fallback
messages=[
{"to": "0244123456", "message": "Hi Alice!"},
{"to": "0555987654"}, # uses shared message
],
)
# Check delivery status
status = client.sms.get_status(response["data"]["messageId"])
print(status["data"]["status"]) # "delivered"
# Resend a failed message
client.sms.resend(response["data"]["messageId"])
Error Handling

All API errors raise a SendexaError with structured fields for easy branching.

Python
from sendexa import Sendexa, SendexaError
try:
client.sms.send(to="0244123456", from_="MyBrand", message="Hi!")
except SendexaError as err:
print(err.status) # HTTP status e.g. 403
print(err.code) # API code e.g. "SENDER_ID_NOT_APPROVED"
print(str(err)) # Human text e.g. "Sender ID not approved"
print(err.request_id) # Trace ID for Sendexa support
AttributeTypeDescription
statusintHTTP status code (400, 401, 403, 429…)
codestrMachine-readable error code from the API
str(err)strHuman-readable description of the error
request_idstr | NoneSendexa trace ID — include when contacting support
rawAnyThe full raw error payload from the API