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 | Yes | Email subject line (max 998 chars) |
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) |
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.
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