---
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/get-draft

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

# Get Draft

อ่านร่างหนึ่งฉบับพร้อมแก้ไข: ผู้รับ หัวเรื่อง เนื้อหา ไฟล์แนบ และการติดตามผล

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

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

- `id` string จำเป็น
`draft_id`

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "get_draft",
        args: {
          id: "Vj0xRFJBRlQx"
        }
      }
    ]
  },
  { 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_draft",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "draft_id": "Vj0xRFJBRlQx",
        "thread_id": "thr_9a1c4e72",
        "mode": "new",
        "to": "ana@client.com",
        "cc": [],
        "bcc": [],
        "subject": "Proposal",
        "html": "<p>Hi Ana, here is the proposal.</p>",
        "updated_at": "2026-10-27T02:10:00Z",
        "compose_uid": "Vj0xQ01QMDAx",
        "track_opens": true,
        "track_clicks": false,
        "unsubscribe": false,
        "attachments": [
          {
            "attachment_id": "6f1c2a9e-4b7d-4e21-9a3f-0c8d5e7b1a42",
            "file_name": "proposal.pdf",
            "mime_type": "application/pdf",
            "size_bytes": 182340
          }
        ]
      }
    }
  ]
}
```

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

- `mode`
`new`, `reply` หรือ `forward`
- `to_emails`
ทุกที่อยู่ใน `to` `to` ยังเป็นที่อยู่แรก
- `id`
ข้อความต้นฉบับ สำหรับ `reply` และ `forward` ไม่มีสำหรับ `new`
- `updated_at`
เวลาที่บันทึกร่างครั้งล่าสุด
- `compose_uid / attachments`
ไฟล์ของร่าง ส่ง `compose_uid` กลับพร้อมไฟล์อัปโหลดใหม่เพื่อเพิ่ม
- `followup_after_hours`
การเตือนติดตามผล เมื่อมี
- `track_opens / track_clicks / unsubscribe`
ตัวเลือก tracking ที่บันทึกในร่าง ส่งกลับเฉพาะเมื่อร่างมี
- `last_send_error`
เฉพาะเมื่อการส่งตามเวลาถูกปฏิเสธและอีเมลกลับมาที่ร่าง: เหตุผลที่ถูกปฏิเสธ

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

ข้อผิดพลาดระดับ 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`DRAFT_NOT_FOUND`
ร่างไม่มีอยู่แล้ว: ถูกส่ง ลบ หรือบันทึกใหม่ (ทุกครั้งที่บันทึกจะได้ draft_id ใหม่)
- CMD`INTERNAL`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
