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

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

# Get Counters

メールボックス全体と各フォルダーの合計・未読のカウンターを取得します。

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

ルートの合計は一意のメッセージを数えます。各フォルダー内の数は一覧の項目を数えるため、`Sent`と`INBOX`の両方にある返信は各フォルダーで1回ずつ数えます。

## 引数

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

## クイックスタート

```
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`
同じIP + メールボックスで毎秒15リクエストまたは同時15件を超えました。Retry-Afterの秒数だけ待ってください。
- CMD`INTERNAL`
サーバーエラー。詳細はサーバーのログにのみ記録されます。
