---
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/vi/api-reference/receive-emails/drafts/list-drafts

Nhận email: bản nháp

# List Drafts

Liệt kê bản nháp của hộp thư, mới nhất trước. Cùng kết quả như list_messages trên thư mục Bản nháp.

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

Bản nháp lưu trong webmail cũng xuất hiện ở đây. Dùng get_draft để đọc một bản kèm nội dung và tệp đính kèm.

## Tham số

- `limit` number không bắt buộc
Số mục mỗi trang, từ 1 đến 100. Mặc định 25.
- `cursor` string không bắt buộc
`next_cursor` của trang trước.
- `after` string không bắt buộc
Chỉ bản nháp lưu sau thời điểm này (RFC 3339, `YYYY-MM-DD` hoặc epoch ms).
- `before` string không bắt buộc
Chỉ bản nháp lưu trước thời điểm này.

## Bắt đầu nhanh

```
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);
```

## Phản hồi

```
{
  "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
      }
    }
  ]
}
```

### Trường phản hồi

- `messages[].message_uid`
`draft_id`.
- `messages[].received_at`
Lần cuối bản nháp được lưu.
- `has_more / next_cursor`
Gửi `next_cursor` làm `cursor` để lấy trang tiếp.

## Lỗi

Lỗi ở mức HTTP trả về `type`, `code` và `message`. Lỗi đánh dấu CMD được trả về trong kết quả lệnh, với HTTP 200.

- 401`TOKEN_EXPIRED`
Access token đã hết hạn. Gọi Refresh Token và lặp lại yêu cầu.
- 401`INVALID_TOKEN`
Token sai định dạng, không xác định hoặc đã bị thu hồi.
- 429`RATE_LIMITED`
Hơn 15 yêu cầu/giây hoặc 15 yêu cầu đồng thời cho cùng IP + hộp thư. Chờ số giây trong Retry-After.
- CMD`INVALID_ARGS`
Thiếu hoặc sai tham số bắt buộc.
- CMD`INVALID_CURSOR`
Cursor sai định dạng hoặc thuộc tài khoản hay thư mục khác.
- CMD`INTERNAL`
Lỗi máy chủ. Chi tiết chỉ được ghi vào log máy chủ.
