# Customer Search

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v2/customers/enquiry:
    post:
      summary: Customer Search
      deprecated: false
      description: ค้นหา / ดึง ข้อมูล Customer
      tags:
        - Venio/Customer
      parameters:
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
        - name: Ocp-Apim-Subscription-Key
          in: header
          description: รหัส subscription key ลูกค้า
          required: true
          example: <Your-Subscription-Key>
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                customerTypes:
                  type: integer
                  description: >-
                    ประเภทลูกค้า (Lead=11100, Prospect=11200, Customer=11300)
                    แนะนำให้รับเป็น Array เพื่อให้ค้นหาได้หลายประเภทพร้อมกัน
                keyword:
                  type: string
                  description: คำค้นหาหลัก (รวม search และ keyword เข้าด้วยกัน)
                searchIn:
                  type: array
                  items:
                    type: string
                    description: |-
                      SearchIn enum:
                      customerCode → รหัสลูกค้า
                      customerName → ชื่อลูกค้า
                      customerTaxNo → เลขประจำตัวผู้เสียภาษี
                      customerPhone → เบอร์โทรศัพท์ลูกค้า
                      customerMobile → เบอร์มือถือลูกค้า
                      customerEmail → อีเมลลูกค้า
                      contactName → ชื่อผู้ติดต่อ
                      contactPhone → เบอร์โทรศัพท์ผู้ติดต่อ
                      contactMobile → เบอร์มือถือผู้ติดต่อ
                      contactEmail → อีเมลผู้ติดต่อ
                      customerGroupName → กลุ่มลูกค้า
                  description: >-
                    ระบุคอลัมน์ที่เป็น String เท่านั้น เพื่อเอา keyword ไปค้นหา
                    ประกอบไปด้วย
                            "customerName"
                            "contactName"
                            "customerCode"
                            "customerTaxNo"
                            "customerEmail"
                            "contactEmail"
                            "customerMobile"
                            "contactMobile"
                            "customerPhone"
                            "contactPhone"
                isExactMatch:
                  type: boolean
                  description: >-
                    true = ค้นหาแบบตรงเป๊ะ (Exact Match), false =
                    ค้นหาแบบบางส่วน (Partial Match/LIKE)
                filters:
                  type: object
                  properties:
                    states:
                      type: integer
                      description: สถานะลูกค้า
                    actionStates:
                      type: integer
                      description: สถานะการกระทำของลูกค้า
                    statuses:
                      type: array
                      items:
                        type: boolean
                      description: รายการสถานะ
                    ownerTeams:
                      type: integer
                      description: ทีมที่รับผิดชอบ
                    owners:
                      type: array
                      items:
                        type: string
                      description: รหัสพนักงานผู้รับผิดชอบ
                    primaryOwner:
                      type: string
                      description: รหัสพนักงานผู้รับผิดชอบหลัก
                    topicInterests:
                      type: array
                      items:
                        type: integer
                      description: รายการหัวข้อที่สนใจ
                    classifications:
                      type: array
                      items:
                        type: integer
                      description: รายการหมวดหมู่
                    groups:
                      type: array
                      items:
                        type: integer
                      description: Lead/Prospect/Customer group ids
                    probabilities:
                      type: array
                      items:
                        type: integer
                      description: รายการความน่าจะเป็น
                    tags:
                      type: array
                      items:
                        type: string
                      description: รายการ Tag
                    sources:
                      type: array
                      items:
                        type: string
                      description: แหล่งที่มา
                  x-apidog-orders:
                    - states
                    - actionStates
                    - statuses
                    - ownerTeams
                    - owners
                    - primaryOwner
                    - topicInterests
                    - classifications
                    - groups
                    - probabilities
                    - tags
                    - sources
                  description: รวมเงื่อนไขที่เป็น Advanced Filters
                  x-apidog-ignore-properties: []
                geoSearch:
                  type: object
                  properties:
                    latitude:
                      type: number
                      description: ละติดจูด
                    longitude:
                      type: number
                      description: ลองจิจูด
                    distanceLimit:
                      type: number
                      description: ระยะทาง ***ใส่ได้กรณีที่มีระบุค่า ละติจูด และลองจิจูด
                  x-apidog-orders:
                    - latitude
                    - longitude
                    - distanceLimit
                  description: เงื่อนไขการค้นหาตามระยะทาง
                  x-apidog-ignore-properties: []
                skip:
                  type: integer
                  description: จำนวน record ที่ข้าม (Pagination)
                take:
                  type: integer
                  description: จำนวน record ที่ต้องการ (แทน pageLength)
                orderBy:
                  type: string
                  description: คอลัมน์ที่ต้องการเรียงลำดับ เช่น 'createdAt desc'
              required:
                - skip
                - take
              x-apidog-orders:
                - customerTypes
                - keyword
                - searchIn
                - isExactMatch
                - filters
                - geoSearch
                - skip
                - take
                - orderBy
              x-apidog-ignore-properties: []
            example:
              customerType: 11300
              keyword: บริษัท เทคโนโลยี
              customerTaxNo: '0105555555555'
              searchIn:
                - customerName
                - contactName
                - customerCode
                - customerTaxNo
                - customerEmail
                - contactEmail
                - customerMobile
                - contactMobile
                - customerPhone
                - contactPhone
              isExactMatch: false
              skip: 0
              take: 20
              orderBy: dateLatestUpdated desc
              filters:
                states: 200001
                actionStates: 1
                ownerTypes: 2
                ownerTeams: 15
                owners:
                  - USR-001
                  - USR-002
                primaryOwner: USR-001
                topicInterests:
                  - 1
                  - 2
                  - 5
                classifications:
                  - 1001
                  - 1002
                groups:
                  - 50
                  - 51
                statuses:
                  - true
                probabilities:
                  - 50
                  - 80
                  - 100
                tags:
                  - VIP
                  - Bangkok
                sources:
                  - '1'
                  - '3'
              geoSearch:
                latitude: 13.736717
                longitude: 100.523186
                distanceLimit: 5000.5
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    properties:
                      code:
                        type: string
                      description:
                        type: string
                    required:
                      - code
                      - description
                    x-apidog-orders:
                      - code
                      - description
                    x-apidog-ignore-properties: []
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        customerId:
                          type: integer
                        customerCode:
                          type: string
                        customerName:
                          type: string
                        customer2ndName:
                          type: string
                        customerAliases:
                          type: array
                          items:
                            type: string
                        customerPicture:
                          type: string
                        customerTaxNo:
                          type: string
                        customerType:
                          type: integer
                        customerStatus:
                          type: integer
                        leadStatus:
                          type: integer
                        uniqueName:
                          type: string
                        customerNote:
                          type: string
                        categorization:
                          type: object
                          properties:
                            groupName:
                              type: string
                            classificationName:
                              type: string
                            sourceOfLead:
                              type: string
                            currentStateId:
                              type: integer
                            currentStateName:
                              type: string
                            customerTags:
                              type: array
                              items:
                                type: string
                            customFields:
                              type: array
                              items:
                                type: string
                          required:
                            - groupName
                            - classificationName
                            - sourceOfLead
                            - currentStateId
                            - currentStateName
                            - customerTags
                            - customFields
                          x-apidog-orders:
                            - groupName
                            - classificationName
                            - sourceOfLead
                            - currentStateId
                            - currentStateName
                            - customerTags
                            - customFields
                          x-apidog-ignore-properties: []
                        contactInfo:
                          type: object
                          properties:
                            customerPhone:
                              type: string
                            customerMobile:
                              type: string
                            customerEmail:
                              type: string
                            socialAccount:
                              type: object
                              properties:
                                facebook:
                                  type: string
                              required:
                                - facebook
                              x-apidog-orders:
                                - facebook
                              x-apidog-ignore-properties: []
                          required:
                            - customerPhone
                            - customerMobile
                            - customerEmail
                            - socialAccount
                          x-apidog-orders:
                            - customerPhone
                            - customerMobile
                            - customerEmail
                            - socialAccount
                          x-apidog-ignore-properties: []
                        address:
                          type: object
                          properties:
                            addressId:
                              type: integer
                            branchCode:
                              type: string
                            locationName:
                              type: string
                            locationAddress:
                              type: string
                            secondaryAddress:
                              type: string
                            locationType:
                              type: integer
                            latitude:
                              type: string
                            longitude:
                              type: string
                            subdistrict:
                              type: string
                            subdistrictEN:
                              type: string
                            district:
                              type: string
                            districtEN:
                              type: string
                            province:
                              type: string
                            provinceEN:
                              type: string
                            zipCode:
                              type: string
                          required:
                            - addressId
                            - branchCode
                            - locationName
                            - locationAddress
                            - secondaryAddress
                            - locationType
                            - latitude
                            - longitude
                            - subdistrict
                            - subdistrictEN
                            - district
                            - districtEN
                            - province
                            - provinceEN
                            - zipCode
                          x-apidog-orders:
                            - addressId
                            - branchCode
                            - locationName
                            - locationAddress
                            - secondaryAddress
                            - locationType
                            - latitude
                            - longitude
                            - subdistrict
                            - subdistrictEN
                            - district
                            - districtEN
                            - province
                            - provinceEN
                            - zipCode
                          x-apidog-ignore-properties: []
                        owners:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                              title:
                                type: string
                              group:
                                type: string
                              teamId:
                                type: integer
                              pictureUrl:
                                type: string
                              isPrimaryOwner:
                                type: boolean
                            x-apidog-orders:
                              - id
                              - title
                              - group
                              - teamId
                              - pictureUrl
                              - isPrimaryOwner
                            x-apidog-ignore-properties: []
                        contacts:
                          type: array
                          items:
                            type: object
                            properties:
                              contactName:
                                type: string
                              contactPicture:
                                type: string
                              contactPhone:
                                type: string
                              contactMobile:
                                type: string
                              contactEmail:
                                type: string
                              contactSocialAccount:
                                type: object
                                properties:
                                  facebook:
                                    type: string
                                required:
                                  - facebook
                                x-apidog-orders:
                                  - facebook
                                x-apidog-ignore-properties: []
                              contactPosition:
                                type: string
                              contactBirthdate:
                                type: string
                              contactNote:
                                type: string
                              contactStatus:
                                type: boolean
                              tags:
                                type: array
                                items:
                                  type: string
                            x-apidog-orders:
                              - contactName
                              - contactPicture
                              - contactPhone
                              - contactMobile
                              - contactEmail
                              - contactSocialAccount
                              - contactPosition
                              - contactBirthdate
                              - contactNote
                              - contactStatus
                              - tags
                            x-apidog-ignore-properties: []
                        topicInterests:
                          type: array
                          items:
                            type: object
                            properties:
                              topicId:
                                type: integer
                              topicName:
                                type: string
                            x-apidog-orders:
                              - topicId
                              - topicName
                            x-apidog-ignore-properties: []
                        stats:
                          type: object
                          properties:
                            activityStats:
                              type: array
                              items:
                                type: object
                                properties:
                                  type:
                                    type: string
                                  count:
                                    type: integer
                                x-apidog-orders:
                                  - type
                                  - count
                                x-apidog-ignore-properties: []
                            onGoingStats:
                              type: array
                              items:
                                type: object
                                properties:
                                  type:
                                    type: string
                                  count:
                                    type: integer
                                x-apidog-orders:
                                  - type
                                  - count
                                x-apidog-ignore-properties: []
                            thisYearStats:
                              type: array
                              items:
                                type: object
                                properties:
                                  type:
                                    type: string
                                  count:
                                    type: integer
                                x-apidog-orders:
                                  - type
                                  - count
                                x-apidog-ignore-properties: []
                            markDealStage:
                              type: object
                              properties:
                                current:
                                  type: integer
                                max:
                                  type: integer
                              required:
                                - current
                                - max
                              x-apidog-orders:
                                - current
                                - max
                              x-apidog-ignore-properties: []
                            dealStage:
                              type: integer
                            dealName:
                              type: string
                            dealPotential:
                              type: integer
                          required:
                            - activityStats
                            - onGoingStats
                            - thisYearStats
                            - markDealStage
                            - dealStage
                            - dealName
                            - dealPotential
                          x-apidog-orders:
                            - activityStats
                            - onGoingStats
                            - thisYearStats
                            - markDealStage
                            - dealStage
                            - dealName
                            - dealPotential
                          x-apidog-ignore-properties: []
                        audit:
                          type: object
                          properties:
                            latestUpdateByUser:
                              type: string
                            latestUpdateType:
                              type: string
                            dateLatestUpdated:
                              type: string
                            dateAcquired:
                              type: integer
                            dateFollowUp:
                              type: string
                          required:
                            - latestUpdateByUser
                            - latestUpdateType
                            - dateLatestUpdated
                            - dateAcquired
                            - dateFollowUp
                          x-apidog-orders:
                            - latestUpdateByUser
                            - latestUpdateType
                            - dateLatestUpdated
                            - dateAcquired
                            - dateFollowUp
                          x-apidog-ignore-properties: []
                      x-apidog-orders:
                        - customerId
                        - customerCode
                        - customerName
                        - customer2ndName
                        - customerAliases
                        - customerPicture
                        - customerTaxNo
                        - customerType
                        - customerStatus
                        - leadStatus
                        - uniqueName
                        - customerNote
                        - categorization
                        - contactInfo
                        - address
                        - owners
                        - contacts
                        - topicInterests
                        - stats
                        - audit
                      x-apidog-ignore-properties: []
                required:
                  - status
                  - data
                x-apidog-orders:
                  - status
                  - data
                x-apidog-ignore-properties: []
              example:
                status:
                  code: '200'
                  description: success
                data:
                  - customerId: 98765
                    customerCode: CUST-2023-001
                    customerName: บริษัท เทคโนโลยี จำกัด (มหาชน)
                    customer2ndName: Technology Public Co., Ltd.
                    customerAliases:
                      - เทคโน
                      - Tech PC
                    customerPicture: https://storage.venio.io/images/customers/98765.png
                    customerTaxNo: '0105555555555'
                    customerType: 11300
                    customerStatus: 1
                    leadStatus: null
                    uniqueName: บริษัท เทคโนโลยี จำกัด (มหาชน)-0105555555555
                    customerNote: ลูกค้ารายใหญ่ ต้องการระบบ ERP
                    categorization:
                      groupName: กลุ่มอุตสาหกรรมไอที
                      classificationName: Enterprise
                      sourceOfLead: Website Contact Form
                      currentStateId: 200001
                      currentStateName: ติดต่อแล้ว (Contacted)
                      customerTags:
                        - VIP
                        - Bangkok
                      customFields:
                        - 'งบประมาณ: 1,000,000'
                    contactInfo:
                      customerPhone: 02-123-4567
                      customerMobile: 081-123-4567
                      customerEmail: contact@technology.co.th
                      socialAccount:
                        facebook: technology.th
                    address:
                      addressId: 1102
                      branchCode: '00000'
                      locationName: สำนักงานใหญ่
                      locationAddress: 99/9 อาคารซอฟต์แวร์ปาร์ค ชั้น 10 ถนนแจ้งวัฒนะ
                      secondaryAddress: ห้อง 1001
                      locationType: 1
                      latitude: '13.901234'
                      longitude: '100.523456'
                      subdistrict: คลองเกลือ
                      district: ปากเกร็ด
                      province: นนทบุรี
                      zipCode: '11120'
                      subdistrictEN: Khlong Kluea
                      districtEN: Pak Kret
                      provinceEN: Nonthaburi
                    owners:
                      - id: USR-001
                        title: นาย สมเกียรติ ยอดขาย
                        group: Enterprise Sales Team
                        teamId: 15
                        pictureUrl: https://storage.venio.io/images/users/usr-001.png
                        isPrimaryOwner: true
                      - id: USR-002
                        title: นางสาว ใจดี บริการ
                        group: Enterprise Support Team
                        teamId: 16
                        pictureUrl: https://storage.venio.io/images/users/usr-002.png
                        isPrimaryOwner: false
                    contacts:
                      - contactName: คุณสมคิด ตัดสินใจ
                        contactPicture: null
                        contactPhone: 02-123-4568
                        contactMobile: 089-999-8888
                        contactEmail: somkid@technology.co.th
                        contactSocialAccount:
                          facebook: somkid.ceo
                        contactPosition: Chief Executive Officer (CEO)
                        contactBirthdate: '1975-05-15T00:00:00Z'
                        contactNote: ชอบตีกอล์ฟ สะดวกคุยช่วงบ่าย
                        contactStatus: true
                        tags:
                          - Decision Maker
                          - C-Level
                    topicInterests:
                      - topicId: 1
                        topicName: ERP Implementation
                      - topicId: 5
                        topicName: Cloud Hosting
                    stats:
                      activityStats:
                        - type: call
                          count: 12
                        - type: meeting
                          count: 3
                      onGoingStats:
                        - type: deal
                          count: 1
                      thisYearStats:
                        - type: won
                          count: 1
                      markDealStage:
                        current: 4
                        max: 6
                      dealStage: 4
                      dealName: Project ERP Implementation Phase 1
                      dealPotential: 1500000
                    audit:
                      latestUpdateByUser: USR-001
                      latestUpdateType: Update Customer Address
                      dateLatestUpdated: '2023-11-20T14:30:00Z'
                      dateAcquired: 1672531200
                      dateFollowUp: '2023-11-25T10:00:00Z'
          headers: {}
          x-apidog-name: Success
        x-200:User authentication required V2.:
          description: ''
          content:
            application/json:
              schema:
                title: ''
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Required%20authorization'
                  status:
                    $ref: '#/components/schemas/Response%20Error%20Msg%20'
                required:
                  - data
                  - status
                x-apidog-orders:
                  - data
                  - status
                x-apidog-ignore-properties: []
              example:
                data:
                  subCode: E9103
                  description: Authorization credentials required
                  metadata: {}
                status:
                  code: '4001'
                  description: Business error with 1 errors
          headers: {}
          x-apidog-name: User authentication required V2.
      security:
        - bearerAuth: []
          x-apidog:
            schemeGroups:
              - id: uyL_cJmK7q60QJZRTi5ot
                schemeIds:
                  - bearerAuth
            required: true
            use:
              id: uyL_cJmK7q60QJZRTi5ot
            scopes:
              uyL_cJmK7q60QJZRTi5ot:
                bearerAuth: []
      x-apidog-folder: Venio/Customer
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/351895/apis/api-28322634-run
components:
  schemas:
    'Response Error Msg ':
      type: object
      properties:
        code:
          type: string
          x-apidog-mock: '4001'
        description:
          type: string
          x-apidog-mock: Business error with 1 errors
      required:
        - code
        - description
      x-apidog-orders:
        - code
        - description
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    Required authorization:
      type: object
      properties:
        subCode:
          type: string
          x-apidog-mock: E9103
        description:
          type: string
          x-apidog-mock: Authorization credentials required
        metadata:
          type: object
          properties: {}
          x-apidog-orders: []
          x-apidog-ignore-properties: []
      required:
        - subCode
        - description
        - metadata
      x-apidog-orders:
        - subCode
        - description
        - metadata
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes:
    bearerAuth:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: ใส่ JWT Token ในรูปแบบ Bearer {token}
    bearer:
      type: bearer
      scheme: bearer
servers:
  - url: https://api.gofive.co.th
    description: Production
security:
  - bearerAuth: []
    x-apidog:
      schemeGroups:
        - id: uyL_cJmK7q60QJZRTi5ot
          schemeIds:
            - bearerAuth
      required: true
      use:
        id: uyL_cJmK7q60QJZRTi5ot
      scopes:
        uyL_cJmK7q60QJZRTi5ot:
          bearerAuth: []

```
