Sendardocs
Jump to content
All guides

Send email with Python

One requests.post call — works in scripts, Django, Flask, and FastAPI alike. Allow additional time for domain verification.

Download the starter projects · View on GitHub · Check your email domain

Before you start

  1. 1

    Create a free account

    Sign up at sendar.app — the Free plan includes 3,000 emails a month (100/day) with no card and no expiry.

  2. 2

    Verify your sending domain

    On the Domains page, add the domain you'll send from and create the DNS records it shows you. Verification usually completes within minutes of the DNS propagating.

  3. 3

    Create an API key

    On the API Keys page, create a key. It's shown once — copy it somewhere safe. Keys look like sndr_… and go in the Authorization header.

Send your first email

Replace the API key and the from domain with your own — the from address must use the domain you verified.

send.py
import requests

response = requests.post(
    "https://sendar.app/api/emails",
    headers={"Authorization": "Bearer sndr_xxxxxxxxxxxx"},
    json={
      "from": "Acme <hello@acme.com>",
      "to": [
        "delivered@example.com"
      ],
      "subject": "Hello World",
      "html": "<p>It works!</p>"
    },
)

print(response.json())

Install the dependency with `pip install requests`, then run `python send.py`.

Keep the key out of your code

Read the key from the environment in real projects:

config
import os

api_key = os.environ["SENDAR_API_KEY"]

What a successful request means

A successful response includes the message ID and status. Save the ID and inspect it in the email log. Provider acceptance does not guarantee inbox delivery. Use a recipient you control for your first test.

Choose a real workflow

For a booking confirmation, include the agreed time, time zone and booking reference. For a receipt, use a confirmed payment event. For password resets, generate expiring single-use tokens in your application; Sendar transports the email and does not issue authentication tokens.

Handle errors without duplicate messages

Keep credentials server-side. Correct invalid requests before retrying. If a timeout leaves acceptance uncertain, inspect the email log before submitting the message again. Add application-level deduplication around payment and booking events.

Run the starter project

Download the starter bundle linked below for Node, Python and a Next.js server-action example. Each runs in preview mode by default. Use your own verified sender and controlled recipient when you explicitly enable live sending.

Check the result

A successful live send returns an email object; a status of sent means provider acceptance. Open the Emails page in your dashboard to see the send, its recipient, and its delivery status — provider acceptance does not guarantee inbox delivery.

If something goes wrong

CodeMeaningFix
401Missing or invalid API keyCheck the Authorization header is exactly `Bearer sndr_...` with a key from the API Keys page.
403Sending domain not verifiedThe domain in your `from` address must be added and verified (DNS records) on the Domains page first.
422Invalid request bodyProvide `from`, at least one `to` recipient, a `subject`, and `html` or `text`. The error message names the exact field.
429Plan quota reachedYou've hit your plan's monthly or daily cap (Free: 3,000/month, 100/day). Upgrade on the Pricing page or wait for the window to reset.

Where to next

  • Batch sending — POST /emails/batch delivers up to 100 emails in one request — see the API docs.
  • Scheduling — Add scheduledAt (ISO 8601) to send up to 30 days in the future (Growth plan and above).
  • Webhooks — Get notified of delivery events instead of polling — configured on the Webhooks page.
  • Pricing — 3,000 emails/month free; paid plans from $12 for 30,000 — flat caps, no overage billing.

Ready when you are.

3,000 emails a month free — no card required.

Create your account
Need a hand with your integration?Contact Sendar