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

# Query session analytics

> Returns session counts, average duration, and completion rate bucketed by day or
hour over the requested date range.




## OpenAPI

````yaml /openapi.yaml get /api/v1/analytics/sessions
openapi: 3.1.0
info:
  title: Humain Kiosk — Device API
  version: '1.0'
  description: >
    The Device API is consumed by physical kiosk terminals, VoIP adapters, and
    website

    widgets. All requests require a device credential issued from the Humain
    admin panel.


    **Base URL:** `https://api.humain.ai` — there is no separate sandbox host.
    Sandbox is a

    property of the credential, not the URL: issue an `hk_test_…` credential
    from the admin

    panel and call the exact same endpoints. In sandbox mode, text sessions echo
    the input back

    verbatim and voice sessions run a record → beep → echo loop — no LLM call is
    made, per-turn

    guardrail/FraudGuard checks do not run, and no usage is billed. See

    [Sandbox mode](/concepts/sandbox-mode).


    Opening a session returns an `agent_url` — use it as the base URL for every
    subsequent

    real-time call (WebSocket, WebRTC, session end) instead of assuming the same
    host that

    served `POST /v1/sessions`. In most deployments `agent_url` is the same
    public API host

    behind a reverse proxy; treat it as opaque and always use the value
    returned.


    Browser-side integrations that cannot hold a device credential — a website
    widget, a

    single-page app — should use the [Public Gateway](/concepts/public-gateway)
    instead of

    calling these endpoints directly. It runs on a separate host and isn't
    documented in this

    reference; see the linked page for its own request/response shapes.
servers:
  - url: https://api.humain.ai
    description: >-
      Production and sandbox — sandbox behavior is selected by using an hk_test_
      credential, not a different URL
security:
  - DeviceToken: []
tags:
  - name: Sessions
    description: Open, interact with, and close conversation sessions.
  - name: Voice (WebRTC)
    description: Establish real-time voice sessions over WebRTC.
  - name: Webhooks
    description: >
      Manage webhook endpoints and inspect delivery history. Part of the Admin
      API —

      authenticated with the admin session cookie, not a device credential.
  - name: Analytics
    description: |
      Query session and usage analytics for a workspace. Part of the Admin API —
      authenticated with the admin session cookie, not a device credential.
paths:
  /api/v1/analytics/sessions:
    get:
      tags:
        - Analytics
      summary: Query session analytics
      description: >
        Returns session counts, average duration, and completion rate bucketed
        by day or

        hour over the requested date range.
      operationId: querySessionAnalytics
      parameters:
        - name: from
          in: query
          required: true
          description: Start of the date range (inclusive), ISO 8601 date.
          schema:
            type: string
            format: date
        - name: to
          in: query
          required: true
          description: End of the date range (inclusive), ISO 8601 date.
          schema:
            type: string
            format: date
        - name: kiosk_id
          in: query
          required: false
          description: Filter to a single kiosk. Omit to aggregate across the workspace.
          schema:
            type: string
        - name: granularity
          in: query
          required: false
          description: Bucket size for the returned series.
          schema:
            type: string
            enum:
              - hour
              - day
            default: day
      responses:
        '200':
          description: Session analytics series
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionAnalyticsResponse'
        '401':
          $ref: '#/components/responses/AdminUnauthenticated'
      security:
        - AdminSession: []
components:
  schemas:
    SessionAnalyticsResponse:
      type: object
      properties:
        granularity:
          type: string
          enum:
            - hour
            - day
        buckets:
          type: array
          items:
            $ref: '#/components/schemas/SessionAnalyticsBucket'
    SessionAnalyticsBucket:
      type: object
      properties:
        date:
          type: string
          format: date-time
        session_count:
          type: integer
        avg_duration_s:
          type: number
        completion_rate:
          type: number
          description: 'Fraction of sessions that ended with `end_reason: completed`.'
    Error:
      type: object
      properties:
        error:
          type: string
          description: Machine-readable error code in SCREAMING_SNAKE_CASE.
          example: UNAUTHENTICATED
        message:
          type: string
          description: Human-readable description of the error.
          example: Missing or invalid device token.
        details:
          type: object
          description: >-
            Additional error-specific fields (see individual error
            descriptions).
  responses:
    AdminUnauthenticated:
      description: Missing or invalid admin session.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: UNAUTHENTICATED
            message: Missing or invalid admin session.
            details: {}
  securitySchemes:
    DeviceToken:
      type: http
      scheme: bearer
      bearerFormat: hk_live_{43-char-base64url} | hk_test_{43-char-base64url}
      description: >
        Device credential issued from the Humain admin panel under

        **Kiosk → Credentials → Issue new credential**.


        Format: `hk_live_` (production) or `hk_test_` (sandbox) followed by 43
        base64url

        characters (32 random bytes). The raw token is shown only once at
        creation time and

        is never stored in plain text.
    AdminSession:
      type: apiKey
      in: cookie
      name: __session
      description: >
        Admin panel session cookie (HttpOnly), issued when a workspace admin
        signs in.

        Webhook and analytics endpoints are part of the Admin API surface and
        are not

        accessible with a device credential.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.