เริ่มต้นอย่างรวดเร็ว
1. ลงทะเบียนเพื่อขอสิทธิ์ใช้งาน
ก่อนเริ่มใช้งาน Consent Management API คุณต้องลงทะเบียนขอสิทธิ์ใช้งานก่อน:
- กรอกแบบฟอร์มลงทะเบียน: https://forms.office.com/r/0nFLVmS5U4
- รอรับ credentials: ทีมงานจะสร้างและส่งข้อมูลต่อไปนี้ให้คุณ:
- Alias
- Password สำหรับ login
2. รับ API key
หลังลงทะเบียนแล้ว คุณสามารถสร้าง x-api-key ได้ด้วยตนเองผ่าน Consentrix Backoffice
3. ตรวจสอบการเชื่อมต่อ
กำหนด API_ORIGIN เป็น host ที่ได้รับสำหรับ environment ของคุณ โดยไม่ต้องใส่ /api หรือ / ปิดท้าย
export API_ORIGIN="https://your-consentrix-host"
curl -sS "${API_ORIGIN}/api/health"
หากเรียกสำเร็จ ระบบจะตอบกลับเป็น JSON ที่มีฟิลด์ status และ success
4. ดึง published template version
แทนที่ YOUR_KEY ด้วย API key จริงของคุณ:
curl -sS \
-H "x-system-api-key: YOUR_KEY" \
"${API_ORIGIN}/api/v1/consent-templates/YOUR_TEMPLATE_CODE/latest"
ตัวอย่าง response เมื่อเรียก สำเร็จ:
{
"data": {
"consent_version_id": "123e4567-e89b-12d3-a456-426614174010",
"version": 1,
"tag": "1.0.0",
"content_html": "<html>...</html>",
"file_url": "https://example.com/content.html",
"allow_reconsent": true
}
}
ลองเรียก Get latest consent template version API ↩
5. ส่งการตัดสินใจเรื่องความยินยอม
curl -sS -X POST \
-H "Content-Type: application/json" \
-H "x-system-api-key: YOUR_KEY" \
"${API_ORIGIN}/api/v1/customers/CUSTOMER_ID/consents/decisions" \
-d '{
"consent_version_id": "123e4567-e89b-12d3-a456-426614174010",
"decision": "given"
}'
ลองเรียก Submit consent decision API ↩
6. Errors
รูปแบบ error response:
{
"code": "1002",
"message": "Unauthorized."
}
ดูรายละเอียด error codes ทั้งหมดได้ที่ API conventions
Request URL
ประกอบ request URL จาก origin ของ environment และ base path /api ที่คงที่:
{API_ORIGIN}{REQUEST_PATH}
ตัวอย่างเช่น request path /api/v1/consent-templates/{template_code}/latest
จะเป็น {API_ORIGIN}/api/v1/consent-templates/{template_code}/latest
API endpoints
| Method | Path | วัตถุประสงค์ |
|---|---|---|
GET | /api/health | ตรวจสอบสถานะระบบ |
GET | /api/v1/consent-templates/{template_code}/latest | ดึง published template ล่าสุด |
GET | /api/v1/customers/{customer_id}/consents/templates/{template_code}/pending | ตรวจสอบว่าลูกค้ามี template ที่ยังไม่ได้ยอมรับหรือไม่ |
POST | /api/v1/customers/{customer_id}/consents/decisions | ส่งการตัดสินใจ |
สิ่งที่ต้องดำเนินการฝั่งคุณ
ก่อนที่ integration จะพร้อมใช้งานจริง ให้ดำเนินการเหล่านี้ให้ครบก่อน:
ใน Consentrix Backoffice (consentrix-portal.odt.co.th)
- สร้าง Consent Template — กำหนดข้อความนโยบายที่ลูกค้าต้องยินยอม เช่น นโยบายการสื่อสารการตลาด
- Publish Template Version — เผยแพร่ version เพื่อให้สามารถเรียกใช้ผ่าน API ได้
- สร้าง API Key — ไปที่ Administration → API Key Management แล้วสร้าง key สำหรับระบบของคุณ
ในแอปพลิเคชันของคุณ
- ครั้งแรกที่ลูกค้าใช้งาน — เรียก
GET /api/v1/consent-templates/{template_code}/latestแล้วแสดงเนื้อหา consent ให้ลูกค้าเห็น - บันทึกการตัดสินใจ — เรียก
POST /api/v1/customers/{customer_id}/consents/decisionsพร้อมgiven,rejectหรือwithdrawตามที่ลูกค้าเลือก - การเข้าใช้งานครั้งถัดไป — เรียก
GET /api/v1/customers/{customer_id}/consents/templates/{template_code}/pendingเพื่อตรวจสอบว่าลูกค้ามี template ใหม่ที่ยังไม่ได้เห็นหรือไม่ ถ้าaccepted: falseให้แสดงเนื้อหา template ใหม่และกลับไปทำขั้นตอนที่ 5