IM
JA
ドキュメントホーム
メニュー
ガイド

検索 読み取り 本体と部品

同期されたメタデータを検索し、オンデマンドで本文と一部のコンテンツを取得します。

inbox-manager client-flow

ボディとパーツの検索読み取り

目的: 同期されたメタデータを検索し、オンデマンドで本文と一部のコンテンツを取得します。

UI フロー

  1. ユーザーは件名/送信者で検索します。
  2. UI は /api/accounts/:account_id/emails/search を呼び出します。
  3. ユーザーがメッセージを開きます。
  4. UI は、完全に解析されたメッセージを取得するために /body を呼び出します。
  5. UI は、選択したパーツのプレビューまたはダウンロードのために /parts を呼び出し、次に /parts/:part_id/content を呼び出します。

クライアント ライブラリ フロー

const results = await api.emails.search(accountId, {
  query: "invoice",
  limit: 20,
});
const emailId = results.data[0]?.id;
if (emailId) {
  const body = await api.emails.getBody(accountId, emailId);
  const parts = await api.emails.listParts(accountId, emailId);
  const firstPart = parts.data[0];
  if (firstPart) {
    await api.emails.getPartContent(accountId, emailId, firstPart.id);
  }
}

HTTP/カールフロー

API_BASE_URL="https://api.inbox-manager.com"

curl -sS -X POST "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/emails/search" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data '{"query":"invoice","limit":20,"offset":0}'

curl -sS "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/emails/${EMAIL_ID}/body" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

curl -sS "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/emails/${EMAIL_ID}/parts" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

curl -sS "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/emails/${EMAIL_ID}/parts/${PART_ID}/content" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

予想される競合ケース

  • 409 email_part_content_hash_mismatch
  • 409 email_part_metadata_out_of_sync

検証スクリプト

  • scripts/provider_parts_content_flow.sh