SuperSend TX 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 supersendtxFor the Django email backend:
pip install 'supersendtx[django]'2. Configure your API key
export SUPERSENDTX_API_KEY=stx_your_key_here3. Send an email (API client)
import os
from supersendtx import SuperSendTX
tx = SuperSendTX(os.environ["SUPERSENDTX_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 SuperSendTX.
Django email backend (recommended)
# settings.py
EMAIL_BACKEND = "supersendtx.django.EmailBackend"
# Uses SUPERSENDTX_API_KEY from the environment.
# Optional: EMAIL_HOST-style settings are not used; configure the API key via env.The Django backend is supersendtx.django.EmailBackend.
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 python/ in the public supersendtx-sdks repository.