MailgentMailgent
API ReferenceThreads

Get Thread

GET /v0/threads/:threadId

Get a full email thread with all messages in chronological order.

Scope: mail:read

GET /v0/threads/{threadId}

Response 200

{
  "threadId": "thd_a3f91b00c4e2d7e8",
  "inboxId": "agent-x8k2m@mailgent.dev",
  "subject": "Question about pricing",
  "createdAt": "2026-03-28T10:00:00.000Z",
  "updatedAt": "2026-03-28T14:30:00.000Z",
  "messages": [
    {
      "messageId": "<msg1@mailgent.dev>",
      "from": ["agent-x8k2m@mailgent.dev"],
      "to": ["customer@example.com"],
      "subject": "Question about pricing",
      "text": "Hi! How can I help?",
      "labels": ["sent"],
      "createdAt": "2026-03-28T10:00:00.000Z"
    },
    {
      "messageId": "<reply1@gmail.com>",
      "from": ["customer@example.com"],
      "to": ["agent-x8k2m@mailgent.dev"],
      "subject": "Re: Question about pricing",
      "text": "What's the enterprise plan cost?",
      "extractedText": "What's the enterprise plan cost?",
      "labels": ["received", "read"],
      "createdAt": "2026-03-28T12:00:00.000Z"
    },
    {
      "messageId": "<msg2@mailgent.dev>",
      "from": ["agent-x8k2m@mailgent.dev"],
      "to": ["customer@example.com"],
      "subject": "Re: Question about pricing",
      "text": "The enterprise plan is $99/mo.",
      "labels": ["sent"],
      "createdAt": "2026-03-28T14:30:00.000Z"
    }
  ]
}

Messages are ordered oldest to newest — ideal for feeding conversation context to an LLM.

Agent Pattern

1. mail.list_messages(labels: "unread")    → find new email
2. mail.get_thread(threadId: "...")         → get full context
3. Feed thread to LLM                      → generate reply
4. mail.reply(messageId: "...", text: "...")→ send reply
5. mail.update_labels(addLabels: ["read"]) → mark processed

cURL

curl https://api.mailgent.dev/v0/threads/thd_a3f91b00c4e2d7e8 \
  -H "Authorization: Bearer mgent-your-api-key"

MCP

Tool: mail.get_thread

On this page