List Threads
GET /api/e2/mail/threads
List email threads (conversations) for your inbox with cursor-based pagination. This is the primary endpoint for building an inbox UI.
What is a Thread?
A thread groups related emails together based on the In-Reply-To and References headers, similar to how Gmail groups conversations. Each thread contains both inbound (received) and outbound (sent) messages.
Use with /mail/threads/:id:
Use this endpoint to list threads, then use GET /mail/threads/:id to fetch all messages in a specific thread.
Query Parameters
Maximum number of threads to return (1-100).
Cursor for pagination. Pass the thread ID from
pagination.next_cursor of the previous response to get the next page.Search query to filter threads by subject or participant emails. Case-insensitive partial match.
Filter by unread status. Set to
true to only return threads with unread messages.Filter threads by domain. Accepts domain ID (e.g.,
dom_xxx) or domain name (e.g., example.com).Returns threads where any participant email matches the domain.Filter threads by email address. Accepts address ID (e.g.,
addr_xxx) or raw email address.Returns threads where the address is a participant.Response
Array of thread objects matching the query, sorted by last message date (newest first).
Pagination metadata for cursor-based pagination.
Applied filters for this query.
Get Thread
GET /api/e2/mail/threads/:id
Retrieve a complete email thread (conversation) with all messages.
What You Get:
- Thread metadata (subject, participants, timestamps)
- All messages in the thread (both inbound and outbound)
- Messages sorted chronologically by thread position
inbound- Emails you receivedoutbound- Emails you sent (includes delivery status)
Response
Thread metadata.
Array of all messages in the thread, sorted by thread position (chronological).
Total number of messages returned.
Threading Logic
Email threads are created automatically based on standard email headers:Thread Grouping Rules
- In-Reply-To Header: Links a message to its parent
- References Header: Contains the full chain of Message-IDs
- Normalized Subject: Fallback grouping by subject (with Re:, Fwd: stripped)
Example Thread Structure
Building an Inbox UI
Step 1: List Threads
Use/mail/threads to display a thread list (like Gmail’s inbox):
Step 2: Display Thread
When user clicks a thread, use/mail/threads/:id to show all messages:
Step 3: Reply to Thread
Use/emails/:id/reply to reply within the thread: