Skip to main content

Python transactional email API client for zaSend

Project description

zasend

License: MIT Python

Official Python client for the zaSend transactional email API.

zaSend is a developer-focused email delivery service for sending product, auth, billing, notification, and lifecycle emails from your application. This package is a small wrapper around the zaSend REST API for Python apps, Django, Flask, FastAPI, background jobs, and scripts.

Use it to:

  • Send transactional email from verified domains
  • Send template-based email with variables
  • Check message status and events
  • Manage suppressions, webhooks, templates, and domains
  • Verify zaSend webhook signatures

The client stays close to the raw API. It has no heavy framework dependencies and uses requests.

Install

pip install zasend

Quick Start

from zasend import ZaSend

client = ZaSend(api_key="sk_live_...")

result = client.send_email(
    from_email="zaSend <noreply@zasend.com>",
    to="user@example.com",
    subject="Welcome",
    text="Thanks for signing up.",
)

print(result["message_id"])

You can use an Account API Key (sk_live_...) for all methods. A Domain Sending Key (dsk_live_...) is restricted to sending email from one verified domain.

Send HTML Email

client.send_email(
    from_email="Acme <noreply@acme.com>",
    to="customer@example.com",
    subject="Your receipt",
    html="<h1>Thanks for your order</h1><p>Your receipt is attached.</p>",
    text="Thanks for your order. Your receipt is attached.",
)

Send to Multiple Recipients

client.send_email(
    from_email="Acme <noreply@acme.com>",
    to=["one@example.com", "two@example.com"],
    subject="Product update",
    text="A new update is available.",
)

zaSend returns one queued message per to recipient. Suppressed recipients reject the whole request so you can fix the list before sending.

Template Send

client.send_template_email(
    from_email="Acme <noreply@acme.com>",
    to="customer@example.com",
    template="welcome",
    variables={"name": "Ada"},
)

Django Example

# settings.py
ZASEND_API_KEY = "sk_live_..."

# anywhere in your app
from django.conf import settings
from zasend import ZaSend

zasend = ZaSend(settings.ZASEND_API_KEY)
zasend.send_email(
    from_email="Acme <noreply@acme.com>",
    to=user.email,
    subject="Reset your password",
    text="Use this link to reset your password.",
)

Flask or FastAPI Example

import os
from zasend import ZaSend

zasend = ZaSend(os.environ["ZASEND_API_KEY"])

def send_signup_email(email):
    return zasend.send_template_email(
        from_email="Acme <noreply@acme.com>",
        to=email,
        template="welcome",
        variables={"product": "Acme"},
    )

Webhook Verification

zaSend signs webhook payloads with HMAC-SHA256. Verify the raw request body before trusting webhook data.

from zasend import verify_webhook_signature

ok = verify_webhook_signature(
    request.get_data(),
    "whsec_...",
    request.headers.get("X-zaSend-Signature"),
)

API Methods

Method Description
send_email(**message) Send direct content or a template email
send_template_email(...) Convenience wrapper for template sends
get_email(message_id) Fetch email status and events
get_rate_limits() Fetch daily usage and limits
list_domains() / add_domain(domain) / verify_domain(id) / delete_domain(id) Manage sending domains
list_suppressions(...) / add_suppression(email, ...) / delete_suppression(id) Manage suppression list entries
list_webhooks() / create_webhook(url, events) / delete_webhook(id) Manage signed delivery webhooks
list_templates() / create_template(...) / get_template(id) / update_template(id, ...) / delete_template(id) Manage email templates

Error Handling

from zasend import APIError, RateLimitError, ValidationError, ZaSend

try:
    ZaSend("sk_live_...").send_email(
        from_email="Acme <noreply@acme.com>",
        to="user@example.com",
        subject="Hello",
        text="Body",
    )
except RateLimitError as exc:
    print("Rate limited:", exc)
except ValidationError as exc:
    print("Invalid request:", exc)
except APIError as exc:
    print("zaSend API error:", exc)

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zasend-0.1.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zasend-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file zasend-0.1.1.tar.gz.

File metadata

  • Download URL: zasend-0.1.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for zasend-0.1.1.tar.gz
Algorithm Hash digest
SHA256 50f263ae53683f6bc78c1d53391da6cff0f44c3bfb402824d99f700706f348dd
MD5 a6b9428294d5d8c3a809186457361a93
BLAKE2b-256 2d22dabe6b386bdd240277c8353158df9f8d95c871dea18df16da731cb8e1125

See more details on using hashes here.

File details

Details for the file zasend-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: zasend-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for zasend-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5dd02d9425cc279ea71eebb305076e89edbfe098fe2031eb5e6a8b062bdfba50
MD5 3c71f074688dcbd77d8ca3aa7ed2ec1e
BLAKE2b-256 ad516c7e25c7de5572728905820c0deaaa896f8ab7a2198e808a0f3587187d48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page