Nhận email: đọc thư
Get Thread
Mở cả cuộc hội thoại: tóm tắt và mọi thư theo thứ tự thời gian, tùy chọn kèm nội dung.
https://g.sendcorex.com/v1command: get_threadTham số
thread_idstringkhông bắt buộcId hội thoại.
idstringkhông bắt buộcId của bất kỳ thư nào trong hội thoại. Dùng cái này hoặc
thread_id.include_bodybooleankhông bắt buộctruethêmbody(htmlvàtext) vào mỗi thư.
Bắt đầu nhanh
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1',
{
commands: [
{
command: "get_thread",
args: {
id: "Vj0xQUJDMTIz",
include_body: true
}
}
]
},
{ 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);Phản hồi
{
"type": "SUCCESS",
"results": [
{
"command": "get_thread",
"id": "0",
"type": "SUCCESS",
"data": {
"thread": {
"thread_id": "thr_9a1c4e72",
"subject": "Invoice for September",
"participants": [
"ana@client.com",
"you@yourdomain.com"
],
"last_senders": [
"ana@client.com"
],
"message_count": 2,
"unread_count": 1,
"folders": [
"INBOX",
"Sent"
]
},
"messages": [
{
"message_uid": "Vj0xQUJDMDA5",
"message_id": "<4c1d…@mail.client.com>",
"in_reply_to": null,
"parent_uid": null,
"depth": 0,
"folders": [
"INBOX"
],
"from_name": "Ana Costa",
"from_email": "ana@client.com",
"direction": "inbound",
"to": [
{
"email": "you@yourdomain.com"
}
],
"reply_to": [],
"subject": "Invoice for September",
"preview": "Hi, attached is the invoice for September…",
"is_read": true,
"is_starred": false,
"is_important": false,
"has_attachments": false,
"received_at": "2026-10-09T09:02:41Z",
"body": {
"html": "<p>Hi, attached is the invoice for September.</p>",
"text": "Hi, attached is the invoice for September."
}
}
]
}
}
]
}Trường phản hồi
threadTóm tắt hội thoại:
thread_id,subject,participants,last_senders,message_count,unread_countvàfolders.messages[]Thư theo thứ tự thời gian.
messages[].message_uid / message_idId trong hộp thư và Message-ID SMTP.
messages[].in_reply_to / parent_uid / depthVị trí của thư trong cây trả lời.
messages[].directioninboundhoặcoutbound.messages[].from_name / from_email / to / reply_toDữ liệu phong bì.
messages[].subject / previewTiêu đề và xem trước.
messages[].is_read / is_starred / is_important / has_attachmentsTrạng thái thư.
messages[].received_atThời điểm thư được nhận hoặc gửi.
messages[].bodyChỉ với
include_body: true:{ html, text }.
Lỗi
Lỗi ở mức HTTP trả về type, code và message. Lỗi đánh dấu CMD được trả về trong kết quả lệnh, với HTTP 200.
- 401
TOKEN_EXPIREDAccess token đã hết hạn. Gọi Refresh Token và lặp lại yêu cầu.
- 401
INVALID_TOKENToken sai định dạng, không xác định hoặc đã bị thu hồi.
- 429
RATE_LIMITEDHơn 15 yêu cầu/giây hoặc 15 yêu cầu đồng thời cho cùng IP + hộp thư. Chờ số giây trong Retry-After.
- CMD
INVALID_ARGSThiếu hoặc sai tham số bắt buộc.
- CMD
NOT_FOUNDThư, thread hoặc thư mục không tồn tại với token này.
- CMD
INTERNALLỗi máy chủ. Chi tiết chỉ được ghi vào log máy chủ.