Email Logs
Email logs
List and retrieve email sending logs for the account.
Returns a paginated list of email logs (messages) for the account. Results are restricted to domains the authenticated token has access to. Invalid or unknown filters are ignored. Results are ordered by sent_at descending.
API token in Api-Token header
Cursor for the next page (message_id UUID from previous response next_page_cursor).
Success
Total number of messages matching the filters (before pagination).
Message UUID to use as search_after for the next page. Null if no more pages.
Bad request - invalid parameters.
Returns unauthorized error message. Check your credentials.
Resource not found
Rate limit exceeded for the current account.
curl -X GET -g 'https://mailtrap.io/api/email_logs?filters[sent_after]=2025-01-01T00:00:00Z&filters[sent_before]=2025-01-31T23:59:59Z&filters[to][operator]=ci_equal&filters[to][value]=recipient@example.com&filters[domain_id][operator]=equal&filters[domain_id][value][]=3938&filters[domain_id][value][]=3939' \
-H 'Authorization: Bearer YOUR_API_KEY'
{
"messages": [
{
"message_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "delivered",
"subject": "Welcome to our service",
"from": "sender@example.com",
"to": "recipient@example.com",
"sent_at": "2025-01-15T10:30:00Z",
"client_ip": "203.0.113.42",
"category": "Welcome Email",
"custom_variables": {},
"sending_stream": "transactional",
"domain_id": 3938,
"template_id": 100,
"template_variables": {},
"opens_count": 2,
"clicks_count": 1
},
{
"message_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
"status": "delivered",
"subject": "Your order confirmation",
"from": "orders@example.com",
"to": "customer@example.com",
"sent_at": "2025-01-15T11:00:00Z",
"client_ip": null,
"category": "Order Confirmation",
"custom_variables": {
"order_id": "12345"
},
"sending_stream": "transactional",
"domain_id": 3938,
"template_id": null,
"template_variables": {},
"opens_count": 0,
"clicks_count": 0
}
],
"total_count": 150,
"next_page_cursor": "b2c3d4e5-f6a7-8901-bcde-f12345678901"
}Returns a single message by message UUID. Message must belong to the account and a domain the token can access.
API token in Api-Token header
Message UUID
Success
Value of the RFC 5322 Message-ID header.
Value of the RFC 5322 In-Reply-To header.
Values of the RFC 5322 References header.
ID of the inbound thread this message belongs to, or null if the message is not part of one. Use it with the Inbound Threads endpoints to fetch the full conversation.
Signed URL to download raw .eml message (temporary).
Returns unauthorized error message. Check your credentials.
Resource not found
Rate limit exceeded for the current account.
curl -X GET 'https://mailtrap.io/api/email_logs/{sending_message_id}' \
-H 'Authorization: Bearer YOUR_API_KEY'
{
"message_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "delivered",
"subject": "Welcome to our service",
"from": "sender@example.com",
"to": "recipient@example.com",
"sent_at": "2025-01-15T10:30:00Z",
"client_ip": "203.0.113.42",
"category": "Welcome Email",
"custom_variables": {},
"sending_stream": "transactional",
"domain_id": 3938,
"template_id": 100,
"template_variables": {},
"opens_count": 2,
"clicks_count": 1,
"raw_message_url": "https://storage.example.com/signed/eml/a1b2c3d4-e5f6-7890-abcd-ef1234567890?token=...",
"events": [
{
"event_type": "click",
"created_at": "2025-01-15T10:35:00Z",
"details": {
"click_url": "https://example.com/track/click/abc123",
"web_ip_address": "198.51.100.50"
}
},
{
"event_type": "spam",
"created_at": "2025-01-15T10:40:00Z",
"details": {
"spam_feedback_type": "abuse"
}
}
]
}Last updated
Was this helpful?

