Skip to main content

unitpost

Official Unitpost SDK for Python. Send email and manage contacts, segments, campaigns, templates, domains, suppressions, and webhooks.

Install

pip install unitpost

Requires Python 3.8+.

Quick start

from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY (or pass Unitpost("up_..."))

result = unitpost.email.send({
    "from": "Acme <you@yourdomain.com>",  # bare address works too
    "to": "customer@example.com",
    "subject": "Hello",
    "html": "<p>It works!</p>",
})

if result.error:
    print(result.error.code, result.error.message)
else:
    print("sent", result.data["id"])

Every method returns a Result with .data and .error. An API-level failure populates .error (a UnitpostError) instead of raising.

Authentication

Pass the key to Unitpost(...), or set UNITPOST_API_KEY. Create a key at unitpost.com → Settings → API keys.

Client surface

Accessor Covers
email Send, batch, list, get, update, stats, inbound (received_*)
email.topics Topics + contact topic prefs
email.campaigns Draft, schedule, send, pause/resume
email.templates Template CRUD
email.domains Domains + verify
contacts CRUD, import jobs
contact_fields Custom field definitions
segments Segments + membership
brand_kits Brand kit
webhooks Endpoints + verify()
api_keys API key management
suppressions Suppression list
usage Billing-period usage snapshot

Pagination

for contact in unitpost.contacts.list_all():
    print(contact["email"])

Suppressions

The suppression list holds addresses excluded from every send — single, batch, and campaign, including cc/bcc — case-insensitively. Hard bounces and spam complaints are added automatically; you can also add your own:

# Suppress one address, or many in a single call (idempotent — re-adding is a no-op).
unitpost.suppressions.create({"email": "bounced@example.com", "reason": "manual"})
unitpost.suppressions.create({"emails": ["a@example.com", "b@example.com"]})

# Look one up by id or email; list (optionally filter scope); un-suppress.
unitpost.suppressions.get("bounced@example.com")
for s in unitpost.suppressions.list_all():
    print(s["email"], s["reason"])
unitpost.suppressions.delete("bounced@example.com")

reason accepts manual, import, or api — the engine-written bounce and complaint reasons are read-only. Unitpost-wide (platform) entries are visible but can't be removed via the API.

Verifying webhooks

from unitpost import verify_webhook

event = verify_webhook(
    payload=raw_body,          # the raw request body (str or bytes)
    secret=os.environ["UNITPOST_WEBHOOK_SECRET"],
    headers=request.headers,
)

Or from the client (Resend-style alias):

event = client.webhooks.verify(payload=raw_body, secret=secret, headers=request.headers)

Idempotency

email.send and email.batch are safe to retry by default — if you don't pass idempotency_key, the SDK generates one so an automatic retry can't double-send. Pass your own to dedupe across separate calls:

unitpost.email.send({...}, idempotency_key="...")
unitpost.email.batch([...], idempotency_key="...")

The server dedupes on (workspace, idempotency key) for 24h and replays the original result instead of re-sending (the email id for a send, the full list envelope for a batch).

Retries

Transient failures are retried automatically: 429, 5xx, and transport errors (timeouts / network) retry up to max_retries times (default 2). A 429/503 Retry-After is honored; otherwise exponential backoff with full jitter is used. Client errors (401/403/404/409/422) are never retried. Only requests safe to replay are retried: GETs and writes carrying an idempotency key (which email.send and email.batch always do); any other keyless write is never auto-retried.

# Defaults shown; set max_retries=0 to disable.
unitpost = Unitpost(max_retries=2, retry_base_delay=0.5, max_retry_delay=20.0)

Resources

Docs + API reference https://www.unitpost.com/docs
Product / SMTP / MCP guides https://www.unitpost.com/guides
OpenAPI JSON https://www.unitpost.com/api/v1/openapi.json
LLM index https://www.unitpost.com/llms.txt
Dashboard / API keys https://www.unitpost.com
Email components (@unitpost/email) https://www.unitpost.com/components
Template gallery https://www.unitpost.com/templates/gallery
Playground https://www.unitpost.com/playground
Migration Assistant https://www.unitpost.com/migration
MCP + Agent Skills https://www.unitpost.com/guides#ai-mcp · https://www.unitpost.com/guides#ai-skills
Support support@unitpost.com

License

MIT

Metadata

Release files for unitpost 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unitpost 0.3.0
File Size Uploaded Provenance Actions
unitpost-0.3.0.tar.gz 19.0 kB Without provenance Details for unitpost-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unitpost 0.3.0
File Interpreter ABI Platform Actions
unitpost-0.3.0-py3-none-any.whl Python 3 none any Details for unitpost-0.3.0-py3-none-any.whl

Total release size: 38.2 kB

Release files / unitpost-0.3.0.tar.gz

Download URL unitpost-0.3.0.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
edcac3c073ae5a8caab0d8859008978cd7b1075f31ee109d39d04de618381bfb
BLAKE2b-256 checksum
How to use checksums
0201a0328f80cb194b8fb69b51dc0d6e14c7b2888faefb75de0ea1d22e568282
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / unitpost-0.3.0-py3-none-any.whl

Download URL unitpost-0.3.0-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc64165834ec2b3c05a27b595a25ad909e7663d8f502820e99c581916b0dd363
BLAKE2b-256 checksum
How to use checksums
3f7f6f695a3e32efb855991756c4d2736bc8998746138606b7796e9c1ddcba52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for unitpost 0.3.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page