Send SMS from Django with the SendiMessage API
Django integrates SendiMessage with the official Python SDK (pip install sendimessage): settings hold the key pair, a small service module owns the client, and models or signals decide when to call it. A CSRF-exempt view receives webhooks.
Call the send from Celery tasks (or Django-Q) for anything user-facing — the API queues the message either way, and background execution keeps views fast.
What this integration enables
Architecture
- Your application eventAn order ships, a booking nears, a ticket updates
- Django server codeBuilds the request with credentials from the environment
- SendiMessage APIPOST /send-message returns the queued message
- Managed messaging lineSMS, or iMessage on supported lines and destinations
- Webhook eventsDelivery status and incoming replies post back to your endpoint
Example request
# pip install sendimessage# settings.py:# SENDIMESSAGE_KEY = os.environ["SENDIMESSAGE_KEY"]# SENDIMESSAGE_SECRET = os.environ["SENDIMESSAGE_SECRET"]# notifications/services.pyfrom django.conf import settingsfrom sendimessage import Clientclient = Client(api_key=settings.SENDIMESSAGE_KEY, api_secret=settings.SENDIMESSAGE_SECRET)def send_message(to: str, content: str) -> dict:msg = client.send_message(number=to, content=content)return msg # {"message_handle": "4e828182-…", "status": "QUEUED", …}# notifications/views.py — webhook receiverfrom django.http import HttpResponsefrom django.views.decorators.csrf import csrf_exemptfrom sendimessage import verify_webhook_signature@csrf_exemptdef sendimessage_webhook(request):ok = verify_webhook_signature(secret=settings.WEBHOOK_SECRET,raw_body=request.body,signature_header=request.headers.get("SendiMessage-Signature", ""), # "t=...,v1=...")if not ok:return HttpResponse(status=401)event = json.loads(request.body) # "outbound" / "receive" …return HttpResponse(status=200)
Delivery events and incoming replies
Point a Django route at your webhook URL to receive delivery status and incoming replies. Verify the signature header before processing.
// "outbound" event → your django endpoint// Verify the SendiMessage-Signature header (t={timestamp},v1=HMAC-SHA256 of// "{timestamp}.{raw body}", keyed with your webhook secret), then use// GET /v2/messages/{message_handle} for authoritative state and match it to// your contact_id in django.
Limitations and honest notes
- iMessage delivery is available on supported messaging lines and destinations. Recipients without iMessage receive SMS when fallback is configured — never assume universal iMessage availability.
- Messages are accepted asynchronously — the API returns status QUEUED and final status arrives via webhook or the message endpoints.
- Official SDKs are published for JavaScript/TypeScript (npm: sendimessage), Python (PyPI: sendimessage), PHP (Composer: sendimessage/sdk), and Go (github.com/sendimessage/sendimessage-go). Every SDK is dependency-free and covers the full public API surface.
Security considerations
- Keep the API key pair in server configuration or environment variables, never in the repository.
- Verify webhook signatures before trusting delivery or reply events.
Frequently asked questions
Is there an official Django package for SendiMessage?
Can Django receive message replies?
Related integrations
Ready to connect Django?
Request a messaging line and a SendiMessage integration specialist will review your Django workflow and guide the setup.