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

# Active sessions right now

> Live count of active Keycloak sessions right now, broken down by client.



## OpenAPI

````yaml /openapi/user.yaml get /api/v1/analytics/sessions/active
openapi: 3.0.3
info:
  title: CapeMedia User Service API
  version: 1.0.0
  description: |2-

        **CapeMedia User Service API** - Comprehensive user service and management system.

        ## Authentication
        This API uses **JWT Bearer tokens** for authentication.

        1. Login via `/api/v1/auth/login` to obtain tokens
        2. Include the access token in the `Authorization` header: `Bearer <access_token>`
        3. Refresh expired tokens via `/api/v1/auth/refresh-token`

        ## Versioning
        The API uses URL path versioning (e.g., `/api/v1/`, `/api/v2/`).
        Current version: **v1**
        
  contact:
    name: API Support
    email: support@capemedia.co.ke
  license:
    name: Cape Media
servers:
  - url: https://api.diginacape.co.ke/acl
    description: Production
  - url: http://sapi.diginacape.co.ke/acl
    description: Local development
security: []
paths:
  /api/v1/analytics/sessions/active:
    get:
      tags:
        - Analytics
      summary: Active sessions right now
      description: Live count of active Keycloak sessions right now, broken down by client.
      operationId: analytics_sessions_active_retrieve
      parameters:
        - in: query
          name: realm
          schema:
            type: string
          description: Keycloak realm
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActiveSessionsResponse'
          description: ''
      security:
        - bearerAuth: []
components:
  schemas:
    ActiveSessionsResponse:
      type: object
      description: Full ``APIResponse`` envelope for the active-sessions endpoint.
      properties:
        success:
          type: boolean
        message:
          type: string
        data:
          $ref: '#/components/schemas/ActiveSessions'
      required:
        - data
        - message
        - success
    ActiveSessions:
      type: object
      description: Payload returned under ``data`` by the active-sessions endpoint.
      properties:
        total_active:
          type: integer
          description: Sum of active sessions across all clients, realm-wide.
        clients:
          type: array
          items:
            $ref: '#/components/schemas/ClientSessionStats'
        generated_at:
          type: string
          format: date-time
          description: When this snapshot was fetched from Keycloak.
      required:
        - clients
        - generated_at
        - total_active
    ClientSessionStats:
      type: object
      description: Active session count for a single Keycloak client.
      properties:
        client_id:
          type: string
          description: Keycloak client id, e.g. 'web-app'.
        active:
          type: integer
          description: Active session count for this client.
      required:
        - active
        - client_id
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Enter your JWT token in the format: Bearer <token>'

````