---
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/contacts/lists/create-list

ผู้ติดต่อ: รายชื่อ

# สร้างรายชื่อ

สร้างรายชื่อ เลือก id ของคุณเองเพื่อให้โค้ดอ้างถึงได้ หรือให้เซิร์ฟเวอร์สร้างให้

POST `https://g.sendcorex.com/v1/contacts` command: create_list

ต้องมีขอบเขต `contact:create` บน API key ของคุณ

รายชื่อใช้จัดกลุ่มผู้ติดต่อเพื่อส่ง ตัวผู้ติดต่อเป็นของบัญชี การเพิ่มในรายชื่อไม่ได้คัดลอก

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

- `list_id` string ไม่บังคับ
id ของคุณ: `a-z`, `0-9`, `_` และ `-` ไม่เกิน 40 ตัว หากไม่ใส่จะสร้างให้ id ที่มีอยู่แล้วจะล้มเหลวด้วย `ALREADY_EXISTS`
เช่น `"customers"`
- `name` string ไม่บังคับ
ชื่อที่แสดง
เช่น `"Customers"`
- `description` string ไม่บังคับ
ข้อความอิสระที่แสดงกับรายชื่อ
- `source` string ไม่บังคับ
ผู้ติดต่อมาจากไหน ไว้อ้างอิง
เช่น `"checkout"`
- `custom` object ไม่บังคับ
ข้อมูลของคุณเอง ไม่เกิน 50 คีย์
เช่น `{ "origin": "checkout", "year": 2026 }`

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/contacts',
  {
    commands: [
      {
        command: "create_list",
        args: {
          list_id: "customers",
          name: "Customers",
          description: "Everyone who bought at least once",
          source: "checkout",
          custom: {
            origin: "checkout",
            year: 2026
          }
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);

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_list",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 14,
      "data": {
        "list_id": "customers",
        "name": "Customers",
        "description": "Everyone who bought at least once",
        "source": "checkout",
        "status": "ready",
        "custom": {
          "origin": "checkout",
          "year": 2026
        },
        "created_at": "2026-10-01T10:00:00.000Z",
        "updated_at": "2026-10-12T15:22:41.000Z",
        "stats": {
          "total": 0,
          "ok": 0,
          "opened": 0,
          "clicked": 0
        }
      }
    }
  ]
}
```

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

- `list_id`
id ที่คุณส่งหรือที่สร้างให้
- `status`
`ready`
- `stats`
ตัวนับ เป็น `0` ทั้งหมดสำหรับรายชื่อใหม่

## ถัดไป: เติมข้อมูล

ส่ง `list_id` กับ Upsert Contacts เพื่อนำเข้าลงรายชื่อโดยตรง หรือใช้ Add To Lists กับผู้ติดต่อที่มีอยู่แล้ว

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

ข้อผิดพลาดระดับ HTTP ส่งกลับ `type`, `code` และ `message` ข้อผิดพลาดที่มีเครื่องหมาย CMD จะกลับมาในผลลัพธ์ของคำสั่ง พร้อม HTTP 200

- 401`INVALID_API_KEY`
API key ไม่มีอยู่ ถูกเพิกถอน หรือถูกปิดในแดชบอร์ด
- 429`RATE_LIMITED`
เกิน 15 คำขอ/วินาที หรือ 15 คำขอพร้อมกันสำหรับ IP + API key เดียวกัน รอจำนวนวินาทีใน Retry-After
- CMD`MISSING_SCOPE`
API key ไม่มีขอบเขตที่คำสั่งนี้ต้องการ คำสั่งอื่นในคำขอยังทำงาน
- CMD`INVALID_ARGS`
อาร์กิวเมนต์ที่จำเป็นหายไปหรือไม่ถูกต้อง: อีเมล ค่าฟิลด์ ตัวเลือก enum คีย์ where id รายชื่อ…
- CMD`ALREADY_EXISTS`
เรียก create_list ด้วย list_id ที่มีอยู่แล้ว
- CMD`INTERNAL`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
