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

โดเมน: เส้นทาง

# Run Commands

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

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

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

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

โดเมนระบุด้วยชื่อ (`acme.com`) ไม่ใช่ id ภายใน

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

- `commands` object[] จำเป็น
1 ถึง 10 คำสั่ง ทำงานตามลำดับ body ทั้งหมดได้สูงสุด 1 MB
- `commands[].command` string จำเป็น
`list_domains`, `get_domain`, `add_domain`, `delete_domain`, `update_domain_description`, `list_free_domains`, `start_dkim_upgrade`, `cancel_dkim_upgrade`, `send_dns_instructions` หรือ `request_domain_remediation`
- `commands[].args` object ไม่บังคับ
อาร์กิวเมนต์ของคำสั่ง ค่าใดก็เป็น `$ref` ไปยังผลลัพธ์ของคำสั่งก่อนหน้าได้
- `commands[].id` string ไม่บังคับ
ตัวระบุของคุณสำหรับผลลัพธ์ ค่าเริ่มต้นคือดัชนี (`"0"`, `"1"`…) จำเป็นหากต้องการใช้ `$ref`

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/domain',
  {
    commands: [
      {
        command: "list_domains",
        id: "mine"
      },
      {
        command: "list_free_domains",
        id: "free"
      }
    ]
  },
  { 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_domains",
      "id": "mine",
      "type": "SUCCESS",
      "took_ms": 6,
      "data": {
        "domains": [
          {
            "domain": "acme.com",
            "validated": true,
            "has_mx": true,
            "has_spf": true,
            "has_dkim": true,
            "has_dmarc": true,
            "has_return_path": true,
            "description": "Transactional (app emails)",
            "dkim_key_size": 2048,
            "dkim_deprecated": false,
            "dkim_upgrade_pending": false,
            "created_at": "2026-09-02T14:21:07.118Z",
            "updated_at": "2026-10-21T02:40:51.902Z"
          }
        ]
      }
    },
    {
      "command": "list_free_domains",
      "id": "free",
      "type": "SUCCESS",
      "took_ms": 0,
      "data": {
        "domains": [
          "corexsend.com",
          "inboxtaken.com",
          "outsending.com",
          "shieldhaus.uk",
          "shieldhaus.info",
          "mailverifypro.info",
          "mailverifypro.online",
          "mailverifypro.store",
          "mailverifypro.org"
        ]
      }
    }
  ]
}
```

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

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

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

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

- `Authorization`
ส่ง `Authorization: <api key>` หรือ `Authorization: Bearer <api key>`
- `domain:read`
`list_domains`, `get_domain`, `list_free_domains` และ `send_dns_instructions`
- `domain:create`
`add_domain`, `start_dkim_upgrade`, `cancel_dkim_upgrade`, `update_domain_description` และ `request_domain_remediation`
- `domain:delete`
`delete_domain` ให้เฉพาะคีย์ที่จำเป็นจริงๆ: การลบโดเมนจะลบผู้ส่งด้วย
- `โทเค็นกล่องจดหมาย`
โทเค็น webmail ใช้ที่นี่ไม่ได้ จะถูกปฏิเสธด้วย `WRONG_CREDENTIAL_TYPE`
- `IP ที่อนุญาต`
หากคีย์มีรายการ IP ที่อนุญาต คำขอจาก IP อื่นจะได้ `403 IP_NOT_ALLOWED`

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

เพิ่มโดเมนและอ่านกลับในคำขอเดียว คำสั่งที่สองนำโดเมนจากผลลัพธ์แรก

add_domain → get_domain

```
{
  "commands": [
    {
      "command": "add_domain",
      "id": "new",
      "args": {
        "domain": "acme.com"
      }
    },
    {
      "command": "get_domain",
      "args": {
        "domain": {
          "$ref": "new",
          "path": "domain"
        }
      }
    }
  ]
}
```

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

สองขีดจำกัด อันแรกสำหรับทั้งเส้นทาง อันที่สองสำหรับบางคำสั่ง

- `15 คำขอ / วินาที`
ต่อ IP + API key เกินจะได้ HTTP 429 พร้อมเฮดเดอร์ `Retry-After`
- `15 พร้อมกัน`
คำขอที่ประมวลผลพร้อมกันสูงสุด 15 ต่อ IP + API key
- `ต่อคำสั่ง ต่อบัญชี`
`add_domain` 10/นาที · `get_domain` 60/นาที · `delete_domain` 30/นาที · `start_dkim_upgrade` และ `cancel_dkim_upgrade` 10/นาที · `update_domain_description` 20/นาที · `send_dns_instructions` และ `request_domain_remediation` 5/นาที เกินแล้วคำสั่งนั้นจะตอบ `RATE_LIMITED`
- `ไม่มีแคช`
ทุกการเรียกอ่านฐานข้อมูล (และ DNS สำหรับ `get_domain`) จึงได้ข้อมูลล่าสุดเสมอ

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

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

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