Ranla with Python
Use the Python SDK in Django, Flask, FastAPI, Celery workers, or any server-side Python app where your API key can stay private.
1. Install the SDK
pip install ranlaFor the Django email backend:
pip install 'ranla[django]'2. Configure your API key
export RANLA_API_KEY=rnl_your_key_here3. Send an email (API client)
import os
from ranla import Ranla
tx = Ranla(os.environ["RANLA_API_KEY"])
result = tx.emails.send(
from_="[email protected]",
to="[email protected]",
subject="Your receipt",
html="<p>Thanks for your purchase.</p>",
)
print(result["id"], result["status"])The client class is Ranla. SuperSendTX remains supported as an alias.
Django email backend (recommended)
# settings.py
EMAIL_BACKEND = "ranla.django.EmailBackend"
# Uses RANLA_API_KEY from the environment.
# Optional: EMAIL_HOST-style settings are not used; configure the API key via env.The Django backend is ranla.django.EmailBackend. supersendtx.django.EmailBackend remains supported.
Then send as usual:
from django.core.mail import EmailMultiAlternatives
msg = EmailMultiAlternatives(
subject="Your receipt",
body="Thanks for your purchase.",
from_email="[email protected]",
to=["[email protected]"],
)
msg.attach_alternative("<p>Thanks for your purchase.</p>", "text/html")
msg.extra_headers["X-SuperSendTX-Tag"] = "campaign=welcome"
msg.extra_headers["X-SuperSendTX-Idempotency-Key"] = "receipt-123"
msg.send()X-SuperSendTX-Tag uses name=value. Pass a list of tag strings for multiple tags. Custom non-reserved headers are forwarded to the API headers field. Optional: X-SuperSendTX-Scheduled-At (ISO 8601).
Resources
The client includes thin wrappers for common API resources:
tx.emails— send, batch, list, cancel, resend, test webhooks, deliverability insightstx.domains— create, verify, apply DNS, update, deletetx.webhooks— CRUD for webhook endpointstx.templates— CRUD plus publishtx.suppressions— list, create, remove
See the API reference for request fields. The Python SDK accepts the same JSON shapes as the REST API.
Source
Package source lives in ranla-python/ in the public supersendtx-sdks repository.