รับอีเมล: จัดระเบียบ

Move

ย้ายข้อความหรือทั้งบทสนทนาระหว่างโฟลเดอร์ เช่น จาก Spam ไป INBOX หรือจาก INBOX ไปเก็บถาวร

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

เฉพาะ from_folder ที่ถูกแทนด้วย to_folder โฟลเดอร์อื่นของข้อความยังอยู่: คำตอบใน ["Sent","INBOX"] ที่ย้ายไปเก็บถาวรจะเป็น ["Sent","Archive"]

การย้ายข้อความไป Spam จะทำให้ผู้ส่งภายนอกไม่ได้รับความไว้วางใจ และอีเมลต่อไปของเขาเข้า Spam ทันที การย้ายออกจาก Spam ไม่คืนความไว้วางใจ ให้ใช้ set_trust

ตัวเลือก mark_unread, label และ conversation_status ทำงานหลังย้าย และเฉพาะ id ที่ย้าย

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

  • idsstring[]ไม่บังคับ

    id ข้อความสูงสุด 100 รายการ

  • idstringไม่บังคับ

    id ข้อความเดียว ใช้อันนี้หรือ ids

  • to_folderstringจำเป็น

    โฟลเดอร์ปลายทาง (slug หรือชื่อ) ไม่รับ Snoozed ให้ใช้ snooze

  • from_folderstringไม่บังคับ

    โฟลเดอร์ที่จะย้ายออก ค่าเริ่มต้นคือโฟลเดอร์ของข้อความที่ไม่ใช่ Sent

  • scopestringไม่บังคับ

    thread (ค่าเริ่มต้น) หรือ message

  • mark_unreadbooleanไม่บังคับ

    หลังย้าย ทำเครื่องหมายทั้งบทสนทนาว่ายังไม่อ่าน

  • labelstringไม่บังคับ

    หลังย้าย เพิ่มป้ายกำกับนี้ (สูงสุด 50 ตัวอักษร)

  • conversation_statusstringไม่บังคับ

    หลังย้าย ตั้งสถานะบทสนทนา: open, waiting หรือ resolved

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

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "move",
        args: {
          id: "Vj0xQUJDMTIz",
          from_folder: "INBOX",
          to_folder: "Archive"
        }
      }
    ]
  },
  { 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": "move",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "items": [
          {
            "id": "Vj0xQUJDMTIz",
            "ok": true,
            "data": {
              "from_folder": "INBOX",
              "to_folder": "Archive",
              "moved": 2
            }
          }
        ],
        "ok_count": 1,
        "failed_count": 0
      }
    }
  ]
}

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

  • items[].data.from_folder / to_folder

    โฟลเดอร์ที่เกี่ยวข้อง

  • items[].data.moved

    จำนวนข้อความที่ย้าย

  • items[].data.trust_status

    เฉพาะเมื่อย้ายไป Spam: สถานะความไว้วางใจใหม่ของผู้ส่ง

  • items[].data.sender / is_trusted

    เฉพาะเมื่อย้ายจาก Spam ไปโฟลเดอร์ปกติ (ไม่ใช่ถังขยะ): ผู้ส่งภายนอก พร้อม trust_status และ is_trusted

  • after

    เฉพาะเมื่อส่งตัวเลือก: สิ่งที่ใช้หลังย้าย

ย้ายออกจาก Spam พร้อมตัวเลือก

แต่ละรายการส่งกลับผู้ส่งภายนอก ส่งผู้ส่งให้ set_trust ด้วย emails เพื่อไว้วางใจในคำสั่งเดียว

Request · Response

{
  "commands": [
    {
      "command": "move",
      "args": {
        "ids": [
          "Vj0xQUJDMTIz",
          "Vj0xREVGNDU2"
        ],
        "from_folder": "Spam",
        "to_folder": "INBOX",
        "mark_unread": true,
        "label": "Leads",
        "conversation_status": "waiting"
      }
    }
  ]
}

{
  "items": [
    {
      "id": "Vj0xQUJDMTIz",
      "ok": true,
      "data": {
        "from_folder": "Spam",
        "to_folder": "INBOX",
        "moved": 1,
        "sender": "john@acme.com",
        "trust_status": "default",
        "is_trusted": false
      }
    },
    {
      "id": "Vj0xREVGNDU2",
      "ok": true,
      "data": {
        "from_folder": "Spam",
        "to_folder": "INBOX",
        "moved": 2,
        "sender": "ana@foo.io",
        "trust_status": "default",
        "is_trusted": false
      }
    }
  ],
  "ok_count": 2,
  "failed_count": 0,
  "after": {
    "marked_unread": 3,
    "label": "Leads",
    "labeled": 3,
    "conversation_status": "waiting",
    "conversations_updated": 2
  }
}

กู้บทสนทนาจาก Spam

ส่งทั้งสองคำสั่งในคำขอเดียว ทำงานตามลำดับ

body ของคำขอ

{
  "commands": [
    {
      "command": "move",
      "args": {
        "id": "Vj0xQUJDMTIz",
        "from_folder": "Spam",
        "to_folder": "INBOX",
        "scope": "thread"
      }
    },
    {
      "command": "set_flags",
      "args": {
        "id": "Vj0xQUJDMTIz",
        "is_read": true,
        "scope": "thread"
      }
    }
  ]
}

ข้อผิดพลาด

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

  • 401TOKEN_EXPIRED

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

  • 401INVALID_TOKEN

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

  • 429RATE_LIMITED

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

  • CMDINVALID_ARGS

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

  • CMDNOT_FOUND

    ไม่มีข้อความ เธรด หรือโฟลเดอร์นี้สำหรับโทเค็นนี้

  • CMDINTERNAL

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