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.

POSThttps://g.sendcorex.com/v1command: get_thread

Tham số

  • thread_idstringkhông bắt buộc

    Id hội thoại.

  • idstringkhông bắt buộc

    Id 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ộc

    true thêm body (html và 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

  • thread

    Tóm tắt hội thoại: thread_id, subject, participants, last_senders, message_count, unread_count và folders.

  • messages[]

    Thư theo thứ tự thời gian.

  • messages[].message_uid / message_id

    Id trong hộp thư và Message-ID SMTP.

  • messages[].in_reply_to / parent_uid / depth

    Vị trí của thư trong cây trả lời.

  • messages[].direction

    inbound hoặc outbound.

  • messages[].from_name / from_email / to / reply_to

    Dữ liệu phong bì.

  • messages[].subject / preview

    Tiêu đề và xem trước.

  • messages[].is_read / is_starred / is_important / has_attachments

    Trạng thái thư.

  • messages[].received_at

    Thời điểm thư được nhận hoặc gửi.

  • messages[].body

    Chỉ 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.

  • 401TOKEN_EXPIRED

    Access token đã hết hạn. Gọi Refresh Token và lặp lại yêu cầu.

  • 401INVALID_TOKEN

    Token sai định dạng, không xác định hoặc đã bị thu hồi.

  • 429RATE_LIMITED

    Hơ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.

  • CMDINVALID_ARGS

    Thiếu hoặc sai tham số bắt buộc.

  • CMDNOT_FOUND

    Thư, thread hoặc thư mục không tồn tại với token này.

  • CMDINTERNAL

    Lỗi máy chủ. Chi tiết chỉ được ghi vào log máy chủ.