Developer Docs

    เริ่มต้น

    Partner API — Auth

    Partner API — Sales

    Partner API — Products

    Partner API — Inventory

    Partner API — Purchasing

    Partner API — Customers

    Partner API — Reports

    Partner API — Webhooks

    อ้างอิง

    List Customers

    ดึงรายการลูกค้าทั้งหมดของธุรกิจ

    Customers เป็นข้อมูลระดับ Business ไม่แยกตามสาขา — ทุก Token ที่มี Scope read:customers จะเห็นลูกค้าทั้งหมดของธุรกิจ

    Endpoint นี้เหมาะสำหรับ:

    • ซิงค์ข้อมูล Customer เข้าสู่ระบบ CRM หรือ Marketing Platform
    • วิเคราะห์พฤติกรรมลูกค้าและ Loyalty Program
    • สร้าง Customer Segment สำหรับแคมเปญ

    Required Scope

    read:customers
    

    ข้อมูล PII (phone, email, date_of_birth, address ฯลฯ) ต้องการ Scope เพิ่มเติม:

    read:customers:pii
    

    Endpoint

    GET /api/partner/v1/customers
    

    Request Headers

    Authorization: Bearer <access_token>
    

    Query Parameters

    ParameterTypeRequiredDescription
    is_activebooleanNoกรองตามสถานะลูกค้า: true หรือ false
    membership_tier_idstring (UUID)Noกรองตาม Membership Tier
    qstringNoค้นหาจาก full_name หรือ customer_code (1–255 ตัวอักษร)
    limitintegerNoจำนวนรายการต่อหน้า (1–200) ค่าเริ่มต้น 50
    cursorstringNoCursor สำหรับดึงหน้าถัดไป

    PII Fields

    ฟิลด์ข้อมูลส่วนบุคคล (PII) จะ ไม่ปรากฏใน Response เลย หาก Token ไม่มี Scope read:customers:pii — ไม่ใช่ null แต่ key หายไปจาก object ทั้งหมด

    ฟิลด์ที่ต้องการ Scope read:customers:pii:

    • phone
    • email
    • date_of_birth
    • address, city, state, postal_code, country
    • tax_id

    Pagination

    Endpoint นี้ใช้ Cursor-based Pagination

    หาก has_more เป็น true ให้ส่ง next_cursor กลับมาใน parameter cursor

    GET /api/partner/v1/customers?cursor=<next_cursor>
    

    Example Request

    curl -X GET \
      "https://<host>/api/partner/v1/customers?is_active=true&limit=50" \
      -H "Authorization: Bearer <access_token>"
    

    Example Response

    {
      "data": [
        {
          "id": "4b1a5ef8-f4a2-4fb2-99d5-dddd1076e1bb",
          "customer_code": "CUS-000380",
          "full_name": "สมชาย ใจดี",
          "first_name": "สมชาย",
          "last_name": "ใจดี",
          "membership_tier_id": "5c19101c-d9e5-4fb0-9f85-7daf1f0c3f91",
          "membership_number": "MEM17785123666606",
          "total_points": 30,
          "available_points": 10,
          "total_spent": "600",
          "total_visits": 4,
          "last_visit_date": "2026-05-11T00:00:00.000Z",
          "is_active": true,
          "is_verified": false,
          "joined_date": "2026-05-11T00:00:00.000Z",
          "created_at": "2026-05-11T15:12:59.723Z",
          "updated_at": "2026-05-11T15:14:06.138Z",
          "phone": "0812345678",
          "email": null,
          "date_of_birth": null,
          "address": null,
          "city": null,
          "state": null,
          "postal_code": null,
          "country": "Thailand",
          "tax_id": null
        }
      ],
      "pagination": {
        "next_cursor": null,
        "has_more": false,
        "limit": 50
      }
    }
    

    Customer Object

    FieldTypeScope RequiredDescription
    idstring (UUID)read:customersCustomer ID
    customer_codestringread:customersรหัสลูกค้า
    full_namestringread:customersชื่อ-นามสกุล
    first_namestringread:customersชื่อ
    last_namestring | nullread:customersนามสกุล
    membership_tier_idstring (UUID) | nullread:customersTier ของ Membership Program
    membership_numberstring | nullread:customersเลข Membership
    total_pointsnumberread:customersคะแนนสะสมทั้งหมด
    available_pointsnumberread:customersคะแนนที่ใช้ได้
    total_spentstring (decimal)read:customersยอดใช้จ่ายสะสม
    total_visitsnumberread:customersจำนวนครั้งที่เข้าใช้บริการ
    last_visit_datestring (ISO 8601) | nullread:customersวันที่เข้าใช้บริการล่าสุด
    is_activebooleanread:customersสถานะลูกค้า
    is_verifiedbooleanread:customersยืนยันตัวตนแล้วหรือยัง
    joined_datestring (ISO 8601) | nullread:customersวันที่สมัครสมาชิก
    created_atstring (ISO 8601)read:customersเวลาที่สร้าง record
    updated_atstring (ISO 8601)read:customersเวลาที่แก้ไขล่าสุด
    phonestring | nullread:customers:piiเบอร์โทรศัพท์
    emailstring | nullread:customers:piiอีเมล
    date_of_birthstring (ISO 8601) | nullread:customers:piiวันเกิด
    addressstring | nullread:customers:piiที่อยู่
    citystring | nullread:customers:piiเมือง / เขต
    statestring | nullread:customers:piiรัฐ / จังหวัด
    postal_codestring | nullread:customers:piiรหัสไปรษณีย์
    countrystring | nullread:customers:piiประเทศ
    tax_idstring | nullread:customers:piiเลขประจำตัวผู้เสียภาษี