メールの受信:読み取り
List Threads
フォルダーの会話をGmailのように一覧表示します。未読、スター、重要、添付ファイル、日付で絞り込めます。
https://g.sendcorex.com/v1command: list_threads各項目は会話です。last_message_uidを使ってget_threadまたはget_messagesで開きます。
引数
folderstring任意一覧表示するフォルダー。デフォルトは
INBOX。limitnumber任意ページサイズ(1〜100)。デフォルトは25。
cursorstring任意前のページの
next_cursor。is_readboolean任意falseで未読メッセージがある会話だけを返します。is_starredboolean任意スターで絞り込み。
is_importantboolean任意重要度で絞り込み。
has_attachmentsboolean任意添付ファイルで絞り込み。
afterstring任意最後のメッセージがこの日付以降(この日を含む)の会話のみ。RFC 3339、
YYYY-MM-DD(UTC)、エポックミリ秒。例:
"2026-10-01"beforestring任意最後のメッセージがこの日付より前(この日を含まない)の会話のみ。形式は
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_uidget_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_EXPIREDaccess tokenの有効期限が切れました。Refresh Tokenを呼んでリクエストを繰り返してください。
- 401
INVALID_TOKENトークンの形式が不正、不明、または取り消されています。
- 429
RATE_LIMITED同じIP + メールボックスで毎秒15リクエストまたは同時15件を超えました。Retry-Afterの秒数だけ待ってください。
- CMD
INVALID_ARGS必須の引数がないか不正です。
- CMD
INVALID_CURSORカーソルが不正か、別のアカウントまたはフォルダーのものです。
- CMD
INTERNALサーバーエラー。詳細はサーバーのログにのみ記録されます。