Skip to main content

Delivrie for Python

The official Python SDK for Delivrie, the email API for transactional email, broadcasts, automations and a shared inbox.

  • No dependencies: the standard library only
  • Python 3.10+, sync and async (AsyncDelivrie)
  • Safe retries: rate limits, server errors and network errors are retried, and sends only with an idempotency key, so an email is never sent twice
  • Webhook signature verification built in

Install

pip install delivrie

Send an email

Create an API key at delivrie.io/api-keys and set it as DELIVRIE_API_KEY.

from delivrie import Delivrie

client = Delivrie()  # reads DELIVRIE_API_KEY

email = client.emails.send(
    from_="Acme <hello@mail.acme.com>",
    to="ada@example.com",
    subject="Welcome to Acme",
    html="<p>Thanks for signing up.</p>",
    idempotency_key="welcome-ada",
)
print(email["id"])

from is a Python keyword, so pass from_, or send a dict exactly like the REST API:

client.emails.send({"from": "Acme <hello@mail.acme.com>", "to": ["ada@example.com"], "subject": "Hi", "text": "Hello"})

Python values are converted for you: datetime for scheduled_at, bytes for attachment content, and a dict for tags.

from datetime import datetime, timedelta, timezone

client.emails.send(
    from_="Acme <billing@mail.acme.com>",
    to="ada@example.com",
    subject="Your invoice",
    html="<p>Attached.</p>",
    attachments=[{"filename": "invoice.pdf", "content": open("invoice.pdf", "rb").read()}],
    tags={"category": "invoice"},
    scheduled_at=datetime.now(timezone.utc) + timedelta(hours=1),
)

Templates

client.emails.send(
    from_="Acme <hello@mail.acme.com>",
    to="ada@example.com",
    template={"id": "welcome", "variables": {"first_name": "Ada"}},
)

Batch

client.emails.batch([
    {"from": "Acme <hello@mail.acme.com>", "to": "ada@example.com", "subject": "Hi Ada", "text": "Hello"},
    {"from": "Acme <hello@mail.acme.com>", "to": "tobi@example.com", "subject": "Hi Tobi", "text": "Hello"},
], idempotency_key="digest-2026-11-14")

Errors

Methods return the API's JSON as a dict and raise DelivrieError when something goes wrong:

from delivrie import DelivrieError

try:
    client.emails.send(from_="Acme <hello@mail.acme.com>", to="ada@example.com", subject="Hi", text="Hello")
except DelivrieError as e:
    print(e.status_code, e.name, e.message)  # 422 validation_error The from domain ... is not verified yet

status_code is 0 for problems that never reached the API (network_error or timeout). Every error name is listed at delivrie.io/docs/errors.

Async

from delivrie import AsyncDelivrie

client = AsyncDelivrie()

@app.post("/signup")
async def signup(email: str):
    await client.emails.send(from_="Acme <hello@mail.acme.com>", to=email, subject="Welcome", text="Hi!",
                             idempotency_key=f"welcome-{email}")

Webhooks

Verify the signature with the raw body, before parsing it:

import os
from delivrie import verify_webhook, WebhookVerificationError

# Flask
@app.post("/webhooks/delivrie")
def delivrie_webhook():
    try:
        event = verify_webhook(request.get_data(), request.headers, os.environ["DELIVRIE_WEBHOOK_SECRET"])
    except WebhookVerificationError:
        return "", 400
    if event["type"] == "email.bounced":
        ...
    return "", 204

In Django, pass request.body and request.headers; in FastAPI, await request.body() and request.headers.

Everything else

The client covers the whole API with the same names as the Node.js SDK, in snake_case:

client.emails send, batch, get, list, list_received, update, cancel, forward
client.domains create, get, verify, update, list, remove
client.api_keys create, list, remove
client.webhooks create, list, deliveries, test, replay, verify
client.contacts create, get, update, list, remove
client.segments create, list, remove, add_contacts
client.broadcasts create, get, list, send, cancel, recipients, remove
client.templates create, get, list, publish
client.suppressions add, list, remove
client.events send, list
client.automations list, get, create, runs, publish, pause, resume
client.inbox.threads list, get, update, reply
client.topics, client.contact_properties, client.inbox.labels list
client.metrics, client.usage get
client.logs list, get

For anything else, client.request("GET", "/path") calls the API directly.

Options

Delivrie(
    api_key="dlv_...",          # default: DELIVRIE_API_KEY
    base_url="https://...",     # default: https://delivrie.io/api (or DELIVRIE_BASE_URL)
    timeout=30,                 # seconds per request
    max_retries=2,
    headers={"X-Request-Source": "billing-service"},
)

MIT licensed.

Metadata

Release files for delivrie 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for delivrie 0.1.0
File Size Uploaded Provenance Actions
delivrie-0.1.0.tar.gz 15.2 kB With provenance Details for delivrie-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for delivrie 0.1.0
File Interpreter ABI Platform Actions
delivrie-0.1.0-py3-none-any.whl Python 3 none any Details for delivrie-0.1.0-py3-none-any.whl

Total release size: 27.7 kB

Release files / delivrie-0.1.0.tar.gz

Download URL delivrie-0.1.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a12df7f54450aafa0afed0ed8f0b7ce4f8a1ef5b9040b4607b7f9a8de4e9201e
BLAKE2b-256 checksum
How to use checksums
b13877e10ba1dcf45495b0f8c56c204c2c04f11cec99b3ba0decfccc3569eca2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / delivrie-0.1.0-py3-none-any.whl

Download URL delivrie-0.1.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a28f6693d7a13ae7e8f9b6b09220369c864ead1fe2f3ec6e15e79c3cc876073e
BLAKE2b-256 checksum
How to use checksums
2908a0df60b88894c888bd8273c8dbf77448cae900ef06260617ca6ef54a2996
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for delivrie 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for delivrie-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page