List Emails
Retrieve a list of emails with optional filtering.
Number of emails to return. Maximum 100.
Cursor for pagination. Use the ID of the last email from the previous page.
Cursor for pagination. Use the ID of the first email from the previous page.
Filter by status: queued, sent, delivered, bounced, failed.
Filter by recipient email address.
Filter by tag (comma-separated for multiple).
Filter emails created after this ISO 8601 timestamp.
Filter emails created before this ISO 8601 timestamp.
Request
curl "https://api.lettr.dev/v1/emails?limit=10&status=delivered" \
-H "Authorization: Bearer le_xxxxxxxxxxxx"
Response
{
"object": "list",
"data": [
{
"id": "email_123abc",
"object": "email",
"from": "you@example.com",
"to": ["recipient@example.com"],
"subject": "Hello World",
"status": "delivered",
"createdAt": "2024-01-15T10:30:00Z"
},
{
"id": "email_456def",
"object": "email",
"from": "you@example.com",
"to": ["another@example.com"],
"subject": "Welcome",
"status": "delivered",
"createdAt": "2024-01-15T09:00:00Z"
}
],
"hasMore": true,
"totalCount": 150
}
// Fetch all emails using pagination
let allEmails = [];
let hasMore = true;
let cursor = null;
while (hasMore) {
const response = await lettr.emails.list({
limit: 100,
starting_after: cursor
});
allEmails = allEmails.concat(response.data);
hasMore = response.hasMore;
if (response.data.length > 0) {
cursor = response.data[response.data.length - 1].id;
}
}