รับอีเมล: การอ่าน

Search

ค้นหาในกล่องจดหมายตามผู้ส่ง โดเมน หัวเรื่อง เนื้อหา หรือป้ายกำกับ ด้วยตัวดำเนินการเดียวกับช่องค้นหาของ webmail

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

หากไม่มี field การค้นหาจะอัตโนมัติ: ที่อยู่อีเมลเต็มค้นตามผู้ส่งตรงตัว domain.com ค้นตามโดเมน และอย่างอื่นค้นในหัวเรื่อง เนื้อหา และชื่อผู้ส่ง

เมื่อใช้ตัวดำเนินการ (from:, is:unread…) ผลลัพธ์จะจัดกลุ่มตามบทสนทนา: หนึ่งแถวต่อเธรด ข้อความล่าสุดที่ตรง หากไม่มี in: จะไม่รวม Spam และถังขยะ

อาร์กิวเมนต์

  • querystringจำเป็น

    สิ่งที่ต้องการค้นหา สูงสุด 256 ตัวอักษร หากมีหลายคำ คำแรกมาจากดัชนีและคำอื่นกรองตามหัวเรื่องและตัวอย่าง

  • fieldstringไม่บังคับ

    จำกัดการค้นหาธรรมดาให้เป็น from, to, subject, body, sender หรือ label ไม่ใช้เมื่อคิวรีมีตัวดำเนินการ

  • limitnumberไม่บังคับ

    ขนาดหน้า 1 ถึง 100 ค่าเริ่มต้น 25

  • cursorstringไม่บังคับ

    next_cursor ของหน้าก่อน

เริ่มต้นอย่างรวดเร็ว

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "search",
        args: {
          query: "ana@client.com",
          field: "from",
          limit: 5
        }
      }
    ]
  },
  { 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": "search",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "messages": [
          {
            "message_uid": "Vj0xQUJDMTIz",
            "thread_id": "thr_9a1c4e72",
            "subject": "Invoice for September",
            "preview": "Hi, attached is the invoice for September…",
            "from_name": "Ana Costa",
            "from_email": "ana@client.com",
            "folders": [
              "INBOX"
            ],
            "is_read": false,
            "is_starred": false,
            "is_important": false,
            "received_at": "2026-10-09T14:21:07Z"
          }
        ],
        "has_more": false,
        "next_cursor": null
      }
    }
  ]
}

ฟิลด์การตอบกลับ

  • messages[]

    ข้อความที่ตรง ใหม่สุดก่อน แต่ละรายการมี message_uid, thread_id, subject, preview, from_name, from_email, folders แฟล็กอ่านแล้ว/ดาว/สำคัญ และ received_at

  • has_more / next_cursor

    การแบ่งหน้า

ตัวดำเนินการ

ใช้ร่วมกับคำธรรมดาได้ ค่าที่มีช่องว่างใส่ในเครื่องหมายคำพูด: subject:"new proposal" ใส่ - ข้างหน้าเพื่อตัดออก: -from:noreply, -newsletter

body ของคำขอ

{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "from:ana@client.com has:attachment newer_than:30d invoice"
      }
    }
  ]
}
  • from: / to:

    ผู้ส่ง / ผู้รับ (to หรือ cc) ส่วนหนึ่งของชื่อหรือที่อยู่

  • subject: / label:

    ข้อความหัวเรื่อง / ป้ายกำกับ

  • in:

    inbox, sent, archive, trash, spam, drafts, promotions, snoozed, scheduled, agents, not-subscribing หรือ id ของโฟลเดอร์กำหนดเอง

  • has:attachment

    เฉพาะข้อความที่มีไฟล์แนบ

  • is:unread / is:read / is:starred / is:important

    สถานะข้อความ

  • after: / before:

    วันที่ YYYY/MM/DD (หรือ YYYY-MM-DD) UTC

  • newer_than: / older_than:

    7d, 2w, 3m (30 วัน) หรือ 1y

มีเฉพาะตัวกรองโดยไม่มีคำค้น (is:unread in:archive) จะส่ง threads (รายการบทสนทนาของโฟลเดอร์นั้น) แทน messages

ตัวอย่างการค้นหา

body ของคำขอ

// subject + body + sender name
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "invoice september"
      }
    }
  ]
}

// exact sender
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "ana@client.com",
        "field": "from"
      }
    }
  ]
}

// everyone from a domain
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "client.com"
      }
    }
  ]
}

// messages with a label
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "cliente-vip",
        "field": "label"
      }
    }
  ]
}

ข้อผิดพลาด

ข้อผิดพลาดระดับ HTTP ส่งกลับ type, code และ message ข้อผิดพลาดที่มีเครื่องหมาย CMD จะกลับมาในผลลัพธ์ของคำสั่ง พร้อม HTTP 200

  • 401TOKEN_EXPIRED

    access token หมดอายุแล้ว เรียก Refresh Token แล้วส่งคำขอซ้ำ

  • 401INVALID_TOKEN

    โทเค็นผิดรูปแบบ ไม่รู้จัก หรือถูกเพิกถอน

  • 429RATE_LIMITED

    เกิน 15 คำขอ/วินาที หรือ 15 คำขอพร้อมกันสำหรับ IP + กล่องจดหมายเดียวกัน รอจำนวนวินาทีใน Retry-After

  • CMDINVALID_ARGS

    อาร์กิวเมนต์ที่จำเป็นหายไปหรือไม่ถูกต้อง

  • CMDINVALID_CURSOR

    cursor ผิดรูปแบบหรือเป็นของบัญชีหรือโฟลเดอร์อื่น

  • CMDINTERNAL

    ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์