yousend (Python)
Official Python SDK for the YouSend email API. Zero dependencies (stdlib only), Python 3.8+.
Install
pip install yousend
Quick start
from yousend import YouSend
ys = YouSend("ys_live_...")
resp = ys.emails.send(
from_="hello@yourdomain.com",
to="customer@example.com",
subject="Welcome aboard",
html="<h1>Welcome!</h1><p>Thanks for signing up.</p>",
track_opens=True,
track_clicks=True,
)
print(resp["messages"][0]["id"])
fromis a Python keyword, so the send parameter isfrom_.
Sending
# Multiple recipients
ys.emails.send(from_=sender, to=["a@x.com", "b@x.com"], subject=s, html=h)
# Template + variables
ys.emails.send(from_=sender, to=to, template="welcome", data={"name": "Sam"})
# Idempotent send (safe to retry)
ys.emails.send(from_=sender, to=to, subject=s, html=h, idempotency_key="order-1234")
# Batch — up to 100, one recipient each
ys.emails.batch([
{"from_": sender, "to": "a@x.com", "subject": s, "html": h},
{"from_": sender, "to": "b@x.com", "subject": s, "html": h},
])
# Retrieve / list
email = ys.emails.get(message_id)
recent = ys.emails.list(status="delivered", limit=50)
Other resources
ys.domains.create("yourdomain.com") # returns DNS records to publish
ys.domains.verify(domain_id)
ys.templates.upsert(name="welcome", subject="Hi {{name}}", html="<p>Hi {{name}}</p>")
ys.webhooks.create(url="https://you.com/hooks", events=["email.delivered", "email.opened"])
ys.suppressions.add("bounced@x.com")
ys.api_keys.create("live") # returns the key once
Verifying webhooks
Pass the raw request body — not a re-serialized dict.
Flask
from flask import Flask, request
from yousend import verify_webhook, YouSendError
app = Flask(__name__)
@app.post("/webhooks/yousend")
def hook():
try:
event = verify_webhook(request.get_data(), request.headers.get("Courier-Signature"), SECRET)
except YouSendError:
return "", 400
if event["type"] == "email.clicked":
print("clicked", event["data"]["url"])
return "", 200
FastAPI
from fastapi import FastAPI, Request, Response
from yousend import verify_webhook, YouSendError
app = FastAPI()
@app.post("/webhooks/yousend")
async def hook(request: Request):
raw = await request.body()
try:
event = verify_webhook(raw, request.headers.get("Courier-Signature"), SECRET)
except YouSendError:
return Response(status_code=400)
return Response(status_code=200)
Errors
from yousend import YouSend, YouSendError
try:
ys.emails.send(from_=sender, to=to, subject=s, html=h)
except YouSendError as e:
print(e.status, e.code, e.message)
License
MIT
Metadata
Release files for yousend 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yousend-0.1.0.tar.gz | 5.7 kB | Without provenance | Details for yousend-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yousend-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for yousend-0.1.0-py3-none-any.whl |
Total release size: 13.1 kB
Release files / yousend-0.1.0.tar.gz
| Download URL | yousend-0.1.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bdbc34505a492c527afe8284204c8661db590228c61792de9a8d91b1f0dff2ad
|
|
BLAKE2b-256 checksum How to use checksums |
f7d9b621b52e8d1849a0dc08aa956b0e4a756f093852a13618b9a72c063b99ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / yousend-0.1.0-py3-none-any.whl
| Download URL | yousend-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b4e0cf9a0970e7caf69623c91f080f8677e4b31a83aaa8da63abce3cd45c240
|
|
BLAKE2b-256 checksum How to use checksums |
803e0b3e0e0246e9786f5563877486d916f295ef45b5fa5f3061f1212c0f00f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Security for yousend 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.
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.