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

const client = createClient(); // reads MAILS_API_KEY

const result = await client.threads.remove(
  "thrd_01JZX8K3M9Q4P7VN2YB6RTDC0E",
);
console.log(result);
{
  "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",
  "deleted": false
}

Trash or delete a thread

Moves the thread to trash (deleted: false, the thread returned).
DELETE/v1/threads/{id}scope · manage
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.threads.remove(
  "thrd_01JZX8K3M9Q4P7VN2YB6RTDC0E",
);
console.log(result);
{
  "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",
  "deleted": false
}

Path Parameters

idstringrequired

Thread id.

Query Parameters

permanentboolean

true deletes the thread for good instead of moving it to trash.

Sent again for a thread already in trash it changes nothing, so a retried request never destroys mail. With permanent=true it deletes the thread for good, from any folder: its messages' content, raw email and attachments are removed, and thread.deleted is emitted. Trash is also emptied automatically 30 days after a thread was moved there. A test key cannot trash or delete a thread holding live mail (403 live_mode_required). An app connected by sign-in may move a thread to trash but not delete it for good: with permanent=true it gets 403 connected_app_not_allowed.

Was this page helpful?