เพิ่มช่องทางติดต่อ POST
เพิ่มช่องทางติดต่อ (destination) เช่น เบอร์โทรหรืออีเมล ให้กับรายชื่อผู้ติดต่อ หนึ่งรายชื่อมีได้หลายช่องทาง
Authorization
ใช้ API Key (การยืนยันตัวตน) — ส่ง header Authorization: Bearer <API_KEY> (API Key ขึ้นต้นด้วย smsk_)
HTTP Request
http
POST https://public-api.smsup-plus.com/Person/insertPersonDestinationContent Type
application/json
Parameter Description
| Property | Type | Required | Description |
|---|---|---|---|
personId | string | Required | รหัสรายชื่อที่จะเพิ่มช่องทาง (ต้องเป็นของบัญชีคุณ) |
value | string | Required | เบอร์โทรหรืออีเมล ห้ามว่าง (ระบบไม่ตรวจรูปแบบ เก็บตามที่ส่งมา) |
isPrimary | boolean | Optional | ระบุว่าเป็นช่องทางหลัก (ค่าเริ่มต้น false) |
Response Description
| Property | Type | Description |
|---|---|---|
status | number | 200 เมื่อสำเร็จ |
data.destinationId | string | รหัสช่องทางติดต่อ (UUID) — เก็บไว้ ใช้ตอนลบช่องทางติดต่อ |
data.personId | string | รหัสรายชื่อเจ้าของช่องทาง |
data.accountId | number | รหัสบัญชีของคุณ |
data.value | string | เบอร์โทรหรืออีเมลที่บันทึก |
data.isPrimary | boolean | เป็นช่องทางหลักหรือไม่ |
data.isDeleted | boolean | false |
data.createdAt | string | เวลาสร้าง (ISO 8601) |
data.updatedAt | string | เวลาแก้ไขล่าสุด (ISO 8601) |
ตัวอย่าง Request
bash
curl -X POST 'https://public-api.smsup-plus.com/Person/insertPersonDestination' \
-H 'Authorization: Bearer <API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"personId": "3f8b2c1e-7a4d-4e9b-9c2f-1d5e6a7b8c90",
"value": "66812345678",
"isPrimary": true
}'js
const res = await fetch('https://public-api.smsup-plus.com/Person/insertPersonDestination', {
method: 'POST',
headers: { Authorization: 'Bearer <API_KEY>', 'Content-Type': 'application/json' },
body: JSON.stringify({
personId: '3f8b2c1e-7a4d-4e9b-9c2f-1d5e6a7b8c90',
value: '66812345678',
isPrimary: true,
}),
})
console.log(await res.json())ตัวอย่าง Response
json
{
"status": 200,
"data": {
"destinationId": "7e6d5c4b-3a29-4180-9f7e-6d5c4b3a2918",
"personId": "3f8b2c1e-7a4d-4e9b-9c2f-1d5e6a7b8c90",
"accountId": 1024,
"value": "66812345678",
"isPrimary": true,
"isDeleted": false,
"createdAt": "2026-11-16T03:20:05.987654321Z",
"updatedAt": "2026-11-16T03:20:05.987654321Z"
}
}Error ที่อาจเจอ
| HTTP | Response | สาเหตุ |
|---|---|---|
| 200 | {"status":400,"description":"personId and value are required."} | ไม่ได้ส่ง personId หรือ value, body ไม่ใช่ JSON หรือชนิดข้อมูลผิด |
| 200 | {"status":404,"description":"Person not found."} | ไม่พบรายชื่อ ถูกลบไปแล้ว หรือไม่ใช่ของบัญชีคุณ |
| 200 | {"status":500,"description":"Failed to add destination."} | บันทึกไม่สำเร็จ ลองใหม่อีกครั้ง |
| 401 | {"error":"invalid api key"} | API Key ไม่ถูกต้อง — ดู Error |
WARNING
เมื่อผ่านการยืนยันตัวตนแล้ว endpoint นี้ตอบ HTTP 200 เสมอ ให้ตรวจผลจากฟิลด์ status ใน body
INFO
Public API ไม่มี endpoint สำหรับดูรายการช่องทางติดต่อ ให้เก็บ destinationId จาก response ไว้เอง — ระบบไม่ตรวจค่าซ้ำ และไม่ปรับช่องทางอื่นของรายชื่อเดียวกันเมื่อส่ง isPrimary: true
