Skip to main content

usend for Python

The official Python SDK for usend, the email API for developers.

pip install usend
import os
from usend import Usend

usend = Usend(os.environ["USEND_API_KEY"])

email = usend.emails.send({
    "from": "Acme <hello@acme.com>",
    "to": "ann@example.com",
    "subject": "Your login code",
    "html": "<p>Your code is <b>482913</b></p>",
})
print(email["id"])

Methods return the API's JSON as dicts and raise usend.UsendError (status_code, name, message).

  • Python 3.9 or newer. No dependencies.
  • The key defaults to USEND_API_KEY; the base URL to USEND_BASE_URL or https://api.usend.et.
  • Requests are retried (max_retries, default 2) with backoff on 429 (honoring Retry-After), 5xx and network errors. A POST is only retried after a 5xx or network error when it carries an idempotency_key, so an email is never sent twice by a retry.
  • smtp_settings(key) / usend.smtp_settings() return SMTP settings (host smtp.usend.et, port 465 or 587).
  • Resources: emails (incl. metrics, share, test, insights), batch, received, templates (+ versions), domains (+ claims, insights), api_keys, audiences, segments, contacts (+ imports, topics), contact_properties, topics, short_links (+ stats), broadcasts (+ cancel, duplicate, recipients, clicked_links, performance), webhooks (+ rotate_secret, events), suppressions (+ create_batch, remove_batch), events, automations (+ runs), inboxes (.labels, .threads, .drafts), logs, stats, tools, oauth.
  • Every endpoint is described in openapi/openapi.yaml (OpenAPI 3.1) in the usend repository.
usend.events.send("order.paid", email="ann@example.com", payload={"total": 42})
usend.suppressions.create_batch(["a@example.com", "b@example.com"])
usend.broadcasts.recipients(broadcast_id, type="opened")  # `type` is required

Send through SMTP; the API key is the password:

import smtplib
from usend import smtp_settings

s = smtp_settings("us_...")  # smtp.usend.et:465, or smtp_settings("us_...", port=587) for STARTTLS
with smtplib.SMTP_SSL(s["host"], s["port"]) as smtp:
    smtp.login(s["username"], s["password"])
    smtp.send_message(message)

Verify a webhook (pass the raw body):

from usend import verify_webhook

event = verify_webhook(raw_body, request.headers, os.environ["USEND_WEBHOOK_SECRET"])

Docs: https://usend.et/docs

Metadata

Release files for usend 1.3.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 usend 1.3.0
File Size Uploaded Provenance
usend-1.3.0.tar.gz 13.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 23.9 kB

Release files / usend-1.3.0.tar.gz

Download URL usend-1.3.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
86ff9e87f6b28527ebea3ac4cf4aeef75846d291effbde531edd9965ca3c5c68
BLAKE2b-256 checksum
How to use checksums
c13c0d115c81bec6619b93adedc63497b479926714b2b4dd37ef9c1dc0d4389d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / usend-1.3.0-py3-none-any.whl

Download URL usend-1.3.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89ac30b62d7f67cd92ec05f8740f9f50b7b022110716fa432ca10d8b09559920
BLAKE2b-256 checksum
How to use checksums
2fe508665badfedbf24058ca9d4417ed264e521bc302c2331fdd3ed6285042e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for usend 1.3.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

1.3.0 This release

2 release files No 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