---
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/senders/routes/run-commands

ผู้ส่ง: เส้นทาง

# Run Commands

จุดเข้าเดียวสำหรับผู้ส่ง ส่ง 1 ถึง 20 คำสั่งในคำขอเดียวและได้ผลลัพธ์หนึ่งรายการต่อคำสั่ง

POST `https://g.sendcorex.com/v1/sender`

โครงสร้างเดียวกับ Domains, Contacts และ Logs หน้าถัดจากนี้อธิบายแต่ละคำสั่ง

ข้อผิดพลาดรายงานต่อคำสั่ง คำสั่งที่ล้มเหลวไม่หยุดคำสั่งอื่น และสถานะ HTTP ยังเป็น `200`

## พารามิเตอร์ body

- `commands` object[] จำเป็น
1 ถึง 20 คำสั่ง ทำงานตามลำดับ body ทั้งหมดได้สูงสุด 1 MB
- `commands[].command` string จำเป็น
`list_senders`, `get_sender`, `create_sender`, `update_sender`, `update_sender_description` หรือ `delete_sender`
- `commands[].args` object ไม่บังคับ
อาร์กิวเมนต์ของคำสั่ง ค่าใดก็เป็น `$ref` ไปยังผลลัพธ์ของคำสั่งก่อนหน้าได้
- `commands[].id` string ไม่บังคับ
ตัวระบุของคุณสำหรับผลลัพธ์ ค่าเริ่มต้นคือดัชนี (`"0"`, `"1"`…) จำเป็นหากต้องการใช้ `$ref`

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/sender',
  {
    commands: [
      {
        command: "list_senders",
        id: "all"
      },
      {
        command: "get_sender",
        id: "one",
        args: {
          sender_id: "K7Q2M9XR4TB8WD1ZC6NF3HJP"
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);

for (const result of response.data.results) {
  if (result.type !== 'SUCCESS') console.error(result.id, result.code, result.message);
  else console.log(result.id, result.data);
}
```

## การตอบกลับ

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "list_senders",
      "id": "all",
      "type": "SUCCESS",
      "took_ms": 5,
      "data": {
        "senders": [
          {
            "sender_id": "K7Q2M9XR4TB8WD1ZC6NF3HJP",
            "email": "hello@acme.com",
            "username": "hello",
            "domain": "acme.com",
            "from_name": "Acme",
            "reply_to": "support@acme.com",
            "description": "Product updates",
            "avatar_color": "#2F6FDB",
            "warmup_enabled": false,
            "reputation": {
              "delivered": 18420,
              "bounced": 131,
              "spam": 6,
              "received_messages": 2210,
              "total_emails": 18557,
              "has_minimum_volume": true,
              "delivery_rate": 99,
              "bounce_rate": 1,
              "spam_rate": 0,
              "engagement_rate": 12,
              "score": 100,
              "status": "Excellent"
            },
            "created_at": "2026-09-02T14:40:12.530Z",
            "updated_at": "2026-10-20T08:15:33.004Z"
          }
        ]
      }
    },
    {
      "command": "get_sender",
      "id": "one",
      "type": "SUCCESS",
      "took_ms": 2,
      "data": {
        "sender_id": "K7Q2M9XR4TB8WD1ZC6NF3HJP",
        "email": "hello@acme.com",
        "username": "hello",
        "domain": "acme.com",
        "from_name": "Acme",
        "reply_to": "support@acme.com",
        "description": "Product updates",
        "avatar_color": "#2F6FDB",
        "warmup_enabled": false,
        "reputation": {
          "delivered": 18420,
          "bounced": 131,
          "spam": 6,
          "received_messages": 2210,
          "total_emails": 18557,
          "has_minimum_volume": true,
          "delivery_rate": 99,
          "bounce_rate": 1,
          "spam_rate": 0,
          "engagement_rate": 12,
          "score": 100,
          "status": "Excellent"
        },
        "created_at": "2026-09-02T14:40:12.530Z",
        "updated_at": "2026-10-20T08:15:33.004Z"
      }
    }
  ]
}
```

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

- `type`
เป็น `SUCCESS` เสมอเมื่อคำขอถูกรับ
- `results[].command`
คำสั่งที่สร้างผลลัพธ์นี้
- `results[].id`
`id` ที่คุณส่ง หรือดัชนีของคำสั่ง
- `results[].type`
`SUCCESS` หรือ `ERROR`
- `results[].took_ms`
เวลาที่คำสั่งใช้ในเซิร์ฟเวอร์
- `results[].data`
ผลลัพธ์ของคำสั่ง มีเฉพาะเมื่อ `type` เป็น `SUCCESS`
- `results[].code / message`
ข้อผิดพลาด มีเฉพาะเมื่อ `type` เป็น `ERROR`

## การยืนยันตัวตน

ใช้ API key ที่สร้างในแดชบอร์ด ที่ Developers → API Keys พร้อมขอบเขตที่คำสั่งต้องการ

- `Authorization`
ส่ง `Authorization: <api key>` หรือ `Authorization: Bearer <api key>`
- `sender:read`
`list_senders` และ `get_sender`
- `sender:create`
`create_sender`
- `sender:update`
`update_sender` และ `update_sender_description`
- `sender:delete`
`delete_sender`
- `โทเค็นกล่องจดหมาย`
โทเค็น webmail ใช้ที่นี่ไม่ได้ จะถูกปฏิเสธด้วย `WRONG_CREDENTIAL_TYPE`
- `IP ที่อนุญาต`
หากคีย์มีรายการ IP ที่อนุญาต คำขอจาก IP อื่นจะได้ `403 IP_NOT_ALLOWED`

## เชื่อมต่อด้วย $ref

สร้างผู้ส่งแล้วส่ง id ต่อให้คำสั่งถัดไปในคำขอเดียวกัน

create_sender → update_sender_description

```
{
  "commands": [
    {
      "command": "create_sender",
      "id": "new",
      "args": {
        "username": "news",
        "from_name": "Acme News",
        "reply_to": "news@acme.com",
        "domain": "acme.com"
      }
    },
    {
      "command": "update_sender_description",
      "args": {
        "sender_id": {
          "$ref": "new",
          "path": "sender_id"
        },
        "description": "Monthly newsletter"
      }
    }
  ]
}
```

## ขีดจำกัดอัตรา

- `15 คำขอ / วินาที`
ต่อ IP + API key เกินจะได้ HTTP 429 พร้อมเฮดเดอร์ `Retry-After`
- `15 พร้อมกัน`
คำขอที่ประมวลผลพร้อมกันสูงสุด 15 ต่อ IP + API key
- `ต่อคำสั่ง ต่อบัญชี`
`create_sender` และ `update_sender` 10/นาที · `update_sender_description` 20/นาที · `delete_sender` 30/นาที เกินแล้วคำสั่งนั้นจะตอบ `RATE_LIMITED`
- `ไม่มีแคช`
ทุกการเรียกอ่านฐานข้อมูล จึงได้ข้อมูลล่าสุดเสมอ

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

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

- 400`INVALID_JSON`
body ไม่ใช่ {"commands":[...]} หรือใหญ่กว่า 1 MB
- 400`INVALID_ARGS`
คำขอไม่มีคำสั่งหรือมีเกิน 20
- 401`MISSING_AUTH_HEADER`
ไม่ได้ส่งเฮดเดอร์ Authorization
- 401`INVALID_API_KEY`
API key ไม่มีอยู่ ถูกเพิกถอน หรือถูกปิดในแดชบอร์ด
- 401`API_KEY_EXPIRED`
API key เลยวันหมดอายุที่ตั้งในแดชบอร์ดแล้ว
- 401`WRONG_CREDENTIAL_TYPE`
มีการส่งโทเค็นกล่องจดหมาย Senders API ต้องใช้ API key จากแดชบอร์ด
- 403`IP_NOT_ALLOWED`
คำขอมาจาก IP ที่ไม่อยู่ใน IP ที่อนุญาตของคีย์
- 403`ACCOUNT_BLOCKED`
บัญชีถูกบล็อก
- 403`MISSING_SCOPE`
คีย์ไม่มีขอบเขต `sender:*` จึงไม่มีคำสั่งใดทำงานได้
- 429`RATE_LIMITED`
เกิน 15 คำขอ/วินาที หรือ 15 คำขอพร้อมกันสำหรับ IP + API key เดียวกัน รอจำนวนวินาทีใน Retry-After
- 503`AUTH_UNAVAILABLE`
การยืนยันตัวตนใช้งานไม่ได้ชั่วคราว ลองอีกครั้ง
- CMD`UNKNOWN_COMMAND`
ไม่มีชื่อคำสั่งนี้
- CMD`INTERNAL`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
