ผู้ติดต่อ: กลุ่ม

Save Segment

บันทึกคิวรีพร้อมชื่อ เพื่อให้แอปและแดชบอร์ดเรียกใช้ภายหลัง ผู้ติดต่อไม่ถูกคัดลอก กลุ่มจะถูกประเมินใหม่ทุกครั้งที่เรียกใช้

POSThttps://g.sendcorex.com/v1/contactscommand: save_segment

ต้องมีขอบเขต contact:create บน API key ของคุณ

where ถูกตรวจสอบตอนบันทึก คีย์หรือฟิลด์ที่ไม่รู้จักจะล้มเหลวด้วย INVALID_ARGS ทันที ไม่ใช่ตอนเรียกใช้ครั้งถัดไป

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

  • segment_idstringไม่บังคับ

    id ของคุณ หากไม่ใส่จะสร้างให้ การบันทึกด้วย id ที่มีอยู่จะแทนที่กลุ่มนั้น

    เช่น "engaged-vips"

  • namestringไม่บังคับ

    ชื่อที่แสดง

    เช่น "Engaged VIPs"

  • whereobjectจำเป็น

    where เดียวกับ Query Contacts

  • sortstring | objectไม่บังคับ

    sort เดียวกับ Query Contacts

    เช่น "open_rate"

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

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/contacts',
  {
    commands: [
      {
        command: "save_segment",
        args: {
          segment_id: "engaged-vips",
          name: "Engaged VIPs",
          where: {
            tags: {
              has: "vip"
            },
            last_open_at: {
              within_days: 30
            }
          },
          sort: "open_rate"
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);

const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);

การตอบกลับ

{
  "type": "SUCCESS",
  "results": [
    {
      "command": "save_segment",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 14,
      "data": {
        "segment_id": "engaged-vips",
        "name": "Engaged VIPs",
        "where": {
          "tags": {
            "has": "vip"
          },
          "last_open_at": {
            "within_days": 30
          }
        },
        "sort": {
          "field": "open_rate"
        },
        "created_at": "2026-10-10T12:00:00.000Z",
        "updated_at": "2026-10-10T12:00:00.000Z"
      }
    }
  ]
}

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

  • (segment)

    กลุ่มตามที่บันทึก

ข้อผิดพลาด

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

  • 401INVALID_API_KEY

    API key ไม่มีอยู่ ถูกเพิกถอน หรือถูกปิดในแดชบอร์ด

  • 429RATE_LIMITED

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

  • CMDMISSING_SCOPE

    API key ไม่มีขอบเขตที่คำสั่งนี้ต้องการ คำสั่งอื่นในคำขอยังทำงาน

  • CMDINVALID_ARGS

    อาร์กิวเมนต์ที่จำเป็นหายไปหรือไม่ถูกต้อง: อีเมล ค่าฟิลด์ ตัวเลือก enum คีย์ where id รายชื่อ…

  • CMDINTERNAL

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