รับอีเมล: การส่งและความไว้วางใจ

Set Trust

ทำเครื่องหมายผู้ส่งว่าไว้วางใจหรือไม่ไว้วางใจ หรือกลับเป็นค่าเริ่มต้น

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

default ลบการตัดสินใจ การย้ายข้อความไป Spam ก็ทำให้ผู้ส่งเป็น untrusted ด้วย

ใช้ emails เพื่ออัปเดตผู้ส่งหลายรายพร้อมกัน เช่น ค่า sender ที่ move ออกจาก Spam ส่งกลับ ผู้เยี่ยมชมต้องมีสิทธิ์ rules

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

  • idstringไม่บังคับ

    id ข้อความ จะใช้ผู้ส่งภายนอกของบทสนทนานั้น

  • from_emailstringไม่บังคับ

    ที่อยู่อีเมลผู้ส่ง ใช้อันนี้หรือ id

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

    ที่อยู่อีเมลผู้ส่งสูงสุด 100 รายการ การตอบเป็นแบบกลุ่ม หนึ่งรายการต่ออีเมล

  • valuestringจำเป็น

    default, trusted หรือ untrusted

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

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "set_trust",
        args: {
          from_email: "client@example.com",
          value: "trusted"
        }
      }
    ]
  },
  { 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": "set_trust",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "from_email": "client@example.com",
        "trust_status": "trusted",
        "is_trusted": true
      }
    }
  ]
}

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

  • from_email

    ผู้ส่งที่อัปเดต

  • trust_status

    สถานะใหม่

  • is_trusted

    true เฉพาะเมื่อสถานะเป็น trusted

  • items

    เมื่อใช้ emails: หนึ่งรายการต่อที่อยู่ บวก ok_count และ failed_count

ไว้วางใจผู้ส่งหลายรายพร้อมกัน

คำสั่งเดียว สูงสุด 100 ที่อยู่

Request · Response

{
  "commands": [
    {
      "command": "set_trust",
      "args": {
        "emails": [
          "john@acme.com",
          "ana@foo.io"
        ],
        "value": "trusted"
      }
    }
  ]
}

{
  "items": [
    {
      "id": "john@acme.com",
      "ok": true,
      "data": {
        "from_email": "john@acme.com",
        "trust_status": "trusted",
        "is_trusted": true
      }
    },
    {
      "id": "ana@foo.io",
      "ok": true,
      "data": {
        "from_email": "ana@foo.io",
        "trust_status": "trusted",
        "is_trusted": true
      }
    }
  ],
  "ok_count": 2,
  "failed_count": 0
}

ข้อผิดพลาด

ข้อผิดพลาดระดับ 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

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