---
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/get-counters

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

# Get Counters

รับตัวนับทั้งหมดและที่ยังไม่อ่านของทั้งกล่องจดหมายและทุกโฟลเดอร์

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

ยอดรวมที่ระดับราก นับข้อความที่ไม่ซ้ำ ตัวเลขในแต่ละโฟลเดอร์นับรายการในรายการ คำตอบที่อยู่ทั้งใน `Sent` และ `INBOX` จึงนับครั้งเดียวในแต่ละโฟลเดอร์

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

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

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

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "get_counters"
      }
    ]
  },
  { 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": "get_counters",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "total": 20,
        "unread": 3,
        "size_bytes": 1048576,
        "folders": {
          "INBOX": {
            "total": 12,
            "unread": 3,
            "size_bytes": 482113
          },
          "Sent": {
            "total": 8,
            "unread": 0,
            "size_bytes": 566463
          }
        }
      }
    }
  ]
}
```

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

- `total`
ข้อความที่ไม่ซ้ำในกล่องจดหมาย
- `unread`
ข้อความที่ไม่ซ้ำและยังไม่อ่านในกล่องจดหมาย
- `size_bytes`
ขนาดรวมของกล่องจดหมาย
- `folders.<name>.total`
รายการในโฟลเดอร์นั้น
- `folders.<name>.unread`
รายการที่ยังไม่อ่านในโฟลเดอร์นั้น
- `folders.<name>.size_bytes`
ขนาดของโฟลเดอร์นั้น

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

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