Skip to main content
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.threads.list({ limit: 10 });
console.log(result);
{
  "data": [
    {
      "id": "thrd_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "agent_id": "agt_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "subject": "<subject>",
      "root_message_id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "last_message_id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "last_message_at": "2026-10-04T12:00:00.000Z",
      "message_count": 0,
      "participants": ["jordan@example.com"],
      "labels": ["<labels>"],
      "label_ids": ["lbl_01JZX8K3M9Q4P7VN2YB6RTDC0E"],
      "status": "open",
      "read": false,
      "folder": "inbox",
      "trashed_at": "2026-10-04T12:00:00.000Z",
      "test_mode": false,
      "created_at": "2026-10-04T12:00:00.000Z",
      "updated_at": "2026-10-04T12:00:00.000Z"
    }
  ],
  "has_more": false,
  "next_cursor": "<next_cursor>"
}

List threads

GET/v1/threadsscope · read
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.threads.list({ limit: 10 });
console.log(result);
{
  "data": [
    {
      "id": "thrd_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "agent_id": "agt_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "subject": "<subject>",
      "root_message_id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "last_message_id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "last_message_at": "2026-10-04T12:00:00.000Z",
      "message_count": 0,
      "participants": ["jordan@example.com"],
      "labels": ["<labels>"],
      "label_ids": ["lbl_01JZX8K3M9Q4P7VN2YB6RTDC0E"],
      "status": "open",
      "read": false,
      "folder": "inbox",
      "trashed_at": "2026-10-04T12:00:00.000Z",
      "test_mode": false,
      "created_at": "2026-10-04T12:00:00.000Z",
      "updated_at": "2026-10-04T12:00:00.000Z"
    }
  ],
  "has_more": false,
  "next_cursor": "<next_cursor>"
}

Query Parameters

limitinteger

Page size (1–100).

Default: 25

cursorstring

Opaque cursor from a previous page's next_cursor.

agent_idstring

Filter by agent id or name. A key tied to one agent always reads that agent's mail, and naming another agent is a 403.

statusstring

Filter by thread status (open|closed|archived).

folderstring

Which folder's threads to return, or all for every folder. Without it: every folder except trash.

One of: inbox, archive, spam, trash, sent, all

readboolean

false for unread threads only, true for read ones.

labelstring

Only threads carrying this label (a name, or a label id lbl_…).

modestring

live for threads that hold live mail, test for threads of test mail only (test_mode: true), all for both. Without it, a key lists the threads of its own mode, as the unread counts of GET /v1/agents/{id}/inbox count them: a live key does not see the test mail POST /v1/test/inbound delivers.

One of: live, test, all

qstring

Case-insensitive substring of the subject or participant addresses. For word search across all mail, use GET /v1/search.

Response

dataobject[]

The items on this page, at most limit of them.

Show propertiesHide properties
idstring

Thread id (thrd_…).

agent_idstring

Id (agt_…) of the agent the thread belongs to; a thread holds one agent's mail only.

subjectstring

The subject of the thread's first message, without one leading Re:, Fwd: or Fw:. Empty when that message had no subject.

root_message_idstring

Id of the message that started the thread: msg_… for one the agent sent, rcv_… for one it received.

last_message_idstring

Id of the message that joined the thread most recently (msg_… or rcv_…).

last_message_atstring

When the latest message joined the thread. The thread list is ordered by it, newest first.

message_countinteger

How many messages have joined the thread, sent and received.

participantsstring[]

Every address the thread has involved, in lower case and without repeats: the agent's own, the senders of received mail and the recipients of sent mail.

labelsstring[]

Label names, up to 50, each at most 64 characters. Any such name works; names that match a label object also appear in label_ids.

label_idsstring[]

Ids (lbl_…) of the label objects whose names are on this thread.

statusstring

open (every new thread), closed or archived, changed with PATCH. archived goes with folder archive, and only an open thread takes in new mail matched by its subject (mail from someone already in the thread).

One of: open, closed, archived

readboolean

False once new mail arrives; set it with PATCH.

folderstring

inbox, archive, spam, trash or sent. archive goes with status archived. sent holds a thread whose messages are all ones the agent sent, until a reply moves it to the inbox. Threads in trash are deleted for good 30 days after they were trashed.

One of: inbox, archive, spam, trash, sent

trashed_atstring

When the thread was moved to trash. Present only while it is there.

test_modeboolean

True when the thread holds no live mail: every message in it was sent with a test key (mk_test_…) or delivered through POST /v1/test/inbound. A thread with any live message is live. Its thread.* events carry the same test_mode, and GET /v1/threads lists a key's own mode unless mode says otherwise.

created_atstring

When the thread was created, with its first message.

updated_atstring

When the thread last changed: a message joined it, or its read state, folder, status or labels changed.

has_moreboolean

True when more items follow this page: pass next_cursor as cursor to get them.

next_cursorstring

Pass as cursor to fetch the next page. Absent on the last page.

Was this page helpful?