รับอีเมล: การอ่าน
Get Messages
อ่านข้อความสูงสุด 50 ฉบับตาม id พร้อมเนื้อหา รายการไฟล์แนบ และเฮดเดอร์
https://g.sendcorex.com/v1command: get_messagesเนื้อหา HTML ส่งกลับแบบดิบ ไม่ผ่านการกรอง ให้กรองในไคลเอนต์ก่อนแสดง
อาร์กิวเมนต์
idsstring[]ไม่บังคับid ข้อความสูงสุด 50 รายการ
idstringไม่บังคับid ข้อความเดียว ใช้อันนี้หรือ
idsincludestring[]ไม่บังคับสิ่งที่จะเพิ่มในแต่ละข้อความ:
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…) บวกสิ่งที่ขอในincludemessages[].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_reasonsเฉพาะใน
AgentsและNotSubscribing: คะแนนการคัดกรองและสิ่งที่ทำให้เกิดmessages[].full_headersทุกอย่างใน
headersบวกheaders_json,received_chain,spf_result,dkim_result,dmarc_resultและspam_resultmessages[].attachmentsรายการพร้อม
attachment_id,file_name,mime_type,size_bytes,inline,content_idและฟิลด์scan_*ไม่รวมตัวไฟล์not_foundid ที่ไม่มีในกล่องจดหมายนี้
ดาวน์โหลดไฟล์แนบ
รายการไฟล์แนบไม่มีข้อมูลไบนารี ใช้ 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เกิน 15 คำขอ/วินาที หรือ 15 คำขอพร้อมกันสำหรับ IP + กล่องจดหมายเดียวกัน รอจำนวนวินาทีใน Retry-After
- CMD
INVALID_ARGSอาร์กิวเมนต์ที่จำเป็นหายไปหรือไม่ถูกต้อง
- CMD
INTERNALข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์