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.code, e.request_id)
# e.headers holds the response headers; e.retry_after the Retry-After
# delay in seconds, when the API sent one.
Retries
Network errors, timeouts, 408, 429 and 5xx responses are retried up to
max_retries times (default 3) with full-jitter exponential backoff. A 429
that carries Retry-After waits exactly that long (up to 60 seconds; a longer
wait is raised instead). A 429 that is a quota rather than throttling — the
monthly plan limit or the daily send cap, which carry an error code and no
Retry-After — is raised immediately, since retrying cannot lift it.
Configuration
client = PostStack(
api_key="sk_live_...",
base_url="https://api.poststack.dev", # default
timeout=30.0, # default (seconds), per attempt
max_retries=3, # default; 0 disables retrying
)
Override timeout per call:
client.emails.send({...}, timeout=60.0)
Resources
client.emails— send, get, list, cancel, reschedule, batch, events, insights, preview, spam_previewclient.domains— create, list, get, verify, update, delete, DMARC, DKIM rotation, inbox placementclient.contacts— CRUD, import, export_csv (text; optionalsegment_id), unsubscribeclient.contact_properties— custom properties, option_usageclient.segments— create, list, get, update, delete, contacts, preview, members, growth, broadcastsclient.templates— CRUD, publish, duplicate, render, presetsclient.webhooks— CRUD, test, deliveries, replay, batch_replay, rotate_secretclient.broadcasts— CRUD, send, test, variants, resend, performance, non_openers, non_clickers, end_ab_testclient.suppressions— list, add, removeclient.api_keys— CRUD, rotateclient.mailboxes— CRUD, aliases, password, filters, signature, shares, unread_summaryclient.inbound_emails— list, get, attachments, download, draft_reply, reply, forwardclient.subscription_topics— topics (get, update, list_subscribers) + contact subscriptionsclient.workflows— CRUD, graph (get_graph/put_graph/validate_graph), activate, pause, trigger, post_eventclient.notification_channels— Slack/Discord/Telegram alert channels: CRUD, test, deliveries, replayclient.signup_forms— CRUD, submitclient.email_validations— validate, validate_batch
Links
- PostStack — EU-hosted email API
- API documentation
- Pricing · Compare providers
- Migrate from Resend · from SendGrid · from Postmark
- Status · Security · DPA
License
MIT — see LICENSE.
Metadata
Release files for poststack 0.9.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 |
|---|---|---|---|---|
| poststack-0.9.0.tar.gz | 32.0 kB | Without provenance | Details for poststack-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| poststack-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for poststack-0.9.0-py3-none-any.whl |
Total release size: 68.6 kB
Release files / poststack-0.9.0.tar.gz
| Download URL | poststack-0.9.0.tar.gz |
|---|---|
| Size | 32.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af13feca76f819711d9eb5d36b1fa5934aeba423c1d10ad872482c7686e642fd
|
|
BLAKE2b-256 checksum How to use checksums |
665b260bcde2fc71ea90247890b5738dad9d80b1c4ce48fea4ca148630c0d17a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / poststack-0.9.0-py3-none-any.whl
| Download URL | poststack-0.9.0-py3-none-any.whl |
|---|---|
| Size | 36.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3791dc000966d48fad8268ed2000bf4ad0b5883d515ddb9689fb1e24a4fb65de
|
|
BLAKE2b-256 checksum How to use checksums |
8b188e27596e2db749615d4b9877c081ed31483b7aa268cf483126310b3b33da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for poststack 0.9.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.