Prerequisites
Before sending your first email, make sure you have:- A verified sending domain with DKIM and SPF records configured
- An API key with sending permissions
- At least one of
htmlortextcontent prepared for your email
Basic Email
Send a simple email with minimal configuration:Email Options
| Parameter | Type | Required | Description |
|---|---|---|---|
from | string | Yes | Sender email address (must be from verified domain) |
from_name | string | No | Friendly sender name |
to | string[] | Yes | Recipient address(es), max 50 |
subject | string | Conditional | Email subject line (max 998 chars). Required unless template_slug is provided — when omitted with a template, the template’s stored subject is used (or the template name if no subject is set). |
html | string | No* | HTML content |
text | string | No* | Plain text content |
amp_html | string | No | AMP HTML content |
cc | string[] | No | CC recipients |
bcc | string[] | No | BCC recipients |
reply_to | string | No | Reply-to address |
reply_to_name | string | No | Reply-to display name |
attachments | array | No | File attachments |
options | object | No | Tracking and sending options |
tag | string | No | Tag for analytics grouping (max 64 chars) |
metadata | object | No | Custom metadata (available in webhooks) |
headers | object | No | Custom email headers (max 10, max 998 chars per value). See Custom Headers. |
substitution_data | object | No | Variables for template substitution |
template_slug | string | No | Template slug to use for email content |
template_version | integer | No | Specific template version to use |
project_id | integer | No | Project to associate with this email |
html, text, or template_slug is required.
Response
request_id uniquely identifies this send request. Store it to track delivery status, correlate with webhook events, and debug issues. See Idempotency for patterns to prevent duplicate sends.
Transactional vs. Marketing Emails
Lettr handles both transactional and marketing emails through the same API, but the two have different characteristics and best practices. Transactional emails are triggered by a user action — password resets, order confirmations, shipping notifications, account alerts. They are expected by the recipient and typically have high open rates. Marketing emails are sent proactively — newsletters, promotions, product announcements. They require clear unsubscribe mechanisms and careful list management. Use thetransactional option to signal the email type:
Transactional emails typically have higher deliverability. Separating transactional and marketing email on different sending domains or subdomains is a common practice to protect your transactional sender reputation. See Best Practices for domain warm-up and reputation guidance.
Unsubscribe Handling
When you send a marketing email (transactional: false), Lettr automatically adds the List-Unsubscribe and List-Unsubscribe-Post headers. This enables one-click unsubscribe in email clients that support it (Gmail, Apple Mail, Outlook, etc.), which is required by major mailbox providers.
For an HTML unsubscribe link in the email body, add the data-msys-unsubscribe="1" attribute to your link. The URL should point to a simple “Sorry to see you go” page — Lettr handles the unsubscribe automatically:
list_unsubscribe or link_unsubscribe webhook event, which you should use to update subscription state in your application.
Common Sending Patterns
Personalized Emails with Merge Tags
Usesubstitution_data to personalize content for each recipient. Lettr’s template language supports variables, conditionals, and loops:
Sending with Templates
Instead of inline HTML, reference a template created in the Lettr dashboard or via the API:Tracking and Metadata
Attach metadata for analytics and debugging, and control tracking per email:Sending to Multiple Recipients
Send to up to 50 recipients per API call. Usesubstitution_data to personalize content with merge tags that apply to all recipients:
Error Handling
The API returns structured errors to help you diagnose issues:invalid_domain), unconfigured domains (unconfigured_domain), validation failures (validation_error), and template errors (template_not_found). Server errors (5xx) are safe to retry with exponential backoff, while client errors (4xx) should not be retried.
See Errors & Retries for a complete error code reference and retry patterns.
Next Steps
Once you’re sending emails, there are three systems you should configure to complete your integration:- Webhooks — Push real-time delivery, bounce, open, and click notifications to your server so you can react to events as they happen
- Analytics — Aggregate dashboards for monitoring delivery rates and engagement trends over time
- Suppressions — Automatically manage bounced and unsubscribed addresses to protect your sender reputation
Learn More
Content Types
HTML, plain text, and AMP email content
Template Language
Personalize your emails with merge tags
Attachments
Add files to your emails
Integrations
Send from Stripe, Supabase, or WordPress