---
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/folders/create-folder

รับอีเมล: โฟลเดอร์และตัวนับ

# Create Folder

สร้างโฟลเดอร์กำหนดเอง การตอบกลับให้ slug สำหรับใช้ในคำสั่งอื่น

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

ใช้ `folder` (slug) ที่ส่งกลับใน `move`, `list_threads` และคำสั่งอื่น ชื่อโฟลเดอร์ก็ใช้ได้ แต่ slug ไม่เปลี่ยน

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

- `name` string จำเป็น
ชื่อโฟลเดอร์ 1 ถึง 64 ตัวอักษร
- `color` string ไม่บังคับ
สีโฟลเดอร์
- `icon` string ไม่บังคับ
ไอคอนโฟลเดอร์

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "create_folder",
        args: {
          name: "Projeto X"
        }
      }
    ]
  },
  { 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": "create_folder",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "folder": "projeto-x",
        "name": "Projeto X"
      }
    }
  ]
}
```

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

- `folder`
slug ของโฟลเดอร์
- `name`
ชื่อโฟลเดอร์ที่คุณส่ง

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

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