---
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/organize/delete

รับอีเมล: จัดระเบียบ

# Delete

ลบข้อความถาวร ลบได้เฉพาะข้อความในถังขยะหรือ Spam

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

ย้อนกลับไม่ได้ หากต้องการย้ายข้อความไปถังขยะ ใช้ `move` กับ `to_folder: "Trash"`

ข้อความที่อยู่ในโฟลเดอร์อื่นด้วย (เช่น คำตอบใน `Sent`) จะถูกนำออกจากถังขยะเท่านั้น ไม่ถูกลบถาวร

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

- `ids` string[] ไม่บังคับ
id ข้อความสูงสุด 100 รายการ
- `id` string ไม่บังคับ
id ข้อความเดียว ใช้อันนี้หรือ `ids`
- `from_folder` string จำเป็น
ต้องเป็น `Trash` หรือ `Spam` อย่างอื่นจะล้มเหลวด้วย `NOT_IN_TRASH`
- `scope` string ไม่บังคับ
`thread` (ค่าเริ่มต้น) หรือ `message`

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "delete",
        args: {
          id: "Vj0xQUJDMTIz",
          from_folder: "Trash"
        }
      }
    ]
  },
  { 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": "delete",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "items": [
          {
            "id": "Vj0xQUJDMTIz",
            "ok": true,
            "data": {
              "changed": 1,
              "deleted": 1,
              "removed": 0
            }
          }
        ],
        "ok_count": 1,
        "failed_count": 0
      }
    }
  ]
}
```

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

- `items[].data.changed`
รายการที่เปลี่ยน
- `items[].data.deleted`
ข้อความที่ลบถาวร
- `items[].data.removed`
ข้อความที่นำออกจากโฟลเดอร์เท่านั้นเพราะยังอยู่ในโฟลเดอร์อื่น

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

ข้อผิดพลาดระดับ 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`NOT_IN_TRASH`
delete ใช้ได้เฉพาะข้อความในถังขยะหรือ Spam ใช้ move ย้ายข้อความไปถังขยะก่อน
- CMD`INTERNAL`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
