Skip to main content

Email Logs Guide

The Email Logs API provides access to detailed delivery status and activity information for all emails sent through EDITH.


Overview

Email logs allow you to:

  • Track email delivery status
  • View open and click activity
  • Debug delivery issues
  • Generate reports and analytics
  • Monitor campaign performance

Get Email Logs

Endpoint

GET /v1/email/logs

Authentication

Requires Bearer token authentication.

Query Parameters

All parameters are optional and can be combined for precise filtering:

ParameterTypeDescription
emailstringFilter by recipient email address (exact match)
recipientDomainstringFilter by recipient's email domain (exact match)
refIdstringFilter by email reference ID (returned when sending)
statusstringFilter by delivery status
fromAddressstringFilter by sender email address (exact match)
subjectstringFilter by email subject (exact match)
campaignIdstringFilter by campaign ID
recipientTypestringFilter by recipient type: "to", "cc", "bcc"
failedReasonstringFilter by failure reason
startCreatedAtstringStart date for creation date filter (RFC3339 format)
endCreatedAtstringEnd date for creation date filter (RFC3339 format)
startDeliveredDatestringStart date for delivery date filter (RFC3339 format)
endDeliveredDatestringEnd date for delivery date filter (RFC3339 format)
pageSizeintegerNumber of results per page (default: 20, max: 50)
pageTokenstringToken for pagination

Email Status Values

StatusDescription
queuedEmail is queued for sending
sentEmail sent to the mail server
deliveredEmail successfully delivered to recipient's inbox
openedRecipient opened the email (if tracking enabled)
clickedRecipient clicked a link (if tracking enabled)
bouncedEmail bounced (soft or hard)
failedEmail failed to send
spamEmail marked as spam
unsubscribedRecipient unsubscribed

Example Requests

Get All Logs (Paginated)

curl -X GET "https://api.edith.example.com/v1/email/logs?pageSize=20" \
-H "Authorization: Bearer YOUR_TOKEN"

Filter by Recipient Email

curl -X GET "https://api.edith.example.com/v1/email/logs?email=customer@example.com" \
-H "Authorization: Bearer YOUR_TOKEN"

Filter by Status

curl -X GET "https://api.edith.example.com/v1/email/logs?status=bounced" \
-H "Authorization: Bearer YOUR_TOKEN"

Filter by Campaign

curl -X GET "https://api.edith.example.com/v1/email/logs?campaignId=welcome-series-2024" \
-H "Authorization: Bearer YOUR_TOKEN"

Filter by Date Range

curl -X GET "https://api.edith.example.com/v1/email/logs?startCreatedAt=2024-01-01T00:00:00Z&endCreatedAt=2024-01-31T23:59:59Z" \
-H "Authorization: Bearer YOUR_TOKEN"

Filter by Reference ID

curl -X GET "https://api.edith.example.com/v1/email/logs?refId=01JC3BBW8S9YGX2VNKG5MD7BTA" \
-H "Authorization: Bearer YOUR_TOKEN"

Combine Multiple Filters

curl -X GET "https://api.edith.example.com/v1/email/logs?campaignId=promo-jan&status=delivered&startCreatedAt=2024-01-15T00:00:00Z" \
-H "Authorization: Bearer YOUR_TOKEN"

Response Format

{
"success": true,
"emailLogs": [
{
"refId": "01JC3BBW8S9YGX2VNKG5MD7BTA",
"accountId": 12345,
"tenantId": 67890,
"fromAddress": "notifications@mail.yourcompany.com",
"recipientAddress": "customer@example.com",
"recipientDomain": "example.com",
"recipientType": "to",
"subject": "Your Order Confirmation",
"status": "delivered",
"priority": "normal",
"campaignId": "order-confirmation",
"opened": true,
"clicked": true,
"failedReason": null,
"createdAt": "2024-01-15T10:30:00Z",
"deliveredDate": "2024-01-15T10:30:05Z",
"updatedAt": "2024-01-15T11:45:00Z",
"track": {
"opens": [
{
"timestamp": "2024-01-15T11:00:00Z",
"userAgent": "Mozilla/5.0...",
"ip": "192.168.1.1"
}
],
"clicks": [
{
"timestamp": "2024-01-15T11:05:00Z",
"url": "https://yourcompany.com/orders/12345",
"userAgent": "Mozilla/5.0...",
"ip": "192.168.1.1"
}
]
}
}
],
"nextPageToken": "eyJJZCI6IjAxSkM0...",
"totalCount": 150
}

Response Fields Explained

Email Log Entry

FieldTypeDescription
refIdstringUnique reference ID for this email (returned when sending)
accountIdintegerYour account identifier
tenantIdintegerTenant/organization identifier
fromAddressstringSender email address
recipientAddressstringRecipient email address
recipientDomainstringDomain portion of recipient email
recipientTypestringHow recipient was addressed: "to", "cc", "bcc"
subjectstringEmail subject line
statusstringCurrent delivery status
prioritystringEmail priority: "normal" or "high"
campaignIdstringCampaign identifier (if provided when sending)
openedbooleanWhether email has been opened (if tracking enabled)
clickedbooleanWhether any links were clicked (if tracking enabled)
failedReasonstringReason for failure (if status is failed/bounced)
createdAtstringWhen the email was created (RFC3339)
deliveredDatestringWhen the email was delivered (RFC3339)
updatedAtstringLast update timestamp (RFC3339)
trackobjectDetailed tracking events (opens, clicks)

Track Object

FieldTypeDescription
opensarrayList of open events with timestamp, userAgent, and IP
clicksarrayList of click events with timestamp, URL, userAgent, and IP

Pagination

The API uses cursor-based pagination for efficient handling of large result sets.

Initial Request

curl -X GET "https://api.edith.example.com/v1/email/logs?pageSize=50" \
-H "Authorization: Bearer YOUR_TOKEN"

Next Page

Use the nextPageToken from the previous response:

curl -X GET "https://api.edith.example.com/v1/email/logs?pageSize=50&pageToken=eyJJZCI6IjAxSkM0..." \
-H "Authorization: Bearer YOUR_TOKEN"

Pagination Tips

  • Maximum pageSize is 50
  • nextPageToken is null when no more results
  • Tokens are short-lived; don't cache them for extended periods
  • Total count may be approximate for very large datasets

Use Cases

1. Track Specific Email Delivery

# Using the ref_id from send response
curl -X GET "https://api.edith.example.com/v1/email/logs?refId=01JC3BBW8S9YGX2VNKG5MD7BTA" \
-H "Authorization: Bearer YOUR_TOKEN"

2. Find Bounced Emails

curl -X GET "https://api.edith.example.com/v1/email/logs?status=bounced&pageSize=50" \
-H "Authorization: Bearer YOUR_TOKEN"

3. Campaign Performance

curl -X GET "https://api.edith.example.com/v1/email/logs?campaignId=black-friday-2024" \
-H "Authorization: Bearer YOUR_TOKEN"

4. Recipient History

curl -X GET "https://api.edith.example.com/v1/email/logs?email=important-customer@company.com" \
-H "Authorization: Bearer YOUR_TOKEN"

5. Domain-Wide Issues

# Check if emails to a specific domain are failing
curl -X GET "https://api.edith.example.com/v1/email/logs?recipientDomain=problematic-domain.com&status=failed" \
-H "Authorization: Bearer YOUR_TOKEN"

6. Recent Failures

curl -X GET "https://api.edith.example.com/v1/email/logs?status=failed&startCreatedAt=2024-01-15T00:00:00Z" \
-H "Authorization: Bearer YOUR_TOKEN"

Best Practices

1. Use Specific Filters

Narrow down results to improve performance:

# Good: Specific filters
?campaignId=promo-jan&status=delivered&startCreatedAt=2024-01-01T00:00:00Z

# Avoid: No filters on large datasets
?pageSize=50

2. Store Reference IDs

When sending emails, store the ref_id for easy lookup:

const response = await sendEmail(payload);
await database.saveEmailRecord({
orderId: order.id,
emailRefId: response.ref_id,
sentAt: new Date()
});

3. Use Campaign IDs Consistently

Tag emails with meaningful campaign IDs:

const payload = {
// ... email content
campaign_id: `${emailType}-${year}-${quarter}`
// e.g., "welcome-2024-q1", "invoice-2024-q1"
};

4. Handle Pagination Properly

async function getAllBouncedEmails() {
const allLogs = [];
let pageToken = null;

do {
const params = new URLSearchParams({
status: 'bounced',
pageSize: '50'
});
if (pageToken) params.set('pageToken', pageToken);

const response = await fetch(
`https://api.edith.example.com/v1/email/logs?${params}`,
{ headers: { 'Authorization': `Bearer ${token}` } }
);
const data = await response.json();

allLogs.push(...data.emailLogs);
pageToken = data.nextPageToken;
} while (pageToken);

return allLogs;
}

5. Monitor Failed Emails

Set up regular checks for failures:

// Daily bounce report
const yesterday = new Date(Date.now() - 86400000).toISOString();
const bouncedEmails = await getEmailLogs({
status: 'bounced',
startCreatedAt: yesterday
});

if (bouncedEmails.length > threshold) {
alertOps('High bounce rate detected');
}

Common Errors

ErrorCauseSolution
Bad RequestInvalid query parametersCheck parameter format
Invalid date formatWrong date formatUse RFC3339 (e.g., 2024-01-15T10:30:00Z)
Page token expiredToken too oldStart pagination from beginning
UnauthorizedInvalid tokenRefresh authentication token