---
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/vi/api-reference/receive-emails/folders/list-folders

Nhận email: thư mục và bộ đếm

# List Folders

Liệt kê thư mục hệ thống và thư mục tùy chỉnh, kèm tổng số và số chưa đọc của mỗi thư mục.

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

Kết quả được cache 1,5 giây.

## Tham số

Endpoint này không có đối số.

## Bắt đầu nhanh

```
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);
```

## Phản hồi

```
{
  "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
          }
        ]
      }
    }
  ]
}
```

### Trường phản hồi

- `folders[].folder`
Mã thư mục (slug). Dùng nó trong lệnh khác.
- `folders[].name`
Tên hiển thị.
- `folders[].system`
`true` cho thư mục hệ thống, `false` cho thư mục tùy chỉnh.
- `folders[].total`
Số mục trong thư mục.
- `folders[].unread`
Số mục chưa đọc trong thư mục.

## Thư mục hệ thống

`INBOX`, `Sent`, `Archive`, `Trash`, `Drafts`, `Spam`, `Promotions`, `Snoozed`, `Scheduled` (email chờ gửi), `Agents` (do AI agent viết) và `NotSubscribing` (nói sẽ không mua hay đăng ký). Chấp nhận bí danh như `inbox`, `archived`, `draft`, `junk`, `promotion` và `not-subscribing` ở mọi nơi cần thư mục.

## Lỗi

Lỗi ở mức HTTP trả về `type`, `code` và `message`. Lỗi đánh dấu CMD được trả về trong kết quả lệnh, với HTTP 200.

- 401`TOKEN_EXPIRED`
Access token đã hết hạn. Gọi Refresh Token và lặp lại yêu cầu.
- 401`INVALID_TOKEN`
Token sai định dạng, không xác định hoặc đã bị thu hồi.
- 429`RATE_LIMITED`
Hơn 15 yêu cầu/giây hoặc 15 yêu cầu đồng thời cho cùng IP + hộp thư. Chờ số giây trong Retry-After.
- CMD`INTERNAL`
Lỗi máy chủ. Chi tiết chỉ được ghi vào log máy chủ.
