---
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/search

メールの受信：読み取り

# Search

送信者、ドメイン、件名、本文、ラベルでメールボックスを検索します。Webmailの検索ボックスと同じ演算子が使えます。

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

`field`がない場合は自動判定です。完全なメールアドレスは送信者の完全一致、`domain.com`はドメイン、それ以外は件名、本文、送信者名で検索します。

演算子（`from:`、`is:unread`…）を使うと、結果は会話ごとにまとめられます（スレッドごとに1行、一致した最新のメッセージ）。`in:`がない場合、Spamとゴミ箱は除外されます。

## 引数

- `query` string 必須
検索語（256文字まで）。複数の語の場合、最初の語はインデックスから、残りは件名とプレビューで絞り込みます。
- `field` string 任意
通常の検索を`from`、`to`、`subject`、`body`、`sender`、`label`に限定します。クエリに演算子がある場合は無視されます。
- `limit` number 任意
ページサイズ（1〜100）。デフォルトは25。
- `cursor` string 任意
前のページの`next_cursor`。

## クイックスタート

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "search",
        args: {
          query: "ana@client.com",
          field: "from",
          limit: 5
        }
      }
    ]
  },
  { 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": "search",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "messages": [
          {
            "message_uid": "Vj0xQUJDMTIz",
            "thread_id": "thr_9a1c4e72",
            "subject": "Invoice for September",
            "preview": "Hi, attached is the invoice for September…",
            "from_name": "Ana Costa",
            "from_email": "ana@client.com",
            "folders": [
              "INBOX"
            ],
            "is_read": false,
            "is_starred": false,
            "is_important": false,
            "received_at": "2026-10-09T14:21:07Z"
          }
        ],
        "has_more": false,
        "next_cursor": null
      }
    }
  ]
}
```

### レスポンスの項目

- `messages[]`
一致したメッセージ（新しい順）。それぞれ`message_uid`、`thread_id`、`subject`、`preview`、`from_name`、`from_email`、`folders`、既読・スター・重要のフラグ、`received_at`を持ちます。
- `has_more / next_cursor`
ページネーション。

## 演算子

通常の語と組み合わせて使えます。空白を含む値は引用符で囲みます：`subject:"new proposal"`。除外するには先頭に`-`を付けます：`-from:noreply`、`-newsletter`。

リクエストボディ

```
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "from:ana@client.com has:attachment newer_than:30d invoice"
      }
    }
  ]
}
```

- `from: / to:`
送信者 / 受信者（toまたはcc）、名前やアドレスの一部。
- `subject: / label:`
件名のテキスト / ラベル。
- `in:`
`inbox`、`sent`、`archive`、`trash`、`spam`、`drafts`、`promotions`、`snoozed`、`scheduled`、`agents`、`not-subscribing`、またはカスタムフォルダーのid。
- `has:attachment`
添付ファイルのあるメッセージのみ。
- `is:unread / is:read / is:starred / is:important`
メッセージの状態。
- `after: / before:`
日付`YYYY/MM/DD`（または`YYYY-MM-DD`）、UTC。
- `newer_than: / older_than:`
`7d`、`2w`、`3m`（30日）、`1y`。

検索語のない絞り込みのみ（`is:unread in:archive`）の場合は、`messages`ではなく`threads`（そのフォルダーの会話一覧）を返します。

## 検索の例

リクエストボディ

```
// subject + body + sender name
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "invoice september"
      }
    }
  ]
}

// exact sender
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "ana@client.com",
        "field": "from"
      }
    }
  ]
}

// everyone from a domain
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "client.com"
      }
    }
  ]
}

// messages with a label
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "cliente-vip",
        "field": "label"
      }
    }
  ]
}
```

## エラー

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`
サーバーエラー。詳細はサーバーのログにのみ記録されます。
