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

const inbound = new Inbound('YOUR_API_KEY')

const { data: thread, error } = await inbound.thread.get('thread_abc123')

if (error) {
  console.error('Error:', error)
} else {
  console.log(`Thread: ${thread.thread.normalizedSubject}`)
  console.log(`Messages: ${thread.messages.length}`)
  console.log(`Participants: ${thread.thread.participantEmails.join(', ')}`)
}
{
  "thread": {
    "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",
    "updatedAt": "2024-01-15T14:30:00Z"
  },
  "messages": [
    {
      "id": "email_123",
      "messageId": "<msg123@example.com>",
      "type": "inbound",
      "threadPosition": 1,
      "subject": "Support Request - Login Issues",
      "textBody": "I'm having trouble logging into my account...",
      "htmlBody": "<p>I'm having trouble logging into my account...</p>",
      "from": "John Doe <customer@example.com>",
      "fromName": "John Doe",
      "fromAddress": "customer@example.com",
      "to": ["support@yourdomain.com"],
      "cc": [],
      "bcc": [],
      "date": "2024-01-15T10:00:00Z",
      "receivedAt": "2024-01-15T10:00:00Z",
      "sentAt": null,
      "isRead": true,
      "readAt": "2024-01-15T10:05:00Z",
      "hasAttachments": false,
      "attachments": [],
      "inReplyTo": null,
      "references": [],
      "headers": {},
      "tags": []
    },
    {
      "id": "sent_456",
      "messageId": "<reply456@yourdomain.com>",
      "type": "outbound",
      "threadPosition": 2,
      "subject": "Re: Support Request - Login Issues",
      "textBody": "Thank you for contacting support. We've reset your password...",
      "htmlBody": "<p>Thank you for contacting support. We've reset your password...</p>",
      "from": "Support Team <support@yourdomain.com>",
      "fromName": "Support Team",
      "fromAddress": "support@yourdomain.com",
      "to": ["customer@example.com"],
      "cc": [],
      "bcc": [],
      "date": "2024-01-15T11:30:00Z",
      "receivedAt": null,
      "sentAt": "2024-01-15T11:30:00Z",
      "isRead": true,
      "readAt": null,
      "hasAttachments": false,
      "attachments": [],
      "inReplyTo": "<msg123@example.com>",
      "references": ["<msg123@example.com>"],
      "headers": {},
      "tags": [{"name": "category", "value": "support"}],
      "status": "sent"
    }
  ],
  "totalCount": 3
}

Overview

This endpoint retrieves all messages in a specific email thread, providing a complete conversation history. Messages are returned in chronological order with both inbound (received) and outbound (sent) emails included.

Authentication

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

Path Parameters

id
string
required
The unique identifier of the thread to retrieve.

Response

thread
object
required
Thread metadata and summary information.
messages
array
required
Array of all messages in the thread, sorted by thread position (chronological order).
totalCount
integer
required
Total number of messages in the thread.

Examples

Request

import { Inbound } from '@inboundemail/sdk'

const inbound = new Inbound('YOUR_API_KEY')

const { data: thread, error } = await inbound.thread.get('thread_abc123')

if (error) {
  console.error('Error:', error)
} else {
  console.log(`Thread: ${thread.thread.normalizedSubject}`)
  console.log(`Messages: ${thread.messages.length}`)
  console.log(`Participants: ${thread.thread.participantEmails.join(', ')}`)
}

Response

{
  "thread": {
    "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",
    "updatedAt": "2024-01-15T14:30:00Z"
  },
  "messages": [
    {
      "id": "email_123",
      "messageId": "<msg123@example.com>",
      "type": "inbound",
      "threadPosition": 1,
      "subject": "Support Request - Login Issues",
      "textBody": "I'm having trouble logging into my account...",
      "htmlBody": "<p>I'm having trouble logging into my account...</p>",
      "from": "John Doe <customer@example.com>",
      "fromName": "John Doe",
      "fromAddress": "customer@example.com",
      "to": ["support@yourdomain.com"],
      "cc": [],
      "bcc": [],
      "date": "2024-01-15T10:00:00Z",
      "receivedAt": "2024-01-15T10:00:00Z",
      "sentAt": null,
      "isRead": true,
      "readAt": "2024-01-15T10:05:00Z",
      "hasAttachments": false,
      "attachments": [],
      "inReplyTo": null,
      "references": [],
      "headers": {},
      "tags": []
    },
    {
      "id": "sent_456",
      "messageId": "<reply456@yourdomain.com>",
      "type": "outbound",
      "threadPosition": 2,
      "subject": "Re: Support Request - Login Issues",
      "textBody": "Thank you for contacting support. We've reset your password...",
      "htmlBody": "<p>Thank you for contacting support. We've reset your password...</p>",
      "from": "Support Team <support@yourdomain.com>",
      "fromName": "Support Team",
      "fromAddress": "support@yourdomain.com",
      "to": ["customer@example.com"],
      "cc": [],
      "bcc": [],
      "date": "2024-01-15T11:30:00Z",
      "receivedAt": null,
      "sentAt": "2024-01-15T11:30:00Z",
      "isRead": true,
      "readAt": null,
      "hasAttachments": false,
      "attachments": [],
      "inReplyTo": "<msg123@example.com>",
      "references": ["<msg123@example.com>"],
      "headers": {},
      "tags": [{"name": "category", "value": "support"}],
      "status": "sent"
    }
  ],
  "totalCount": 3
}

Error Responses

{
  "error": "Thread not found"
}