รับอีเมล: จดหมายข่าว

Get Unsubscribe Options

คุณยกเลิกรับจากรายชื่อที่ส่งอีเมลนี้ได้ไหม อย่างไร และทำไปแล้วหรือยัง

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

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

  • idstringจำเป็น

    อีเมลที่คุณได้รับ

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

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "get_unsubscribe_options",
        args: {
          id: "Vj0xQUJDMTIz"
        }
      }
    ]
  },
  { 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": "get_unsubscribe_options",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "can_unsubscribe": true,
        "method": "one_click",
        "one_click": true,
        "http": "https://shop.com/u/abc",
        "mailto": "mailto:unsub@shop.com?subject=unsubscribe",
        "list_id": "Shop News <news.shop.com>",
        "list_key": "news.shop.com",
        "from_email": "news@shop.com"
      }
    }
  ]
}

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

  • method

    one_click, mailto หรือ http — สิ่งที่ unsubscribe จะใช้

  • list_key

    List-Id เมื่ออีเมลมี ไม่เช่นนั้นคือผู้ส่ง จดหมายข่าวเดียวกันจากที่อยู่อื่นคือรายชื่อเดียวกัน

  • status

    แสดงเมื่อคุณขอแล้ว: done, pending หรือ failed

ข้อผิดพลาด

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

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