---
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/contacts/activity/get-stats

連絡先：アクティビティ

# 統計の取得

アカウント全体の合計を1回の呼び出しで：連絡先数、ステータス別の連絡先、リスト別のメンバー、タグ別の連絡先。

POST `https://g.sendcorex.com/v1/contacts` command: get_stats

API keyに`contact:read`スコープが必要です。

変更のたびに更新されるカウンターなので、ダッシュボードを開くときに呼んでも負荷は小さいです。

## 引数

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

## クイックスタート

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/contacts',
  {
    commands: [
      {
        command: "get_stats"
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);

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_stats",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 14,
      "data": {
        "total": 2040,
        "status": {
          "subscribed": 1951,
          "unsubscribed": 61,
          "bounced": 22,
          "complained": 3,
          "blocked": 3
        },
        "lists": {
          "customers": {
            "total": 1834,
            "ok": 1790,
            "opened": 912,
            "clicked": 233
          },
          "newsletter": {
            "total": 640,
            "ok": 602,
            "opened": 288,
            "clicked": 41
          }
        },
        "tags": {
          "customer": 1834,
          "vip": 120,
          "black-friday": 512
        }
      }
    }
  ]
}
```

### レスポンスの項目

- `total`
アカウント内の連絡先。
- `status`
グローバルステータス別の連絡先。
- `lists.<id>`
`total`のメンバー、送信可能な`ok`のメンバー、`opened`または`clicked`したメンバー。
- `tags`
タグ別の連絡先。

## エラー

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

- 401`INVALID_API_KEY`
API keyが存在しないか、取り消されたか、ダッシュボードで無効化されています。
- 429`RATE_LIMITED`
同じIP + API keyで毎秒15リクエストまたは同時15件を超えました。Retry-Afterの秒数だけ待ってください。
- CMD`MISSING_SCOPE`
API keyにこのコマンドに必要なスコープがありません。リクエスト内のほかのコマンドは実行されます。
- CMD`INTERNAL`
サーバーエラー。詳細はサーバーのログにのみ記録されます。
