import { CommuneClient } from 'commune-ai';
const commune = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY });
const result = await commune.threads.get('thread_f47ac10b-58cc-4372-a567-0e02b2c3d479');
for (const message of result.data) {
console.log(message.direction, message.content);
}
from commune import CommuneClient
client = CommuneClient()
result = client.threads.get("thread_f47ac10b-58cc-4372-a567-0e02b2c3d479")
for message in result.data:
print(message.direction, message.content)
get_thread(thread_id="thread_f47ac10b-58cc-4372-a567-0e02b2c3d479")
curl "https://api.commune.email/v1/threads/thread_f47ac10b-58cc-4372-a567-0e02b2c3d479/messages" \
-H "Authorization: Bearer comm_..."
commune threads get thread_f47ac10b-58cc-4372-a567-0e02b2c3d479
{
"data": [
{
"channel": "email",
"message_id": "49a3999c-0ce1-4ea6-ab68-e08a5c73e498",
"thread_id": "thread_f47ac10b-58cc-4372-a567-0e02b2c3d479",
"direction": "inbound",
"participants": [
{ "role": "sender", "identity": "customer@example.com" },
{ "role": "to", "identity": "support@mycompany.com" }
],
"content": "Hi, I need help with my order.",
"content_html": "<p>Hi, I need help with my order.</p>",
"attachments": [],
"created_at": "2026-02-25T09:00:00.000Z",
"metadata": {
"subject": "Order help",
"inbox_id": "inbox_abc123",
"domain_id": "domain_xyz789",
"delivery_status": "delivered",
"has_attachments": false,
"attachment_count": 0,
"spam_checked": true,
"spam_score": 0.02,
"spam_action": "accept",
"spam_flagged": false,
"prompt_injection_checked": true,
"prompt_injection_detected": false,
"prompt_injection_risk": "none"
}
},
{
"channel": "email",
"message_id": "7b8c9d0e-1f2a-3b4c-d5e6-f7a8b9c0d1e2",
"thread_id": "thread_f47ac10b-58cc-4372-a567-0e02b2c3d479",
"direction": "outbound",
"participants": [
{ "role": "sender", "identity": "support@mycompany.com" },
{ "role": "to", "identity": "customer@example.com" }
],
"content": "Hi! Happy to help. Your order #12345 is on its way.",
"content_html": "<p>Hi! Happy to help. Your order #12345 is on its way.</p>",
"attachments": [],
"created_at": "2026-02-25T10:30:00.000Z",
"metadata": {
"subject": "Re: Order help",
"inbox_id": "inbox_abc123",
"domain_id": "domain_xyz789",
"delivery_status": "delivered",
"has_attachments": false,
"attachment_count": 0
}
}
]
}
{
"error": "unauthorized",
"message": "Invalid or missing API key"
}
Threads
Get thread messages
Get all messages in a thread, ordered chronologically.
GET
/
v1
/
threads
/
:threadId
/
messages
import { CommuneClient } from 'commune-ai';
const commune = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY });
const result = await commune.threads.get('thread_f47ac10b-58cc-4372-a567-0e02b2c3d479');
for (const message of result.data) {
console.log(message.direction, message.content);
}
from commune import CommuneClient
client = CommuneClient()
result = client.threads.get("thread_f47ac10b-58cc-4372-a567-0e02b2c3d479")
for message in result.data:
print(message.direction, message.content)
get_thread(thread_id="thread_f47ac10b-58cc-4372-a567-0e02b2c3d479")
curl "https://api.commune.email/v1/threads/thread_f47ac10b-58cc-4372-a567-0e02b2c3d479/messages" \
-H "Authorization: Bearer comm_..."
commune threads get thread_f47ac10b-58cc-4372-a567-0e02b2c3d479
{
"data": [
{
"channel": "email",
"message_id": "49a3999c-0ce1-4ea6-ab68-e08a5c73e498",
"thread_id": "thread_f47ac10b-58cc-4372-a567-0e02b2c3d479",
"direction": "inbound",
"participants": [
{ "role": "sender", "identity": "customer@example.com" },
{ "role": "to", "identity": "support@mycompany.com" }
],
"content": "Hi, I need help with my order.",
"content_html": "<p>Hi, I need help with my order.</p>",
"attachments": [],
"created_at": "2026-02-25T09:00:00.000Z",
"metadata": {
"subject": "Order help",
"inbox_id": "inbox_abc123",
"domain_id": "domain_xyz789",
"delivery_status": "delivered",
"has_attachments": false,
"attachment_count": 0,
"spam_checked": true,
"spam_score": 0.02,
"spam_action": "accept",
"spam_flagged": false,
"prompt_injection_checked": true,
"prompt_injection_detected": false,
"prompt_injection_risk": "none"
}
},
{
"channel": "email",
"message_id": "7b8c9d0e-1f2a-3b4c-d5e6-f7a8b9c0d1e2",
"thread_id": "thread_f47ac10b-58cc-4372-a567-0e02b2c3d479",
"direction": "outbound",
"participants": [
{ "role": "sender", "identity": "support@mycompany.com" },
{ "role": "to", "identity": "customer@example.com" }
],
"content": "Hi! Happy to help. Your order #12345 is on its way.",
"content_html": "<p>Hi! Happy to help. Your order #12345 is on its way.</p>",
"attachments": [],
"created_at": "2026-02-25T10:30:00.000Z",
"metadata": {
"subject": "Re: Order help",
"inbox_id": "inbox_abc123",
"domain_id": "domain_xyz789",
"delivery_status": "delivered",
"has_attachments": false,
"attachment_count": 0
}
}
]
}
{
"error": "unauthorized",
"message": "Invalid or missing API key"
}
import { CommuneClient } from 'commune-ai';
const commune = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY });
const result = await commune.threads.get('thread_f47ac10b-58cc-4372-a567-0e02b2c3d479');
for (const message of result.data) {
console.log(message.direction, message.content);
}
from commune import CommuneClient
client = CommuneClient()
result = client.threads.get("thread_f47ac10b-58cc-4372-a567-0e02b2c3d479")
for message in result.data:
print(message.direction, message.content)
get_thread(thread_id="thread_f47ac10b-58cc-4372-a567-0e02b2c3d479")
curl "https://api.commune.email/v1/threads/thread_f47ac10b-58cc-4372-a567-0e02b2c3d479/messages" \
-H "Authorization: Bearer comm_..."
commune threads get thread_f47ac10b-58cc-4372-a567-0e02b2c3d479
{
"data": [
{
"channel": "email",
"message_id": "49a3999c-0ce1-4ea6-ab68-e08a5c73e498",
"thread_id": "thread_f47ac10b-58cc-4372-a567-0e02b2c3d479",
"direction": "inbound",
"participants": [
{ "role": "sender", "identity": "customer@example.com" },
{ "role": "to", "identity": "support@mycompany.com" }
],
"content": "Hi, I need help with my order.",
"content_html": "<p>Hi, I need help with my order.</p>",
"attachments": [],
"created_at": "2026-02-25T09:00:00.000Z",
"metadata": {
"subject": "Order help",
"inbox_id": "inbox_abc123",
"domain_id": "domain_xyz789",
"delivery_status": "delivered",
"has_attachments": false,
"attachment_count": 0,
"spam_checked": true,
"spam_score": 0.02,
"spam_action": "accept",
"spam_flagged": false,
"prompt_injection_checked": true,
"prompt_injection_detected": false,
"prompt_injection_risk": "none"
}
},
{
"channel": "email",
"message_id": "7b8c9d0e-1f2a-3b4c-d5e6-f7a8b9c0d1e2",
"thread_id": "thread_f47ac10b-58cc-4372-a567-0e02b2c3d479",
"direction": "outbound",
"participants": [
{ "role": "sender", "identity": "support@mycompany.com" },
{ "role": "to", "identity": "customer@example.com" }
],
"content": "Hi! Happy to help. Your order #12345 is on its way.",
"content_html": "<p>Hi! Happy to help. Your order #12345 is on its way.</p>",
"attachments": [],
"created_at": "2026-02-25T10:30:00.000Z",
"metadata": {
"subject": "Re: Order help",
"inbox_id": "inbox_abc123",
"domain_id": "domain_xyz789",
"delivery_status": "delivered",
"has_attachments": false,
"attachment_count": 0
}
}
]
}
{
"error": "unauthorized",
"message": "Invalid or missing API key"
}
Path Parameters
string
required
The thread ID. Format:
thread_<uuid>. Obtain this from the thread_id field in any message or from List threads.Query Parameters
number
default:"50"
Maximum number of messages to return. Range: 1–1000.
string
default:"asc"
Sort order by
created_at. One of: asc (oldest first, default for reading a conversation) or desc (newest first).Response
object[]
Array of message objects in the thread, ordered by
created_at. Each object is the full message shape — same as returned by Get message.Hide Message object properties
Hide Message object properties
string
Always
"email" for email messages.string
Unique message identifier.
string
Thread this message belongs to.
string
"inbound" for received messages, "outbound" for sent messages.object[]
string
Plain text body of the message.
string | null
HTML body of the message.
string[]
Attachment IDs for files attached to this message.
string
ISO 8601 timestamp.
object
Full metadata object. See Get message for all available fields, including delivery status, spam analysis, and prompt injection detection.
Last modified on March 19, 2026
Was this page helpful?

