# Case Enquiry

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v2/cases/enquiry:
    post:
      summary: Case Enquiry
      deprecated: false
      description: ดึงชุดข้อมูลเคส โดยสามารถกรองเคสที่ต้องการได้
      tags:
        - Venio/Case Management
      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:
                dateRange:
                  type: string
                  description: |-
                    ช่วงเวลา (default all)
                    โดยมีค่าให้ใช้ ดังนี้
                    custom (กำหนดเอง ใช้ from/to)
                    all (ทั้งหมด)
                    today (วันนี้)
                    7d (7 วันล่าสุด)
                    30d (30 วันล่าสุด) 
                    90d (90 วันล่าสุด) 
                    (ถ้าไม่มี dateRange custom from/to จะไม่มีผล)
                    ระบบจะคำนวณย้อนหลังแบบไม่ลบเวลา
                  nullable: true
                from:
                  type: string
                  description: วันที่เริ่ม
                  nullable: true
                to:
                  type: string
                  description: วันที่สิ้นสุด
                  nullable: true
                categoryIds:
                  type: array
                  items:
                    type: integer
                  description: กรองรหัสหมวดหมู่ (จาก GET v2/cases/categories)
                owners:
                  type: array
                  items:
                    type: string
                  description: |-
                    กรองเจ้าของ
                    รองรับ "_none" = ไม่มีเจ้าของ
                stageIds:
                  type: array
                  items:
                    type: integer
                  description: กรองรหัสขั้นตอน (จาก GET v2/cases/stages)
                sources:
                  type: array
                  items:
                    type: string
                  description: |-
                    กรองแหล่งที่มา
                    โดยมีค่าให้ใช้ ดังนี้
                    email (เคสที่มาจาก Email)
                    chat (เคสที่มาจาก Chat)
                    web-form (เคสที่มาจากแบบฟอร์ม)
                    manual (เคสที่สร้างขึ้นเอง)
                tags:
                  type: array
                  items:
                    type: string
                  description: กรองแท็ก
                search:
                  type: string
                  description: |-
                    keyword ค้นหา
                    ระบบจะค้นหาแบบ substring match
                    ใน field Subject, Description และ caseNo
                  nullable: true
                skip:
                  type: integer
                  description: จำนวนที่ข้าม (default 0)
                take:
                  type: integer
                  description: จำนวนต่อหน้า (default 20)
                sortField:
                  type: string
                  description: |-
                    ฟิลด์การเรียงข้อมูล (default เรียงตามวันที่สร้างเคส)
                    โดยมีค่าให้ใช้ ดังนี้
                    caseNo (เรียงตามรหัสเคส)
                    title (เรียงตามหัวข้อเคส)
                    category (เรียงตามประเภทของเคส)
                    stage (เรียงตามขั้นตอนของเคส) 
                    sla (เรียงตาม SLA)
                  nullable: true
                sortOrder:
                  type: string
                  description: |-
                    ทิศทางการเรียงข้อมูล (default desc)
                    โดยมีค่าให้ใช้ ดังนี้
                    asc   (เรียงจากน้อยไปหามาก)
                    desc (เรียงจากมากไปหาน้อย)
                  nullable: true
              x-apidog-orders:
                - dateRange
                - from
                - to
                - categoryIds
                - owners
                - stageIds
                - sources
                - tags
                - search
                - skip
                - take
                - sortField
                - sortOrder
              x-apidog-ignore-properties: []
            examples:
              '1':
                value:
                  dateRange: custom
                  from: '2026-06-01T00:00:00'
                  to: '2026-06-03T00:00:00'
                  categoryIds:
                    - 1
                    - 2
                  owners:
                    - ownerCode
                  stageIds:
                    - 1
                    - 2
                  sources: []
                  tags:
                    - tag1
                    - tag2
                  search: null
                  skip: 0
                  take: 20
                  sortField: title
                  sortOrder: desc
                summary: Full Enquiry
              '2':
                value:
                  skip: 0
                  take: 20
                summary: Minimal Enquiry
      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: object
                    properties:
                      total:
                        type: integer
                      hasMore:
                        type: boolean
                      rows:
                        type: array
                        items:
                          type: object
                          properties:
                            caseNo:
                              type: string
                            subject:
                              type: string
                            description:
                              type: string
                              nullable: true
                            categoryId:
                              type: integer
                            stageId:
                              type: integer
                            customerCode:
                              type: string
                              nullable: true
                            source:
                              type: string
                            sourceName:
                              type: string
                            dateCase:
                              type: string
                            dateDue:
                              type: string
                            caseTag:
                              type: array
                              items:
                                type: string
                            activityNo:
                              type: array
                              items:
                                type: string
                            dealNo:
                              type: array
                              items:
                                type: string
                            chatId:
                              type: string
                              nullable: true
                            sla:
                              type: object
                              properties:
                                cycleStartedAt:
                                  type: string
                                firstReplyAt:
                                  type: 'null'
                                reopenCount:
                                  type: integer
                                firstResponse:
                                  type: object
                                  properties:
                                    targetMs:
                                      type: integer
                                    elapsedMs:
                                      type: 'null'
                                    breached:
                                      type: boolean
                                  required:
                                    - targetMs
                                    - elapsedMs
                                    - breached
                                  x-apidog-orders:
                                    - targetMs
                                    - elapsedMs
                                    - breached
                                  x-apidog-ignore-properties: []
                                resolution:
                                  type: object
                                  properties:
                                    targetMs:
                                      type: integer
                                    elapsedMs:
                                      type: 'null'
                                    breached:
                                      type: boolean
                                  required:
                                    - targetMs
                                    - elapsedMs
                                    - breached
                                  x-apidog-orders:
                                    - targetMs
                                    - elapsedMs
                                    - breached
                                  x-apidog-ignore-properties: []
                              required:
                                - cycleStartedAt
                                - firstReplyAt
                                - reopenCount
                                - firstResponse
                                - resolution
                              x-apidog-orders:
                                - cycleStartedAt
                                - firstReplyAt
                                - reopenCount
                                - firstResponse
                                - resolution
                              x-apidog-ignore-properties: []
                            owner:
                              type: string
                            participants:
                              type: array
                              items:
                                type: string
                          required:
                            - caseNo
                            - subject
                            - description
                            - categoryId
                            - stageId
                            - customerCode
                            - source
                            - sourceName
                            - dateCase
                            - dateDue
                            - caseTag
                            - activityNo
                            - dealNo
                            - chatId
                            - sla
                            - owner
                            - participants
                          x-apidog-orders:
                            - caseNo
                            - subject
                            - description
                            - categoryId
                            - stageId
                            - customerCode
                            - source
                            - sourceName
                            - dateCase
                            - dateDue
                            - caseTag
                            - activityNo
                            - dealNo
                            - chatId
                            - sla
                            - owner
                            - participants
                          x-apidog-ignore-properties: []
                    required:
                      - total
                      - hasMore
                      - rows
                    x-apidog-orders:
                      - total
                      - hasMore
                      - rows
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - data
                x-apidog-orders:
                  - status
                  - data
                x-apidog-ignore-properties: []
              examples:
                '1':
                  summary: Success
                  value:
                    status:
                      code: '1000'
                      description: Success
                    data:
                      total: 57
                      hasMore: true
                      rows:
                        - caseNo: CaseNo1
                          subject: Subject1
                          description: Description1
                          categoryId: 1
                          stageId: 1
                          customerCode: CustomerCode1
                          source: '1'
                          sourceName: อีเมล
                          dateCase: '2026-06-01T09:00:00Z'
                          dateDue: '2026-06-01T17:00:00Z'
                          caseTag:
                            - CaseTag1
                          activityNo:
                            - ActivityNo1
                          dealNo:
                            - DealNo1
                          chatId: ChatId1
                          sla:
                            cycleStartedAt: '2026-06-01T09:00:05Z'
                            firstReplyAt: null
                            reopenCount: 0
                            firstResponse:
                              targetMs: 1800000
                              elapsedMs: null
                              breached: false
                            resolution:
                              targetMs: 86400000
                              elapsedMs: null
                              breached: false
                          owner: StaffCode1
                          participants:
                            - StaffCode2
                        - caseNo: CaseNo2
                          subject: Subject2
                          description: null
                          categoryId: 1
                          stageId: 1
                          customerCode: null
                          source: '1'
                          sourceName: อีเมล
                          dateCase: '2026-06-01T09:00:00Z'
                          dateDue: '2026-06-01T17:00:00Z'
                          caseTag: []
                          activityNo: []
                          dealNo: []
                          chatId: null
                          sla:
                            cycleStartedAt: '2026-06-01T09:00:05Z'
                            firstReplyAt: null
                            reopenCount: 0
                            firstResponse:
                              targetMs: 1800000
                              elapsedMs: null
                              breached: false
                            resolution:
                              targetMs: 86400000
                              elapsedMs: null
                              breached: false
                          owner: StaffCode2
                          participants: []
                '2':
                  summary: No Result
                  value:
                    status:
                      code: '1000'
                      description: Success
                    data:
                      total: 0
                      hasMore: false
                      rows: []
          headers: {}
          x-apidog-name: Success
        '400':
          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: object
                    properties:
                      errors:
                        type: array
                        items:
                          type: object
                          properties:
                            subCode:
                              type: string
                            description:
                              type: string
                            metadata:
                              type: 'null'
                          x-apidog-orders:
                            - subCode
                            - description
                            - metadata
                          x-apidog-ignore-properties: []
                    required:
                      - errors
                    x-apidog-orders:
                      - errors
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - data
                x-apidog-orders:
                  - status
                  - data
                x-apidog-ignore-properties: []
              example:
                status:
                  code: '4001'
                  description: Business error with 1 or more errors
                data:
                  errors:
                    - subCode: '400'
                      description: >-
                        owners staffCode(s) not found in your company:
                        StaffCode0
                      metadata: null
          headers: {}
          x-apidog-name: Owner StaffCode Not Found
        '403':
          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: object
                    properties:
                      errors:
                        type: array
                        items:
                          type: object
                          properties:
                            subCode:
                              type: string
                            description:
                              type: string
                            metadata:
                              type: 'null'
                          x-apidog-orders:
                            - subCode
                            - description
                            - metadata
                          x-apidog-ignore-properties: []
                    required:
                      - errors
                    x-apidog-orders:
                      - errors
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - data
                x-apidog-orders:
                  - status
                  - data
                x-apidog-ignore-properties: []
              example:
                status:
                  code: '4001'
                  description: Business error with 1 or more errors
                data:
                  errors:
                    - subCode: '403'
                      description: Invalid access rights.
                      metadata: null
          headers: {}
          x-apidog-name: Forbidden
        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.
        5XX:
          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: object
                    properties:
                      errors:
                        type: array
                        items:
                          type: object
                          properties:
                            subCode:
                              type: string
                            description:
                              type: string
                            metadata:
                              type: 'null'
                          x-apidog-orders:
                            - subCode
                            - description
                            - metadata
                          x-apidog-ignore-properties: []
                    required:
                      - errors
                    x-apidog-orders:
                      - errors
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - data
                x-apidog-orders:
                  - status
                  - data
                x-apidog-ignore-properties: []
              examples:
                '5':
                  summary: Example 1
                  value:
                    status:
                      code: '4001'
                      description: Business error with 1 or more errors
                    data:
                      errors:
                        - subCode: '500'
                          description: >-
                            [DEBUG] HttpRequestException: No connection could be
                            made because the target machine actively refused it.
                          metadata: null
                '6':
                  summary: Example 2
                  value:
                    status:
                      code: '4001'
                      description: Business error with 1 or more errors
                    data:
                      errors:
                        - subCode: '502'
                          description: 'CaseManagement returned 502: (empty body)'
                          metadata: null
          headers: {}
          x-apidog-name: Server Error
      security:
        - bearer: []
      x-apidog-folder: Venio/Case Management
      x-apidog-status: developing
      x-run-in-apidog: https://app.apidog.com/web/project/351895/apis/api-38554363-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: http
      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: []

```
