Documentation
Sign inGet started

Python

Send your first email from a plain Python script using the Bird Python SDK's sync client. Three steps: install, send, run.

1. Install the SDK

Code example
pip install bird-sdk
Code example
# or
uv add bird-sdk
poetry add bird-sdk
Requires Python 3.10+. The import package is bird.

2. Send an email

Export your API key — the SDK reads BIRD_API_KEY from the environment and infers the region (us1 or eu1) from the bk_us1_ / bk_eu1_ prefix, so Bird() needs no arguments:
Code example
export BIRD_API_KEY="bk_us1_..."
Create send.py:
Code example
from bird import APIError, Bird

with Bird() as client:
    try:
        message = client.email.send(
            from_={"email": "onboarding@messagebird.dev", "name": "Bird"},
            to=["delivered@messagebird.dev"],
            subject="Hello from Bird",
            html="<p>My first Bird email.</p>",
        )
        print(message.id, message.status)
    except APIError as err:
        print("send failed:", err)
from_ is the Python spelling of the from field (from is a reserved word). onboarding@messagebird.dev is Bird's shared onboarding sender — no domain verification needed — and delivered@messagebird.dev is a sandbox recipient that always delivers.
Transient failures retry automatically, and a retried send reuses one idempotency key across attempts, so it never double-applies.

3. Run it

Code example
python send.py
The API responds with 202 — the message is accepted and delivered asynchronously:
Code example
{
  "id": "em_019c1930687b7bfa8a1b2c3d4e5f6789",
  "status": "accepted"
}
Fetch the message by its em_ id with client.email.get(message.id) and watch the status move from accepted to delivered.

Next steps