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

# Chat Analytics

> Aggregate KPIs for the AI Chat dashboard.

Window-based — `?window_days=N` controls the lookback. We never run
cross-tenant aggregates here; RLS scopes everything automatically.



## OpenAPI

````yaml https://api.vellaro.io/openapi.json get /api/v1/admin/chat/analytics
openapi: 3.1.0
info:
  title: Vellaro API
  description: Vellaro 2026 — E-commerce API
  version: 0.1.0
servers:
  - url: https://api.vellaro.io
    description: Produzione
security: []
tags: []
paths:
  /api/v1/admin/chat/analytics:
    get:
      tags:
        - admin:chat
      summary: Chat Analytics
      description: |-
        Aggregate KPIs for the AI Chat dashboard.

        Window-based — `?window_days=N` controls the lookback. We never run
        cross-tenant aggregates here; RLS scopes everything automatically.
      operationId: chat_analytics_api_v1_admin_chat_analytics_get
      parameters:
        - name: window_days
          in: query
          required: false
          schema:
            type: integer
            maximum: 365
            minimum: 1
            default: 30
            title: Window Days
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_ChatAnalyticsOut_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ApiResponse_ChatAnalyticsOut_:
      properties:
        data:
          anyOf:
            - $ref: '#/components/schemas/ChatAnalyticsOut'
            - type: 'null'
        meta:
          anyOf:
            - $ref: '#/components/schemas/PaginationMeta'
            - type: 'null'
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
      type: object
      title: ApiResponse[ChatAnalyticsOut]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ChatAnalyticsOut:
      properties:
        window_days:
          type: integer
          title: Window Days
        conversations:
          type: integer
          title: Conversations
        messages:
          type: integer
          title: Messages
        assistant_messages:
          type: integer
          title: Assistant Messages
        refusals:
          type: integer
          title: Refusals
        refusal_rate:
          type: number
          title: Refusal Rate
        total_cost_cents:
          type: integer
          title: Total Cost Cents
        avg_messages_per_conv:
          type: number
          title: Avg Messages Per Conv
        feedback_positive:
          type: integer
          title: Feedback Positive
        feedback_negative:
          type: integer
          title: Feedback Negative
        by_safety:
          additionalProperties:
            type: integer
          type: object
          title: By Safety
        daily_volume:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Daily Volume
      type: object
      required:
        - window_days
        - conversations
        - messages
        - assistant_messages
        - refusals
        - refusal_rate
        - total_cost_cents
        - avg_messages_per_conv
        - feedback_positive
        - feedback_negative
        - by_safety
        - daily_volume
      title: ChatAnalyticsOut
    PaginationMeta:
      properties:
        page:
          type: integer
          title: Page
        page_size:
          type: integer
          title: Page Size
        total:
          type: integer
          title: Total
        total_pages:
          type: integer
          title: Total Pages
      type: object
      required:
        - page
        - page_size
        - total
        - total_pages
      title: PaginationMeta
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````