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

メールの受信：フォルダーとカウンター

# List Folders

システムフォルダーとカスタムフォルダーを、それぞれの合計と未読数とともに一覧表示します。

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

結果は1.5秒間キャッシュされます。

## 引数

このエンドポイントに引数はありません。

## クイックスタート

```
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`
フォルダーの識別子（スラッグ）。ほかのコマンドで使います。
- `folders[].name`
表示名。
- `folders[].system`
システムフォルダーは`true`、カスタムフォルダーは`false`。
- `folders[].total`
フォルダー内の項目数。
- `folders[].unread`
フォルダー内の未読項目数。

## システムフォルダー

`INBOX`、`Sent`、`Archive`、`Trash`、`Drafts`、`Spam`、`Promotions`、`Snoozed`、`Scheduled`（送信待ちのメール）、`Agents`（AIエージェントが書いたもの）、`NotSubscribing`（購入や登録をしないと言っているもの）。`inbox`、`archived`、`draft`、`junk`、`promotion`、`not-subscribing`などの別名も、フォルダーを指定する場所ならどこでも使えます。

## エラー

HTTPレベルのエラーは`type`、`code`、`message`を返します。CMDと表示されたエラーは、HTTP 200でコマンドの結果内に返ります。

- 401`TOKEN_EXPIRED`
access tokenの有効期限が切れました。Refresh Tokenを呼んでリクエストを繰り返してください。
- 401`INVALID_TOKEN`
トークンの形式が不正、不明、または取り消されています。
- 429`RATE_LIMITED`
同じIP + メールボックスで毎秒15リクエストまたは同時15件を超えました。Retry-Afterの秒数だけ待ってください。
- CMD`INTERNAL`
サーバーエラー。詳細はサーバーのログにのみ記録されます。
