---
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/send-trust/set-trust

メールの受信：送信と信頼

# Set Trust

送信者を信頼済みまたは信頼しないに設定するか、デフォルトに戻します。

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

`default`で判断を削除します。メッセージをSpamに移すと、その送信者も`untrusted`になります。

`emails`で多くの送信者をまとめて更新できます。たとえば`move`でSpamから出したときに返る`sender`の値です。ゲストには`rules`権限が必要です。

## 引数

- `id` string 任意
メッセージid。その会話の外部送信者を使います。
- `from_email` string 任意
送信者のメールアドレス。これか`id`を使います。
- `emails` string[] 任意
送信者のメールアドレスを最大100件。レスポンスは一括形式で、メールアドレスごとに1件。
- `value` string 必須
`default`、`trusted`、`untrusted`。

## クイックスタート

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "set_trust",
        args: {
          from_email: "client@example.com",
          value: "trusted"
        }
      }
    ]
  },
  { 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": "set_trust",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "from_email": "client@example.com",
        "trust_status": "trusted",
        "is_trusted": true
      }
    }
  ]
}
```

### レスポンスの項目

- `from_email`
更新した送信者。
- `trust_status`
新しいステータス。
- `is_trusted`
ステータスが`trusted`の場合のみ`true`。
- `items`
`emails`の場合：アドレスごとに1件、および`ok_count`と`failed_count`。

## 多くの送信者をまとめて信頼

1つのコマンドで最大100件のアドレス。

Request · Response

```
{
  "commands": [
    {
      "command": "set_trust",
      "args": {
        "emails": [
          "john@acme.com",
          "ana@foo.io"
        ],
        "value": "trusted"
      }
    }
  ]
}

{
  "items": [
    {
      "id": "john@acme.com",
      "ok": true,
      "data": {
        "from_email": "john@acme.com",
        "trust_status": "trusted",
        "is_trusted": true
      }
    },
    {
      "id": "ana@foo.io",
      "ok": true,
      "data": {
        "from_email": "ana@foo.io",
        "trust_status": "trusted",
        "is_trusted": true
      }
    }
  ],
  "ok_count": 2,
  "failed_count": 0
}
```

## エラー

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`NOT_FOUND`
このトークンでは、そのメッセージ、スレッド、フォルダーは存在しません。
- CMD`INTERNAL`
サーバーエラー。詳細はサーバーのログにのみ記録されます。
