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

รับอีเมล: ร่าง

# List Drafts

แสดงร่างของกล่องจดหมาย ใหม่สุดก่อน ผลเดียวกับ list_messages บนโฟลเดอร์ร่าง

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

ร่างที่บันทึกใน webmail ก็แสดงที่นี่ ใช้ get_draft เพื่ออ่านร่างพร้อมเนื้อหาและไฟล์แนบ

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

- `limit` number ไม่บังคับ
จำนวนต่อหน้า 1 ถึง 100 ค่าเริ่มต้น 25
- `cursor` string ไม่บังคับ
`next_cursor` ของหน้าก่อน
- `after` string ไม่บังคับ
เฉพาะร่างที่บันทึกหลังเวลานี้ (RFC 3339, `YYYY-MM-DD` หรือ epoch ms)
- `before` string ไม่บังคับ
เฉพาะร่างที่บันทึกก่อนเวลานี้

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "list_drafts",
        args: {
          limit: 25
        }
      }
    ]
  },
  { 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_drafts",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "messages": [
          {
            "message_uid": "Vj0xRFJBRlQx",
            "thread_id": "thr_9a1c4e72",
            "folder": "Drafts",
            "subject": "Proposal",
            "preview": "Hi Ana, here is the proposal.",
            "from_name": "Marcos",
            "from_email": "marcos@yourdomain.com",
            "has_attachments": true,
            "size_bytes": 2210,
            "is_read": true,
            "is_starred": false,
            "is_important": false,
            "is_spam": false,
            "snoozed_until": null,
            "received_at": "2026-10-27T02:10:00Z"
          }
        ],
        "has_more": false,
        "next_cursor": null
      }
    }
  ]
}
```

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

- `messages[].message_uid`
`draft_id`
- `messages[].received_at`
เวลาที่บันทึกร่างครั้งล่าสุด
- `has_more / next_cursor`
ส่ง `next_cursor` เป็น `cursor` เพื่อดูหน้าถัดไป

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

ข้อผิดพลาดระดับ 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`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
