---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/th/api-reference/receive-emails/reading/get-thread

รับอีเมล: การอ่าน

# Get Thread

เปิดทั้งบทสนทนา: สรุปและทุกข้อความตามลำดับเวลา เลือกให้มีเนื้อหาได้

POST `https://g.sendcorex.com/v1` command: get_thread

## อาร์กิวเมนต์

- `thread_id` string ไม่บังคับ
id ของบทสนทนา
- `id` string ไม่บังคับ
id ของข้อความใดก็ได้ในบทสนทนา ใช้อันนี้หรือ `thread_id`
- `include_body` boolean ไม่บังคับ
`true` เพิ่ม `body` (`html` และ `text`) ให้ทุกข้อความ

## เริ่มต้นอย่างรวดเร็ว

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "get_thread",
        args: {
          id: "Vj0xQUJDMTIz",
          include_body: true
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_TOKEN } },
);

const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);
```

## การตอบกลับ

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "get_thread",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "thread": {
          "thread_id": "thr_9a1c4e72",
          "subject": "Invoice for September",
          "participants": [
            "ana@client.com",
            "you@yourdomain.com"
          ],
          "last_senders": [
            "ana@client.com"
          ],
          "message_count": 2,
          "unread_count": 1,
          "folders": [
            "INBOX",
            "Sent"
          ]
        },
        "messages": [
          {
            "message_uid": "Vj0xQUJDMDA5",
            "message_id": "<4c1d…@mail.client.com>",
            "in_reply_to": null,
            "parent_uid": null,
            "depth": 0,
            "folders": [
              "INBOX"
            ],
            "from_name": "Ana Costa",
            "from_email": "ana@client.com",
            "direction": "inbound",
            "to": [
              {
                "email": "you@yourdomain.com"
              }
            ],
            "reply_to": [],
            "subject": "Invoice for September",
            "preview": "Hi, attached is the invoice for September…",
            "is_read": true,
            "is_starred": false,
            "is_important": false,
            "has_attachments": false,
            "received_at": "2026-10-09T09:02:41Z",
            "body": {
              "html": "<p>Hi, attached is the invoice for September.</p>",
              "text": "Hi, attached is the invoice for September."
            }
          }
        ]
      }
    }
  ]
}
```

### ฟิลด์การตอบกลับ

- `thread`
สรุปบทสนทนา: `thread_id`, `subject`, `participants`, `last_senders`, `message_count`, `unread_count` และ `folders`
- `messages[]`
ข้อความตามลำดับเวลา
- `messages[].message_uid / message_id`
id ในกล่องจดหมายและ Message-ID ของ SMTP
- `messages[].in_reply_to / parent_uid / depth`
ตำแหน่งของข้อความในแผนผังการตอบ
- `messages[].direction`
`inbound` หรือ `outbound`
- `messages[].from_name / from_email / to / reply_to`
ข้อมูลซอง
- `messages[].subject / preview`
หัวเรื่องและตัวอย่าง
- `messages[].is_read / is_starred / is_important / has_attachments`
สถานะข้อความ
- `messages[].received_at`
เวลาที่ได้รับหรือส่งข้อความ
- `messages[].body`
เฉพาะเมื่อใช้ `include_body: true`: `{ html, text }`

## ข้อผิดพลาด

ข้อผิดพลาดระดับ HTTP ส่งกลับ `type`, `code` และ `message` ข้อผิดพลาดที่มีเครื่องหมาย CMD จะกลับมาในผลลัพธ์ของคำสั่ง พร้อม HTTP 200

- 401`TOKEN_EXPIRED`
access token หมดอายุแล้ว เรียก Refresh Token แล้วส่งคำขอซ้ำ
- 401`INVALID_TOKEN`
โทเค็นผิดรูปแบบ ไม่รู้จัก หรือถูกเพิกถอน
- 429`RATE_LIMITED`
เกิน 15 คำขอ/วินาที หรือ 15 คำขอพร้อมกันสำหรับ IP + กล่องจดหมายเดียวกัน รอจำนวนวินาทีใน Retry-After
- CMD`INVALID_ARGS`
อาร์กิวเมนต์ที่จำเป็นหายไปหรือไม่ถูกต้อง
- CMD`NOT_FOUND`
ไม่มีข้อความ เธรด หรือโฟลเดอร์นี้สำหรับโทเค็นนี้
- CMD`INTERNAL`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
