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

# Get Dashboard Stats

> Get dashboard statistics.

Returns comprehensive dashboard metrics including:
- Total counts (accounts, users, collections, records)
- Growth metrics (new accounts/users in last 7 days)
- Recent registrations (last 10 users)
- System health (database status, storage usage)
- Active sessions count
- Recent audit logs (PII masked based on user group membership)

Only superadmins (users in the system account with nil UUID) can access this endpoint.
PII is masked unless the user belongs to the 'pii_access' group.



## OpenAPI

````yaml get /api/v1/dashboard/stats
openapi: 3.1.0
info:
  title: SnackBase
  description: Open-source Backend-as-a-Service (BaaS)
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/dashboard/stats:
    get:
      tags:
        - dashboard
      summary: Get Dashboard Stats
      description: >-
        Get dashboard statistics.


        Returns comprehensive dashboard metrics including:

        - Total counts (accounts, users, collections, records)

        - Growth metrics (new accounts/users in last 7 days)

        - Recent registrations (last 10 users)

        - System health (database status, storage usage)

        - Active sessions count

        - Recent audit logs (PII masked based on user group membership)


        Only superadmins (users in the system account with nil UUID) can access
        this endpoint.

        PII is masked unless the user belongs to the 'pii_access' group.
      operationId: get_dashboard_stats_api_v1_dashboard_stats_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DashboardStats'
        '403':
          description: Superadmin access required
components:
  schemas:
    DashboardStats:
      properties:
        total_accounts:
          type: integer
          title: Total Accounts
        total_users:
          type: integer
          title: Total Users
        total_collections:
          type: integer
          title: Total Collections
        total_records:
          type: integer
          title: Total Records
        new_accounts_7d:
          type: integer
          title: New Accounts 7D
        new_users_7d:
          type: integer
          title: New Users 7D
        recent_registrations:
          items:
            $ref: '#/components/schemas/RecentRegistration'
          type: array
          title: Recent Registrations
        system_health:
          $ref: '#/components/schemas/SystemHealthStats'
        active_sessions:
          type: integer
          title: Active Sessions
        public_collections_count:
          type: integer
          title: Public Collections Count
          description: Collections with at least one public rule
          default: 0
        recent_audit_logs:
          items:
            $ref: '#/components/schemas/AuditLogResponse'
          type: array
          title: Recent Audit Logs
      type: object
      required:
        - total_accounts
        - total_users
        - total_collections
        - total_records
        - new_accounts_7d
        - new_users_7d
        - recent_registrations
        - system_health
        - active_sessions
        - recent_audit_logs
      title: DashboardStats
      description: Dashboard statistics response.
    RecentRegistration:
      properties:
        id:
          type: string
          title: Id
        email:
          type: string
          title: Email
        account_id:
          type: string
          title: Account Id
          description: Account ID (UUID)
        account_code:
          type: string
          title: Account Code
          description: Human-readable account code in XX#### format (e.g., AB1234)
        account_name:
          type: string
          title: Account Name
        created_at:
          type: string
          format: date-time
          title: Created At
      type: object
      required:
        - id
        - email
        - account_id
        - account_code
        - account_name
        - created_at
      title: RecentRegistration
      description: Recent user registration information.
    SystemHealthStats:
      properties:
        database_status:
          type: string
          title: Database Status
        storage_usage_mb:
          type: number
          title: Storage Usage Mb
      type: object
      required:
        - database_status
        - storage_usage_mb
      title: SystemHealthStats
      description: System health statistics.
    AuditLogResponse:
      properties:
        id:
          type: integer
          title: Id
          description: Unique identifier (sequence number)
        account_id:
          type: string
          title: Account Id
          description: Account context (UUID)
        operation:
          type: string
          title: Operation
          description: 'Operation type: CREATE, UPDATE, DELETE'
        table_name:
          type: string
          title: Table Name
          description: Table/collection name
        record_id:
          type: string
          title: Record Id
          description: ID of the affected record
        column_name:
          type: string
          title: Column Name
          description: Name of the changed column
        old_value:
          anyOf:
            - type: string
            - type: 'null'
          title: Old Value
          description: Previous value
        new_value:
          anyOf:
            - type: string
            - type: 'null'
          title: New Value
          description: New value
        user_id:
          type: string
          title: User Id
          description: ID of user who made the change
        user_email:
          type: string
          title: User Email
          description: Email of user who made the change
        user_name:
          type: string
          title: User Name
          description: Name of user who made the change
        es_username:
          anyOf:
            - type: string
            - type: 'null'
          title: Es Username
          description: Electronic signature username
        es_reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Es Reason
          description: Electronic signature reason
        es_timestamp:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Es Timestamp
          description: Electronic signature timestamp
        ip_address:
          anyOf:
            - type: string
            - type: 'null'
          title: Ip Address
          description: Client IP address
        user_agent:
          anyOf:
            - type: string
            - type: 'null'
          title: User Agent
          description: User agent string
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Request Id
          description: Correlation ID
        occurred_at:
          type: string
          format: date-time
          title: Occurred At
          description: Timestamp of the change (UTC)
        checksum:
          anyOf:
            - type: string
            - type: 'null'
          title: Checksum
          description: SHA-256 hash of this entry
        previous_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Previous Hash
          description: Checksum of the previous entry
        extra_metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Extra Metadata
          description: Additional metadata
      type: object
      required:
        - id
        - account_id
        - operation
        - table_name
        - record_id
        - column_name
        - user_id
        - user_email
        - user_name
        - occurred_at
      title: AuditLogResponse
      description: Response for a single audit log entry.

````