Docs

Python SDK

The irisend Python SDK has zero dependencies and supports Python 3.9+. Not yet on PyPI — install straight from the repo until the first tagged release ships.

InstallcURL
# Not yet published to PyPI (the publish pipeline exists, gated on a release tag).
# Install straight from the repo until the first tagged release:
pip install "irisend @ git+https://github.com/lucamanuel06/irisend#subdirectory=packages/sdk-python"

Quickstart

Calls either return the parsed JSON response as a dict or raise irisend.IrisendError — there's no {data, error} tuple to unpack. from is a Python keyword, so every request/response dict uses from_ for it instead (converted automatically); every other field matches the wire's own snake_case name.

send.pyPython
import os
from irisend import Irisend

irisend = Irisend(os.environ["IRISEND_API_KEY"])
# or: Irisend() — api_key falls back to the IRISEND_API_KEY env var automatically

email = irisend.emails.send({
    "from_": "Acme <[email protected]>",  # "from" is a Python keyword, hence from_
    "to": "[email protected]",
    "subject": "Welcome!",
    "html": "<p>Thanks for signing up.</p>",
})
print("sent", email["id"])

Send with a template

send_with_template.pyPython
template = irisend.templates.create({
    "name": "Welcome",
    "from_": "[email protected]",
    "html": "<p>Hi {{{CUSTOMER_NAME}}}</p>",
    "subject": "Welcome!",
    "variables": [{"key": "CUSTOMER_NAME", "type": "string", "fallback_value": "there"}],
})
irisend.templates.publish(template["id"])  # required before emails.send can render it

irisend.emails.send({
    "to": "[email protected]",
    "template": {"id": template["id"], "variables": {"CUSTOMER_NAME": "Jane"}},
})

Verifying webhooks

A separate top-level irisend.webhooks module (distinct from the client.webhooks management resource) implements the same Standard Webhooks / Svix-compatible scheme the server signs with.

verify_webhook.pyPython
from irisend import webhooks

# headers is a dict of the incoming request's headers; body is the exact, unparsed request body
if not webhooks.verify(signing_secret, headers, body):
    raise ValueError("invalid webhook signature")

# or verify and parse in one call:
event = webhooks.construct_event(signing_secret, headers, body)  # raises WebhookVerificationError