Posthawk
SDK

Python
SDK

The official Posthawk SDK for Python. Built on httpx with typed dataclass responses and a simple result pattern. Send your first email in under a minute.

$ pip install posthawkposthawk
Simple API

Send emails with
five lines of code

Initialize the client, call send, and check the result. Every method returns a PosthawkResponse with .data and .error.

Python
from posthawk import Posthawkclient = Posthawk("ck_live_...")result = client.emails.send(    from_email="hello@yourdomain.com",    to="user@example.com",    subject="Welcome!",    html="<h1>Hello!</h1>",)if result.error:    print(result.error.message)else:    print("Sent!", result.data.job_id)
Error Handling
from posthawk import Posthawkclient = Posthawk("ck_live_...")# Every method returns PosthawkResponseresult = client.emails.send(    from_email="hello@yourdomain.com",    to="user@example.com",    subject="Test",    html="<p>Hello</p>",)if result.error:    print(f"Error {result.error.status_code}: {result.error.message}")else:    print(f"Job ID: {result.data.job_id}")    print(f"Status URL: {result.data.status_url}")
Result Pattern

No try/except
needed

SDK methods never raise exceptions for API errors. Check result.error first, then access result.data safely.

Scheduling

Schedule, cancel,
and reschedule

Send later by adding scheduled_for. Full management API to list, cancel, or change the send time. Accepts datetime objects or ISO strings.

Python
# Schedule for laterfrom datetime import datetime, timedelta, timezoneresult = client.emails.send(    from_email="hello@yourdomain.com",    to="user@example.com",    subject="Reminder",    text="Don't forget your meeting!",    scheduled_for=datetime.now(timezone.utc) + timedelta(hours=24),)# Manage scheduled emailsresult = client.scheduled.list(status="scheduled")client.scheduled.cancel("id")client.scheduled.reschedule(    "id", scheduled_for="2026-04-01T10:00:00Z")
Getting started

Up and running
in minutes

01

Install the package

One command to add Posthawk to your project. Only requires httpx as a dependency.

02

Create a client

Initialize with your API key. The SDK handles auth headers, serialization, and error wrapping.

03

Send your first email

Call client.emails.send() with your content. Get back a typed dataclass with delivery status.

Dataclass Responses

Every response is a typed dataclass with .data and .error attributes. Full IDE autocomplete out of the box.

httpx Powered

Built on httpx with connection pooling and a 30s timeout. Context manager support for clean resource cleanup.

Schedule Emails

Schedule, list, cancel, and reschedule emails. Accepts datetime objects or ISO 8601 strings.

Never Raises

Every method returns PosthawkResponse with .data and .error — no try/except needed. Only the constructor raises for missing keys.

Start sending emails

Install the SDK and send your first email in under a minute.

Cookie Preferences

We use analytics cookies to understand how you use our site and improve your experience. Privacy Policy