Language SDKs
Python
Send published Sendery templates from Python.
Install
pip install senderyRequirements
Python 3.10+.
Set up
Publish a welcome template with name and action_url variables, and create a project API key. Store it as SENDERY_API_KEY on your server.
Shell
export SENDERY_API_KEY="your_project_api_key"Send an email
The response contains the accepted email’s id and status. Calls are synchronous; use asyncio.to_thread() when sending from async code.
Python
import os
from sendery import Sendery
sendery = Sendery(os.environ["SENDERY_API_KEY"])
receipt = sendery.send(
to="[email protected]",
template="welcome",
data={"name": "Alex", "action_url": "https://example.com/start"},
)
print(receipt["id"])Retrieve an email
Use the returned ID to check delivery status.
Python
message = sendery.get(receipt["id"])
print(message["status"])Retry a send
Use a key such as welcome-123 for one email, and keep the payload unchanged on retries. retry(3) allows up to three additional attempts for temporary failures; send() alone makes one attempt.
Python
email = sendery.prepare(
to="[email protected]",
template="welcome",
data={"name": "Alex", "action_url": "https://example.com/start"},
idempotency_key="welcome-123",
)
receipt = email.retry(3).send()Handle errors
Catch the SDK exception to inspect the status and code. Retry delays are in seconds. The example uses the prepared email from the retry example above.
Python
from sendery import SenderyError
try:
receipt = email.retry(3).send()
except SenderyError as error:
print(error.status, error.code, error.errors)
# error.retry_after is a delay in seconds, when provided.
raise