ผู้ติดต่อ: การค้นหา
ค้นหาผู้ติดต่อ
ค้นหาผู้ติดต่อด้วยการผสมรายชื่อ สถานะ แท็ก ฟิลด์กำหนดเอง การมีส่วนร่วม และวันที่ คุณบอกว่าต้องการใคร เซิร์ฟเวอร์เลือกดัชนีเอง
https://g.sendcorex.com/v1/contactscommand: query_contactsต้องมีขอบเขต contact:read บน API key ของคุณ
เซิร์ฟเวอร์วัดเงื่อนไขที่มีดัชนีทุกข้อใน where สแกนข้อที่คัดกรองได้มากที่สุด แล้วตรวจผู้ติดต่อแต่ละรายกับ where ทั้งหมด คุณไม่ต้องเลือกดัชนีเลย
อาร์กิวเมนต์
whereobjectไม่บังคับเงื่อนไขที่รวมด้วย AND ไม่ใส่ (หรือส่ง
{}) เพื่อรับผู้ติดต่อทั้งหมด ดูข้อมูลอ้างอิงwhereด้านล่างsortstring | objectไม่บังคับชื่อฟิลด์หรือ
{ "field": "<name>" }ดูการเรียงด้านล่างเช่น
"open_rate"limitnumberไม่บังคับขนาดหน้า 1 ถึง 1000 ค่าเริ่มต้น 50
cursorstringไม่บังคับnext_cursorของหน้าก่อน ส่งพร้อมwhereและsortเดิมselectstring[]ไม่บังคับส่งกลับเฉพาะส่วนเหล่านี้ของผู้ติดต่อแต่ละราย เช่น
["status", "fields.plan", "stats.open_count"]emailจะกลับมาเสมอ หากไม่ใส่จะได้ผู้ติดต่อทั้งหมด
เริ่มต้นอย่างรวดเร็ว
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1/contacts',
{
commands: [
{
command: "query_contacts",
args: {
where: {
list: "customers",
sendable: true,
tags: {
has: "vip",
none: [
"churn"
]
},
fields: {
plan: {
in: [
"pro",
"business"
]
},
age: {
gte: 25,
lte: 40
}
},
last_open_at: {
within_days: 30
}
},
sort: "open_rate",
limit: 100
}
}
]
},
{ 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": "query_contacts",
"id": "0",
"type": "SUCCESS",
"took_ms": 14,
"data": {
"contacts": [
{
"email": "ana@acme.com",
"domain": "acme.com",
"first_name": "Ana",
"last_name": "Costa",
"phone": null,
"company": "Acme",
"locale": "pt-BR",
"timezone": "America/Sao_Paulo",
"source": "checkout",
"status": "subscribed",
"status_reason": null,
"status_at": "2026-10-13T06:05:08.323Z",
"created_at": "2026-10-13T06:05:08.323Z",
"updated_at": "2026-10-14T09:12:40.118Z",
"tags": [
"customer",
"vip"
],
"lists": {
"customers": {
"subscribed": true,
"sendable": true,
"added_at": "2026-10-13T06:05:08.323Z",
"unsubscribed_at": null
}
},
"fields": {
"plan": "pro",
"age": 31,
"city": "São Paulo"
},
"stats": {
"sent_count": 12,
"open_count": 7,
"click_count": 2,
"bounce_count": 0,
"complaint_count": 0,
"open_rate": 0.58,
"click_rate": 0.17,
"first_open_at": "2026-10-13T08:41:02.000Z",
"last_open_at": "2026-10-14T21:03:55.000Z",
"last_click_at": "2026-10-14T21:04:10.000Z",
"last_sent_at": "2026-10-14T20:58:31.000Z"
}
}
],
"has_more": true,
"next_cursor": "eyJkIjoidGFnOnZpcCJ9",
"plan": {
"driver": "tag:vip",
"examined": 412,
"keys_only": false,
"ms": {
"scan": 4,
"fetch": 9,
"filter": 1,
"total": 14
}
}
}
}
]
}ฟิลด์การตอบกลับ
contactsผู้ติดต่อที่ตรง ทั้งหมด หรือเฉพาะส่วนที่ขอด้วย
selecthas_more / next_cursorการแบ่งหน้า ขณะที่
has_moreเป็นtrueส่งnext_cursorเป็นcursorพร้อมwhereและsortเดิมplan.driverดัชนีที่เซิร์ฟเวอร์เลือกสแกน เช่น
tag:vipหรือlist:customersplan.examinedจำนวนรายการดัชนีที่อ่านเพื่อเติมหน้านี้
plan.keys_onlytrueเมื่อหน้านี้ตอบจากดัชนีอย่างเดียว ไม่ต้องโหลดผู้ติดต่อplan.msเวลาที่ใช้สแกน ดึง กรอง และรวม หน่วยมิลลิวินาที
ออบเจกต์ where
ทุกคีย์ไม่บังคับและต้องตรงทั้งหมด ข้อความ ตัวเลือก enum และแท็กไม่สนตัวพิมพ์และวรรณยุกต์
email"ana@acme.com"อ่านผู้ติดต่อนั้นโดยตรงsearch"jo sil"แต่ละคำต้องเป็นส่วนต้นของคำในชื่อ นามสกุล บริษัท หรืออีเมลstatus"subscribed"รายการอย่าง["bounced", "complained"],{ "in": [...] }หรือ{ "not": "subscribed" }list"customers"หรือ{ "in": ["a", "b"] }สำหรับสมาชิกของรายชื่อใดก็ได้sendabletrueเมื่อมีlist: สมัครรับรายชื่อนั้นและมีสถานะsubscribedเมื่อไม่มีlist: สถานะsubscribedtags{ "has": "vip" },{ "all": [...] },{ "any": [...] },{ "none": [...] }ใช้ร่วมกันได้domain"gmail.com"หรือ{ "in": [...] }fields{ "plan": "pro" },{ "age": { "gte": 25 } },{ "plan": { "in": [...] } },{ "city": { "contains": "paul" } },{ "company": { "exists": true } }ฟิลด์ต้องมีอยู่sent_count, open_count, click_count, bounce_count, complaint_count, open_rate, click_rateตัวเลข หรือ
{ "gte", "gt", "lte", "lt", "eq" }อัตราอยู่ระหว่าง 0 ถึง 1created_at, first_open_at, last_open_at, last_click_at, last_sent_at{ "within_days": 30 },{ "after": "2026-01-01" },{ "before": "..." },{ "never": true }หรือ{ "exists": true }campaign_opened, campaign_clickedid แคมเปญ ผู้ติดต่อที่เปิดหรือคลิกแคมเปญนั้น
คีย์ที่ไม่รู้จัก หรือฟิลด์ที่ไม่มีอยู่ จะทำให้คำสั่งล้มเหลวด้วย INVALID_ARGS แทนที่จะเงียบและไม่พบอะไร
ตัวดำเนินการสำหรับฟิลด์กำหนดเอง
ฟิลด์กำหนดเองแต่ละฟิลด์มีดัชนีของตัวเอง ตัวกรองเหล่านี้จึงเร็วแม้ในรายชื่อใหญ่
เท่ากับ{ "plan": "pro" }ค่าข้อความและ enum ไม่สนตัวพิมพ์และวรรณยุกต์ ในฟิลด์multi_enumจะตรงกับผู้ติดต่อที่มีตัวเลือกนั้นin{ "plan": { "in": ["pro", "business"] } }ค่าใดก็ได้gte, gt, lte, lt, eqช่วงในฟิลด์
numberและdateวันที่รับYYYY-MM-DDหรือ ISOcontainsส่วนหนึ่งของค่า
textไม่สนตัวพิมพ์และวรรณยุกต์existstrueสำหรับผู้ติดต่อที่มีค่าfalseสำหรับที่ไม่มี
การเรียง
แต่ละฟิลด์การเรียงมีทิศทางตายตัว การเรียงตามฟิลด์กำหนดเองหรือวันที่จะส่งเฉพาะผู้ติดต่อที่มีค่า: last_open_at ส่งเฉพาะคนที่เปิดอย่างน้อยหนึ่งครั้ง
emailA ถึง Z
fields.<key>จากน้อยไปมาก ใช้กับฟิลด์
multi_enumไม่ได้sent_count, open_count, click_count, open_rate, click_rateมากสุดก่อน
created_at, last_open_at, last_click_at, last_sent_atล่าสุดก่อน
การแบ่งหน้า
แต่ละการเรียกอ่านรายการดัชนีได้สูงสุด 20,000 รายการ เมื่อถึงเพดานก่อนเต็มหน้า จะส่งผู้ติดต่อน้อยลง (บางครั้งไม่มีเลย) พร้อม has_more: true ทำต่อไปขณะที่ has_more เป็น true อย่าหยุดที่หน้าว่าง
Node.js
const where = { list: 'customers', sendable: true };
const emails = [];
let cursor;
do {
const [result] = await call({
command: 'query_contacts',
args: { where, select: ['email'], limit: 1000, ...(cursor ? { cursor } : {}) },
});
emails.push(...result.data.contacts.map((c) => c.email));
cursor = result.data.has_more ? result.data.next_cursor : null;
} while (cursor);call คือตัวช่วยใดก็ได้ที่ POST { commands: [...] } ไปที่ /v1/contacts และส่งกลับ results เหมือนใน Run Commands
ตัวอย่างเพิ่มเติม
body คำขอ
{
"commands": [
{
"command": "query_contacts",
"id": "inactive",
"args": {
"where": {
"list": "customers",
"last_open_at": {
"never": true
},
"created_at": {
"before": "2026-07-01"
}
}
}
},
{
"command": "query_contacts",
"id": "bounced",
"args": {
"where": {
"status": [
"bounced",
"complained"
]
},
"select": [
"status",
"status_reason"
]
}
},
{
"command": "query_contacts",
"id": "search",
"args": {
"where": {
"search": "ana acme"
},
"limit": 10
}
}
]
}ข้อผิดพลาด
ข้อผิดพลาดระดับ HTTP ส่งกลับ type, code และ message ข้อผิดพลาดที่มีเครื่องหมาย CMD จะกลับมาในผลลัพธ์ของคำสั่ง พร้อม HTTP 200
- 401
INVALID_API_KEYAPI key ไม่มีอยู่ ถูกเพิกถอน หรือถูกปิดในแดชบอร์ด
- 429
RATE_LIMITEDเกิน 15 คำขอ/วินาที หรือ 15 คำขอพร้อมกันสำหรับ IP + API key เดียวกัน รอจำนวนวินาทีใน Retry-After
- CMD
MISSING_SCOPEAPI key ไม่มีขอบเขตที่คำสั่งนี้ต้องการ คำสั่งอื่นในคำขอยังทำงาน
- CMD
INVALID_ARGSอาร์กิวเมนต์ที่จำเป็นหายไปหรือไม่ถูกต้อง: อีเมล ค่าฟิลด์ ตัวเลือก enum คีย์ where id รายชื่อ…
- CMD
INVALID_CURSORcursor ผิดรูปแบบหรือเป็นของคิวรีหรือบัญชีอื่น
- CMD
INTERNALข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์