GET
/
api
/
v2
/
threads
import { Inbound } from '@inboundemail/sdk'

const inbound = new Inbound('YOUR_API_KEY')

const { data: threads, error } = await inbound.thread.list()

if (error) {
  console.error('Error:', error)
} else {
  console.log(`Found ${threads.threads.length} threads`)
  console.log(`Total: ${threads.pagination.total}`)
}
{
  "threads": [
    {
      "id": "thread_abc123",
      "rootMessageId": "<msg123@example.com>",
      "normalizedSubject": "Support Request - Login Issues",
      "participantEmails": ["customer@example.com", "support@yourdomain.com"],
      "messageCount": 3,
      "lastMessageAt": "2024-01-15T14:30:00Z",
      "createdAt": "2024-01-15T10:00:00Z",
      "hasUnread": true,
      "isArchived": false,
      "latestMessage": {
        "id": "email_789",
        "type": "inbound",
        "subject": "Re: Support Request - Login Issues",
        "fromText": "John Doe <customer@example.com>",
        "textPreview": "Thanks for the password reset. I'm still having issues...",
        "isRead": false,
        "hasAttachments": false,
        "date": "2024-01-15T14:30:00Z"
      }
    }
  ],
  "pagination": {
    "limit": 10,
    "offset": 0,
    "total": 1,
    "hasMore": false
  },
  "filters": {
    "search": "support",
    "unreadOnly": true
  }
}

Overview

This endpoint retrieves a paginated list of all email conversation threads for the authenticated user. Threads group related emails together based on Message-ID headers and subject lines, providing a conversation-based view of your emails.

Authentication

Authorization
string
required
Bearer token for API authentication. Format: Bearer YOUR_API_KEY

Query Parameters

limit
integer
default:"25"
Maximum number of threads to return per page. Range: 1-100.
offset
integer
default:"0"
Number of threads to skip for pagination. Must be non-negative.
Search query to filter threads by subject or participant email addresses.
unread
boolean
Filter threads by unread status. Set to true to only return threads with unread messages.
archived
boolean
Filter threads by archived status. Set to true to only return archived threads.

Response

threads
array
required
Array of thread objects with summary information and latest message preview.
pagination
object
required
Pagination information for the current request.
filters
object
required
Applied filter information.

Examples

Basic Request

import { Inbound } from '@inboundemail/sdk'

const inbound = new Inbound('YOUR_API_KEY')

const { data: threads, error } = await inbound.thread.list()

if (error) {
  console.error('Error:', error)
} else {
  console.log(`Found ${threads.threads.length} threads`)
  console.log(`Total: ${threads.pagination.total}`)
}

Filtered Request

import { Inbound } from '@inboundemail/sdk'

const inbound = new Inbound('YOUR_API_KEY')

const { data: threads, error } = await inbound.thread.list({
  search: 'support',
  unread: true,
  limit: 10
})

if (error) {
  console.error('Error:', error)
} else {
  console.log(`Found ${threads.threads.length} unread support threads`)
}

Response

{
  "threads": [
    {
      "id": "thread_abc123",
      "rootMessageId": "<msg123@example.com>",
      "normalizedSubject": "Support Request - Login Issues",
      "participantEmails": ["customer@example.com", "support@yourdomain.com"],
      "messageCount": 3,
      "lastMessageAt": "2024-01-15T14:30:00Z",
      "createdAt": "2024-01-15T10:00:00Z",
      "hasUnread": true,
      "isArchived": false,
      "latestMessage": {
        "id": "email_789",
        "type": "inbound",
        "subject": "Re: Support Request - Login Issues",
        "fromText": "John Doe <customer@example.com>",
        "textPreview": "Thanks for the password reset. I'm still having issues...",
        "isRead": false,
        "hasAttachments": false,
        "date": "2024-01-15T14:30:00Z"
      }
    }
  ],
  "pagination": {
    "limit": 10,
    "offset": 0,
    "total": 1,
    "hasMore": false
  },
  "filters": {
    "search": "support",
    "unreadOnly": true
  }
}

Error Responses

{
  "error": "Limit must be between 1 and 100"
}