---
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/rules/list-rules

รับอีเมล: กฎ

# List Rules

กฎของกล่องจดหมายตามลำดับที่ทำงาน พร้อมจำนวนครั้งที่แต่ละกฎตรง

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

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

endpoint นี้ไม่มีอาร์กิวเมนต์

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "list_rules"
      }
    ]
  },
  { 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": "list_rules",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "rules": [
          {
            "id": "Vj0xUlVMRTAx",
            "rule_id": "Vj0xUlVMRTAx",
            "name": "Clients always in Inbox",
            "match": "all",
            "conditions": [
              {
                "field": "from_domain",
                "op": "in_list",
                "value": "acme.com, globex.com"
              },
              {
                "field": "provider",
                "op": "is_any_of",
                "value": [
                  "microsoft_365",
                  "google_workspace"
                ]
              }
            ],
            "except": [
              {
                "field": "subject",
                "op": "contains",
                "value": "newsletter"
              }
            ],
            "actions": [
              {
                "type": "keep_inbox"
              },
              {
                "type": "label",
                "value": "Clients"
              },
              {
                "type": "star"
              }
            ],
            "stop": false,
            "timezone": "Asia/Kuala_Lumpur",
            "enabled": true,
            "position": 0,
            "hits": 128,
            "last_hit_at": "2026-10-25T09:12:44Z",
            "created_at": "2026-10-01T02:00:00Z",
            "updated_at": "2026-10-20T08:30:00Z"
          }
        ],
        "max_rules": 100
      }
    }
  ]
}
```

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

- `rules[]`
ตามลำดับการทำงาน (`position`) `hits` และ `last_hit_at` แสดงว่ากฎไหนถูกใช้จริง
- `max_rules`
สูงสุด 100 กฎต่อกล่องจดหมาย

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

ข้อผิดพลาดระดับ 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`INTERNAL`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
