lettr package gives you a Pythonic API client that works with any Python application — Django, Flask, FastAPI, or standalone scripts. It follows Python conventions and integrates seamlessly with your existing codebase.
Using Cursor? Jump straight in using this prompt
Why Use the Python SDK?
Rather than making raw HTTP requests, the SDK provides:- Type hints — Full type annotations for IDE autocompletion and type checking
- Sync and async — Both synchronous and asynchronous API clients
- Pythonic interface — Snake_case naming and Python conventions
- Error handling — Typed exceptions for different error scenarios
- Minimal dependencies — Only requires
httpxfor HTTP requests
Prerequisites
Before you begin, make sure you have:API Key
Create an API key in the Lettr dashboard
Verified Domain
Add and verify your sending domain
- Python 3.8 or later installed
- pip for package management
- A verified sending domain in your Lettr dashboard
Quick Setup
Get started in three quick steps: install, configure, and send.1
Install the SDK
httpx as a dependency. For async support, httpx’s async features are included by default.2
Create a client
3
Send your first email
request_id for tracking and the number of accepted recipients.Configuration
Environment Variables
Read your API key from an environment variable:Using python-dotenv
Load environment variables from a.env file using python-dotenv:
.env file:
Custom HTTP Client
Use a custom httpx client with custom timeouts:Async Client
Use the async client for non-blocking operations:Sending Emails
Basic HTML Email
Send a simple HTML email:With Display Name
Add a friendly display name to the sender address:Plain Text Email
Send a plain text email without HTML:Multipart Emails (HTML + Text)
Send both HTML and plain text versions for maximum compatibility:Explore the SDK
Beyond sending, the SDK manages every Lettr resource:Templates
Manage Lettr templates and merge tags
Domains
Add, verify, and manage sending domains
Webhooks
Manage webhook endpoints for delivery and engagement events
Audience
Lists, contacts, topics, properties, and segments
Campaigns
List, send, and schedule campaigns
What’s Next
Advanced Features
Multiple recipients, attachments, templates, error handling, and more
Flask Integration
Use Lettr with Flask applications
FastAPI Integration
Use Lettr with FastAPI applications
API Reference
Complete API documentation