Skip to main content

Official Python SDK for the PostStack Email API

Project description

PostStack Python SDK

Official Python SDK for the PostStack Email API — an EU-hosted, GDPR-compliant email API for Python with sync and async clients, full type hints, and drop-in compatibility with Django, FastAPI, Flask, and Starlette. Up to 75% cheaper than Resend, SendGrid, and Postmark.

Docs: poststack.dev/docs/sdk.

Installation

pip install poststack

Requires Python 3.10+.

Quick start

from poststack import PostStack

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

result = client.emails.send({
    "from": "hello@example.com",
    "to": ["user@example.com"],
    "subject": "Hello from PostStack",
    "html": "<p>Welcome!</p>",
})

print(result["id"])

Async usage

import asyncio
from poststack import AsyncPostStack

async def main():
    client = AsyncPostStack(api_key="sk_live_...")
    try:
        result = await client.emails.send({
            "from": "hello@example.com",
            "to": ["user@example.com"],
            "subject": "Hello from PostStack",
            "html": "<p>Welcome!</p>",
        })
        print(result["id"])
    finally:
        await client.aclose()

asyncio.run(main())

Or use it as an async context manager:

async with AsyncPostStack(api_key="sk_live_...") as client:
    result = await client.emails.send({...})

Error handling

Any non-2xx response raises PostStackError:

from poststack import PostStack, PostStackError

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

try:
    client.emails.send({"from": "x@y.com", "to": ["z@w.com"], "subject": "hi"})
except PostStackError as e:
    print(e.status_code, e.error, e.request_id)

Configuration

client = PostStack(
    api_key="sk_live_...",
    base_url="https://api.poststack.dev",  # default
    timeout=30.0,                           # default (seconds)
)

Override timeout per call:

client.emails.send({...}, timeout=60.0)

Resources

  • client.emails — send, get, list, cancel, reschedule, batch, events, insights
  • client.domains — create, list, get, verify, update, delete, DMARC
  • client.contacts — CRUD, import, export, unsubscribe
  • client.contact_properties — custom properties
  • client.segments — create, list, get, update, delete, contacts, preview
  • client.templates — CRUD, publish, duplicate, presets
  • client.webhooks — CRUD, test, deliveries, replay
  • client.broadcasts — CRUD, send, test, variants
  • client.suppressions — list, add, remove
  • client.api_keys — CRUD
  • client.mailboxes — CRUD, aliases, password
  • client.subscription_topics — topics + contact subscriptions
  • client.workflows — CRUD, steps, activate, pause, trigger
  • client.signup_forms — CRUD, submit
  • client.email_validations — validate, validate_batch

Links

License

MIT — see LICENSE.

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

poststack-0.5.0.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

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

poststack-0.5.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file poststack-0.5.0.tar.gz.

File metadata

  • Download URL: poststack-0.5.0.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for poststack-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1c1fdc0d53d17617e0deb253c1ed7dcf7512ec209333a9e37461797eb44051ce
MD5 2b32346e5e2285bbe9b0455d8ae4545b
BLAKE2b-256 825504899661fd4428ab0ee42159a3d016a9c2b63f62ff4893c5aade356e78c7

See more details on using hashes here.

File details

Details for the file poststack-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: poststack-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for poststack-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da13f397501bf3701ee8e0214d7dd41941eb61b021be07d2745a01aecf2f2872
MD5 330c1e45cbe528bf770092ecc81af570
BLAKE2b-256 f4e10d4f03d763758774812868e9fbcca8fce11c1881edfe1cddfe864f2cecac

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