ผู้ติดต่อ: ฟิลด์กำหนดเอง
กำหนดฟิลด์
สร้างฟิลด์กำหนดเอง หรือเปลี่ยนชื่อและตัวเลือก ทุกฟิลด์มีดัชนีของตัวเอง จึงกรองและเรียงได้ทันที
https://g.sendcorex.com/v1/contactscommand: define_fieldต้องมีขอบเขต contact:create บน API key ของคุณ
เรียกอีกครั้งด้วย key และ type เดิมจะอัปเดตชื่อและตัวเลือก ชนิดเปลี่ยนไม่ได้ ลองเปลี่ยนจะล้มเหลวด้วย TYPE_LOCKED หากต้องการเปลี่ยน ให้ลบฟิลด์แล้วสร้างใหม่
อาร์กิวเมนต์
keystringจำเป็นa-z,0-9และ_ขึ้นต้นด้วยตัวอักษร ไม่เกิน 40 ตัวเช่น
"plan"typestringจำเป็นtext,number,date,bool,enumหรือmulti_enumเช่น
"enum"namestringไม่บังคับชื่อที่แสดง ค่าเริ่มต้นคือคีย์
เช่น
"Plan"optionsstring[]ไม่บังคับจำเป็นสำหรับ
enumและmulti_enum: ค่าที่อนุญาตเช่น
["free", "pro", "business"]
เริ่มต้นอย่างรวดเร็ว
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1/contacts',
{
commands: [
{
command: "define_field",
args: {
key: "plan",
name: "Plan",
type: "enum",
options: [
"free",
"pro",
"business"
]
}
}
]
},
{ 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": "define_field",
"id": "0",
"type": "SUCCESS",
"took_ms": 14,
"data": {
"key": "plan",
"name": "Plan",
"type": "enum",
"options": [
"free",
"pro",
"business"
],
"created_at": "2026-10-01T10:00:00.000Z",
"updated_at": "2026-10-01T10:00:00.000Z"
}
}
]
}ฟิลด์การตอบกลับ
(field)ฟิลด์ตามที่บันทึก:
key,name,type,options,created_at,updated_at
ชนิด
textไม่เกิน 2,000 ตัวอักษร กรองด้วยเท่ากับ (ไม่สนตัวพิมพ์และวรรณยุกต์)
containsหรือexistsnumberจำนวนเต็มหรือทศนิยม รวมค่าติดลบ
"1234,5"อ่านเป็น 1234.5 รองรับช่วงและการเรียงdateYYYY-MM-DDหรือ ISO รองรับช่วงและการเรียงbooltrueหรือfalse"yes","sim"และ"1"อ่านเป็น trueenumหนึ่งใน
options"PRO"ถูกเก็บเป็น"pro"ค่านอกตัวเลือกทำให้รายการล้มเหลวmulti_enumoptionsกี่ค่าก็ได้ เป็นรายการหรือ"tech, golf"ใช้เรียงไม่ได้
ตั้งค่าทุกฟิลด์ในครั้งเดียว
body คำขอ
{
"commands": [
{
"command": "define_field",
"args": {
"key": "plan",
"name": "Plan",
"type": "enum",
"options": [
"free",
"pro",
"business"
]
}
},
{
"command": "define_field",
"args": {
"key": "age",
"name": "Age",
"type": "number"
}
},
{
"command": "define_field",
"args": {
"key": "city",
"name": "City",
"type": "text"
}
},
{
"command": "define_field",
"args": {
"key": "birthday",
"name": "Birthday",
"type": "date"
}
},
{
"command": "define_field",
"args": {
"key": "interests",
"name": "Interests",
"type": "multi_enum",
"options": [
"golf",
"tech",
"travel"
]
}
},
{
"command": "define_field",
"args": {
"key": "vip",
"name": "VIP",
"type": "bool"
}
}
]
}บัญชีหนึ่งมีฟิลด์ได้สูงสุด 100 เกินจากนั้น define_field จะล้มเหลวด้วย LIMIT_REACHED
ข้อผิดพลาด
ข้อผิดพลาดระดับ 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
TYPE_LOCKEDdefine_field พยายามเปลี่ยนชนิดของฟิลด์ที่มีอยู่ ลบแล้วสร้างใหม่
- CMD
LIMIT_REACHEDบัญชีมีฟิลด์กำหนดเองครบ 100 แล้ว
- CMD
INTERNALข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์