Overview
This endpoint provides detailed statistics about email threading for your account, including thread distribution, activity metrics, and unread counts. Useful for building analytics dashboards and understanding email patterns.
Authentication
Bearer token for API authentication. Format: Bearer YOUR_API_KEY
Response
Total number of email threads in the account.
Total number of messages (inbound + outbound) across all threads.
Average number of messages per thread (rounded to 2 decimal places).
Information about the thread with the most messages. Show Most active thread properties
Unique identifier of the most active thread.
Number of messages in the most active thread.
Subject line of the most active thread.
ISO 8601 timestamp of the last activity in this thread.
Statistics about recent threading activity. Show Recent activity properties
Number of threads that were active today (had new messages).
Number of messages received today.
Number of threads that were active in the last 7 days.
Number of messages received in the last 7 days.
Distribution of threads by message count. Show Distribution properties
Number of threads with exactly 1 message (no replies).
Number of threads with 2-5 messages.
Number of threads with 6-15 messages.
Number of threads with 16 or more messages.
Statistics about unread messages and threads. Show Unread statistics properties
Number of threads that contain at least one unread message.
Total number of unread messages across all threads.
Examples
Request
import { Inbound } from '@inboundemail/sdk'
const inbound = new Inbound ( 'YOUR_API_KEY' )
const { data : stats , error } = await inbound . thread . getStats ()
if ( error ) {
console . error ( 'Error:' , error )
} else {
console . log ( `Total threads: ${ stats . totalThreads } ` )
console . log ( `Average messages per thread: ${ stats . averageMessagesPerThread } ` )
console . log ( `Unread threads: ${ stats . unreadStats . unreadThreads } ` )
}
Response
{
"totalThreads" : 45 ,
"totalMessages" : 178 ,
"averageMessagesPerThread" : 3.96 ,
"mostActiveThread" : {
"threadId" : "thread_abc123" ,
"messageCount" : 12 ,
"subject" : "Ongoing Support Issue" ,
"lastMessageAt" : "2024-01-15T14:30:00Z"
},
"recentActivity" : {
"threadsToday" : 5 ,
"messagesToday" : 12 ,
"threadsThisWeek" : 18 ,
"messagesThisWeek" : 67
},
"distribution" : {
"singleMessageThreads" : 28 ,
"shortThreads" : 12 ,
"mediumThreads" : 4 ,
"longThreads" : 1
},
"unreadStats" : {
"unreadThreads" : 8 ,
"unreadMessages" : 15
}
}
Error Responses
401 Unauthorized
500 Internal Server Error
{
"error" : "Unauthorized"
}