メールの受信:読み取り
Get Messages
idで最大50件のメッセージを、本文、添付ファイル一覧、ヘッダーとともに読み取ります。
https://g.sendcorex.com/v1command: get_messagesHTML本文はサニタイズされず、そのまま返ります。表示前にクライアント側でサニタイズしてください。
引数
idsstring[]任意最大50件のメッセージid。
idstring任意単一のメッセージid。これか
idsを使います。includestring[]任意各メッセージに追加するもの:
body、attachments、headers、full_headers。デフォルトは["body","attachments"]。例:
["body", "headers", "attachments"]
クイックスタート
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1',
{
commands: [
{
command: "get_messages",
args: {
ids: [
"Vj0xQUJDMTIz"
],
include: [
"body",
"headers",
"attachments"
]
}
}
]
},
{ 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": "get_messages",
"id": "0",
"type": "SUCCESS",
"data": {
"messages": [
{
"message_uid": "Vj0xQUJDMTIz",
"thread_id": "thr_9a1c4e72",
"message_id": "<3f2a1b4c@SCOREX123MB45.prd.sendcorex.com>",
"folders": [
"INBOX"
],
"labels": [
"cliente-vip"
],
"from_name": "Ana Costa",
"from_email": "ana@client.com",
"to": [
{
"email": "you@yourdomain.com"
}
],
"cc": [],
"bcc": [],
"subject": "Invoice for September",
"is_read": false,
"is_starred": false,
"is_important": false,
"snoozed_until": null,
"received_at": "2026-10-09T14:21:07Z",
"body": {
"html": "<p>Hi, attached is the invoice.</p>",
"text": "Hi, attached is the invoice.",
"external_images": false
},
"headers": {
"content_type": "multipart/mixed",
"ip_address": "203.0.113.10",
"is_tls": true,
"spf_success": true,
"dkim_success": true,
"dmarc_success": true,
"spam_score": 0.4,
"list_unsubscribe": null
},
"attachments": [
{
"attachment_id": "Vj0xQVRUMDE",
"file_name": "invoice.pdf",
"mime_type": "application/pdf",
"size_bytes": 48213,
"inline": false,
"content_id": null
}
]
}
],
"not_found": []
}
}
]
}レスポンスの項目
messages[]エンベロープと状態の項目(
folders、labels、to、cc、bcc、references、snoozed_until…)と、includeで指定したもの。messages[].body{ html, text, external_images }。HTMLは生のままでサニタイズされていません。messages[].headerscontent_type、ip_address、is_tls、spf_success、dkim_success、dmarc_success、spam_score、list_unsubscribe、list_id、sender_provider(配信時に検証した送信元)、rules_matched…messages[].agent_score / agent_reasonsAgentsとNotSubscribingのみ:振り分けのスコアとその理由。messages[].full_headersheadersの内容に加え、headers_json、received_chain、spf_result、dkim_result、dmarc_result、spam_result。messages[].attachmentsattachment_id、file_name、mime_type、size_bytes、inline、content_id、scan_*項目のリスト。ファイル本体は含まれません。not_foundこのメールボックスに存在しないid。
添付ファイルのダウンロード
添付ファイル一覧にバイナリは含まれません。attachment_idを取得し、Raw Messageルートでファイルをダウンロードしてください。
GET /v1/raw?message_id=<message_uid>&attachment_id=<attachment_id>。元のMIMEタイプはX-Original-Content-Typeで返ります。
エラー
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
INTERNALサーバーエラー。詳細はサーバーのログにのみ記録されます。