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

List Folders

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

POSThttps://g.sendcorex.com/v1command: list_folders

ผลลัพธ์ถูกแคช 1.5 วินาที

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

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

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

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "list_folders"
      }
    ]
  },
  { 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_folders",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "folders": [
          {
            "folder": "INBOX",
            "name": "INBOX",
            "system": true,
            "total": 12,
            "unread": 3
          },
          {
            "folder": "Sent",
            "name": "Sent",
            "system": true,
            "total": 8,
            "unread": 0
          },
          {
            "folder": "projeto-x",
            "name": "Projeto X",
            "system": false,
            "total": 4,
            "unread": 1
          }
        ]
      }
    }
  ]
}

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

  • folders[].folder

    ตัวระบุโฟลเดอร์ (slug) ใช้ในคำสั่งอื่น

  • folders[].name

    ชื่อที่แสดง

  • folders[].system

    true สำหรับโฟลเดอร์ระบบ false สำหรับโฟลเดอร์กำหนดเอง

  • folders[].total

    จำนวนรายการในโฟลเดอร์

  • folders[].unread

    จำนวนรายการที่ยังไม่อ่านในโฟลเดอร์

โฟลเดอร์ระบบ

INBOX, Sent, Archive, Trash, Drafts, Spam, Promotions, Snoozed, Scheduled (อีเมลที่รอส่ง), Agents (เขียนโดย AI agent) และ NotSubscribing (บอกว่าจะไม่ซื้อหรือสมัคร) รับชื่อแทน เช่น inbox, archived, draft, junk, promotion และ not-subscribing ทุกที่ที่ต้องการโฟลเดอร์

ข้อผิดพลาด

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

  • 401TOKEN_EXPIRED

    access token หมดอายุแล้ว เรียก Refresh Token แล้วส่งคำขอซ้ำ

  • 401INVALID_TOKEN

    โทเค็นผิดรูปแบบ ไม่รู้จัก หรือถูกเพิกถอน

  • 429RATE_LIMITED

    เกิน 15 คำขอ/วินาที หรือ 15 คำขอพร้อมกันสำหรับ IP + กล่องจดหมายเดียวกัน รอจำนวนวินาทีใน Retry-After

  • CMDINTERNAL

    ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์