---
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/reading/list-threads

メールの受信：読み取り

# List Threads

フォルダーの会話をGmailのように一覧表示します。未読、スター、重要、添付ファイル、日付で絞り込めます。

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

各項目は会話です。`last_message_uid`を使って`get_thread`または`get_messages`で開きます。

## 引数

- `folder` string 任意
一覧表示するフォルダー。デフォルトは`INBOX`。
- `limit` number 任意
ページサイズ（1〜100）。デフォルトは25。
- `cursor` string 任意
前のページの`next_cursor`。
- `is_read` boolean 任意
`false`で未読メッセージがある会話だけを返します。
- `is_starred` boolean 任意
スターで絞り込み。
- `is_important` boolean 任意
重要度で絞り込み。
- `has_attachments` boolean 任意
添付ファイルで絞り込み。
- `after` string 任意
最後のメッセージがこの日付以降（この日を含む）の会話のみ。RFC 3339、`YYYY-MM-DD`（UTC）、エポックミリ秒。
例： `"2026-10-01"`
- `before` string 任意
最後のメッセージがこの日付より前（この日を含まない）の会話のみ。形式は`after`と同じ。
例： `"2026-10-08T00:00:00+08:00"`

## クイックスタート

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "list_threads",
        args: {
          folder: "INBOX",
          is_read: false,
          limit: 20
        }
      }
    ]
  },
  { 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_threads",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "threads": [
          {
            "thread_id": "thr_9a1c4e72",
            "folder": "INBOX",
            "subject": "Invoice for September",
            "preview": "Hi, attached is the invoice for September…",
            "from_name": "Ana Costa",
            "from_email": "ana@client.com",
            "participants": [
              "ana@client.com",
              "you@yourdomain.com"
            ],
            "last_senders": [
              "ana@client.com"
            ],
            "message_count": 2,
            "thread_message_count": 3,
            "unread_count": 1,
            "has_unread": true,
            "has_starred": false,
            "has_important": false,
            "has_attachments": false,
            "last_message_uid": "Vj0xQUJDMTIz",
            "last_message_at": "2026-10-09T14:21:07Z"
          }
        ],
        "has_more": true,
        "next_cursor": "eyJwIjoyfQ"
      }
    }
  ]
}
```

### レスポンスの項目

- `threads[].thread_id`
会話のid。
- `threads[].folder`
一覧表示しているフォルダー。
- `threads[].subject`
会話の件名。
- `threads[].preview`
最新メッセージの短いプレビュー。
- `threads[].from_name / from_email`
最新メッセージの送信者。
- `threads[].participants`
会話の参加者全員。
- `threads[].last_senders`
最新のメッセージを書いた人。
- `threads[].message_count`
このフォルダー内のメッセージ数。
- `threads[].thread_message_count`
会話全体のメッセージ数。
- `threads[].unread_count / has_unread`
会話内の未読メッセージ数。
- `threads[].has_starred / has_important / has_attachments`
会話のフラグ。
- `threads[].last_message_uid`
`get_messages`や`get_thread`で会話を開くためのid。
- `threads[].last_message_at`
最新メッセージの日付。
- `has_more / next_cursor`
ページネーション。次のページを取得するには`next_cursor`を`cursor`として送ります。

## 絞り込みと速度

`is_read: false`、`is_starred: true`、`is_important: true`は専用のインデックスを使うため、フォルダー全体ではなく一致する会話だけを調べます。組み合わせると1つのインデックス（スター、重要、未読の順）を使い、残りはその上で絞り込みます。`after`と`before`はキー範囲なので、期間外は走査しません。`has_attachments`と、スター・重要の`false`値はフォルダーを走査します。

期間内の未読の会話

```
{
  "commands": [
    {
      "command": "list_threads",
      "args": {
        "is_read": false,
        "after": "2026-10-01",
        "before": "2026-10-08T00:00:00+08:00"
      }
    }
  ]
}
```

## ページネーション

`has_more`が`true`の場合は、`cursor`に`next_cursor`を設定してもう一度コマンドを呼びます。

Node.js

```
let cursor;
const threads = [];

do {
  const [result] = await call({
    command: 'list_threads',
    args: { folder: 'INBOX', limit: 100, ...(cursor ? { cursor } : {}) },
  });
  threads.push(...result.data.threads);
  cursor = result.data.has_more ? result.data.next_cursor : null;
} while (cursor);
```

`call`は、Run Commandsのように`{ commands: [...] }`を`/v1`にPOSTして`results`を返す任意のヘルパーです。

## エラー

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`INVALID_ARGS`
必須の引数がないか不正です。
- CMD`INVALID_CURSOR`
カーソルが不正か、別のアカウントまたはフォルダーのものです。
- CMD`INTERNAL`
サーバーエラー。詳細はサーバーのログにのみ記録されます。
