ข้ามไปยังเนื้อหาหลัก

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

1. ลงทะเบียนเพื่อขอสิทธิ์ใช้งาน

ก่อนเริ่มใช้งาน Consent Management API คุณต้องลงทะเบียนขอสิทธิ์ใช้งานก่อน:

  1. กรอกแบบฟอร์มลงทะเบียน: https://forms.office.com/r/0nFLVmS5U4
  2. รอรับ credentials: ทีมงานจะสร้างและส่งข้อมูลต่อไปนี้ให้คุณ:
    • Alias
    • Email
    • 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

ลองเรียก Health check API ↩

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"
}'

ดู Decision Values

ลองเรียก 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

MethodPathวัตถุประสงค์
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)

  1. สร้าง Consent Template — กำหนดข้อความนโยบายที่ลูกค้าต้องยินยอม เช่น นโยบายการสื่อสารการตลาด
  2. Publish Template Version — เผยแพร่ version เพื่อให้สามารถเรียกใช้ผ่าน API ได้
  3. สร้าง API Key — ไปที่ Administration → API Key Management แล้วสร้าง key สำหรับระบบของคุณ

ในแอปพลิเคชันของคุณ

  1. ครั้งแรกที่ลูกค้าใช้งาน — เรียก GET /api/v1/consent-templates/{template_code}/latest แล้วแสดงเนื้อหา consent ให้ลูกค้าเห็น
  2. บันทึกการตัดสินใจ — เรียก POST /api/v1/customers/{customer_id}/consents/decisions พร้อม given, reject หรือ withdraw ตามที่ลูกค้าเลือก
  3. การเข้าใช้งานครั้งถัดไป — เรียก GET /api/v1/customers/{customer_id}/consents/templates/{template_code}/pending เพื่อตรวจสอบว่าลูกค้ามี template ใหม่ที่ยังไม่ได้เห็นหรือไม่ ถ้า accepted: false ให้แสดงเนื้อหา template ใหม่และกลับไปทำขั้นตอนที่ 5

อ่านต่อ