---
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/list-messages

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

# List Messages

แสดงข้อความทีละฉบับ โดยไม่รวมเป็นบทสนทนา แสดงทุกข้อความที่มีป้ายกำกับก็ได้

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

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

- `folder` string ไม่บังคับ
โฟลเดอร์ที่จะแสดง ค่าเริ่มต้น `INBOX`
- `limit` number ไม่บังคับ
ขนาดหน้า 1 ถึง 100 ค่าเริ่มต้น 25
- `cursor` string ไม่บังคับ
`next_cursor` ของหน้าก่อน
- `is_read` boolean ไม่บังคับ
กรองตามสถานะการอ่าน ตัวกรองนี้สแกนโฟลเดอร์
- `is_starred` boolean ไม่บังคับ
กรองตามดาว ตัวกรองนี้สแกนโฟลเดอร์
- `is_important` boolean ไม่บังคับ
กรองตามความสำคัญ ตัวกรองนี้สแกนโฟลเดอร์
- `is_spam` boolean ไม่บังคับ
กรองตาม spam ตัวกรองนี้สแกนโฟลเดอร์
- `after` string ไม่บังคับ
เฉพาะข้อความที่ได้รับในหรือหลังวันนี้ RFC 3339, `YYYY-MM-DD` (UTC) หรือ epoch มิลลิวินาที
- `before` string ไม่บังคับ
เฉพาะข้อความที่ได้รับก่อนวันนี้ รูปแบบเดียวกับ `after`
- `label` string ไม่บังคับ
แสดงข้อความที่มีป้ายกำกับนี้ในทุกโฟลเดอร์ `folder` และตัวกรองบูลีนจะถูกละเว้น ไม่สนตัวพิมพ์ `after` และ `before` ยังใช้ได้
เช่น `"cliente-vip"`

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "list_messages",
        args: {
          folder: "INBOX",
          is_read: false,
          limit: 50
        }
      }
    ]
  },
  { 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": "list_messages",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "messages": [
          {
            "message_uid": "Vj0xQUJDMTIz",
            "thread_id": "thr_9a1c4e72",
            "folder": "INBOX",
            "subject": "Invoice for September",
            "preview": "Hi, attached is the invoice for September…",
            "from_name": "Ana Costa",
            "from_email": "ana@client.com",
            "has_attachments": false,
            "size_bytes": 4821,
            "is_read": false,
            "is_starred": false,
            "is_important": false,
            "is_spam": false,
            "snoozed_until": null,
            "received_at": "2026-10-09T14:21:07Z"
          }
        ],
        "has_more": false,
        "next_cursor": null
      }
    }
  ]
}
```

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

- `messages[].message_uid`
id ของข้อความ
- `messages[].thread_id`
บทสนทนาที่ข้อความอยู่
- `messages[].folder`
โฟลเดอร์ของรายการนี้
- `messages[].subject / preview`
หัวเรื่องและตัวอย่างสั้น
- `messages[].from_name / from_email`
ผู้ส่ง
- `messages[].has_attachments / size_bytes`
แฟล็กไฟล์แนบและขนาดข้อความ
- `messages[].is_read / is_starred / is_important / is_spam`
สถานะข้อความ
- `messages[].snoozed_until`
เวลาที่ข้อความที่เลื่อนไว้จะกลับมา หรือ `null`
- `messages[].received_at`
เวลาที่ได้รับข้อความ
- `has_more / next_cursor`
การแบ่งหน้า

## แสดงตามป้ายกำกับ

เมื่อใช้ `label` คำสั่งจะอ่านดัชนีป้ายกำกับ จึงตรวจเฉพาะข้อความที่มีป้าย แต่ละข้อความส่งกลับพร้อมสถานะปัจจุบันในทุกโฟลเดอร์ คุณจึงได้ `folders` และ `labels` แทน `folder` เดียว

ข้อมูลตอบกลับเมื่อใช้ป้ายกำกับ

```
{
  "messages": [
    {
      "message_uid": "Vj0xQUJDMTIz",
      "thread_id": "thr_9a1c4e72",
      "subject": "Invoice for September",
      "preview": "Hi, attached is the invoice for September…",
      "from_name": "Ana Costa",
      "from_email": "ana@client.com",
      "folders": [
        "INBOX"
      ],
      "labels": [
        "cliente-vip"
      ],
      "is_read": false,
      "is_starred": false,
      "is_important": false,
      "received_at": "2026-10-09T14:21:07Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

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

ข้อผิดพลาดระดับ 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`INVALID_CURSOR`
cursor ผิดรูปแบบหรือเป็นของบัญชีหรือโฟลเดอร์อื่น
- CMD`INTERNAL`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
