> ## Documentation Index
> Fetch the complete documentation index at: https://www.studyfetch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get all chat messages from sessions for user or group



## OpenAPI

````yaml /openapi-components.json get /api/v1/usage-analyst/chat-messages
openapi: 3.0.0
info:
  title: StudyFetch API
  description: API documentation for StudyFetch
  version: '1.0'
  contact: {}
servers:
  - url: https://studyfetchapi.com
    description: Production API Server
security: []
tags: []
paths:
  /api/v1/usage-analyst/chat-messages:
    get:
      tags:
        - Usage Analyst
      summary: Get all chat messages from sessions for user or group
      operationId: getChatMessages
      parameters:
        - name: userId
          required: false
          in: query
          description: User ID to get chat messages for
          schema:
            type: string
        - name: groupIds
          required: false
          in: query
          description: Array of group IDs to filter
          schema:
            example:
              - class-101
              - class-102
            type: array
            items:
              type: string
      responses:
        '200':
          description: Chat messages retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  messages:
                    type: array
                    items:
                      type: object
                      properties:
                        sessionId:
                          type: string
                        userId:
                          type: string
                        componentId:
                          type: string
                        role:
                          type: string
                          enum:
                            - user
                            - assistant
                            - system
                        content:
                          type: string
                        createdAt:
                          type: string
                          format: date-time
                        metadata:
                          type: object
                  total:
                    type: number
                  sessionCount:
                    type: number
      security:
        - x-api-key: []
components:
  securitySchemes:
    x-api-key:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API Key for server-to-server authentication. Resolves to the owning
        organization.

````