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.4.0.tar.gz (15.4 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.4.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for poststack-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b3fda2e08f4709bf08044af369f6d0d62a339864fa523c511dc688060415e6af
MD5 3ffa364ad6ba7e39809937c001896b19
BLAKE2b-256 c300cbc86d343fb386ff8687f027a5ef2a2e11c5aab293d1ee28ecfd58834cd4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: poststack-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d91192aba02c558926c07dbbc6317173f5865a5a61a6fbe8c667fc2ec437cfb2
MD5 21535f6acf7bfeb5bcb84c631db4f3b8
BLAKE2b-256 b2ba5e587cfc38249a1d8260fcf945b4adb4a80a268dc31218b6e33055126dc9

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