Skip to content

lettr-com/lettr-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lettr for Python SDK

The official Python SDK for the Lettr Email API. A clean, typed client for emails, templates, domains, webhooks, audience, and campaigns — methods raise typed exceptions on failure.

Installation

pip install lettr

Quick Start

import lettr

client = lettr.Lettr("lttr_your_api_key")

response = client.emails.send(
    from_email="you@example.com",
    to=["user@example.com"],
    subject="Hello from Lettr!",
    html="<h1>Welcome!</h1>",
)

print(response.request_id)

Use the client as a context manager to close the connection pool automatically:

with lettr.Lettr("lttr_your_api_key") as client:
    client.emails.send(from_email="you@example.com", to=["user@example.com"],
                       subject="Hello!", html="<p>Hello!</p>")

Error Handling

The SDK raises typed exceptions — all subclasses of lettr.LettrError:

try:
    client.emails.send(from_email="you@example.com", to=["user@example.com"],
                       subject="Hello", html="<p>Hello!</p>")
except lettr.ValidationError as e:
    print(e.message, e.errors)
except lettr.LettrError as e:
    print(e.message)

See Error Handling for the full exception hierarchy.

Documentation

Full guides for every resource, with complete request/response details, live in the docs:

📚 docs.lettr.com/quickstart/python

Topic Guide
Install, client setup, sending Quickstart
Async, Django, error handling, type hints Advanced
Manage Lettr templates & merge tags Templates
Add, verify, and manage sending domains Domains
Webhook endpoints for delivery & engagement events Webhooks
Lists, contacts, topics, properties, segments Audience
List, send, and schedule campaigns Campaigns
Flask & FastAPI integration Flask · FastAPI
Endpoint reference (params & schemas) API Reference

Requirements

  • Python 3.8+
  • httpx (installed automatically)

License

MIT