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

> ## Agent Instructions
> These are the DualMind developer and admin docs. The API base URL is https://api.dualmindlab.tech and the local API runs on http://localhost:5079.
> Never send POST, PUT, PATCH or DELETE requests to the production API while developing; use a local API and a development Supabase project.
> Environment variables are documented by name only. Never ask for or print secret values.
> Admin routes under /api/admin require a Supabase access token for a user whose public.users.role is admin. The PUT routes for users, models, providers and threads write every field, so send the full record; PUT /api/admin/keys/{keyId} writes only the fields you send (sending api_key replaces the key).

# Get the dashboard

> Headline metrics, API-key health per provider, the five most recent users, comparisons and votes, and a database health flag. This is what the admin dashboard renders.

<Badge color="purple" icon="shield-check" stroke>AdminOnly</Badge> <Badge color="surface" icon="key-round">Bearer token, role admin</Badge>


## OpenAPI

````yaml api-reference/openapi-admin.json GET /api/admin/dashboard
openapi: 3.1.0
info:
  title: DualMind Admin API
  version: 1.0.0
  description: >-
    Admin routes of the DualMind API (`/api/admin/*`). Every route requires a
    Supabase access token for an account whose `public.users.role` is `admin`
    (the `AdminOnly` policy). Responses use the `{ success, data, total, page,
    pageSize, message, error }` envelope.
servers:
  - url: https://api.dualmindlab.tech
    description: Production
  - url: http://localhost:5079
    description: Local (dotnet run)
security:
  - bearerAuth: []
tags:
  - name: Dashboard
  - name: Users
  - name: AI models
  - name: Providers
  - name: API keys
  - name: Comparisons
  - name: Votes
  - name: Threads
  - name: Messages
paths:
  /api/admin/dashboard:
    get:
      tags:
        - Dashboard
      summary: Get the dashboard
      description: >-
        Headline metrics, API-key health per provider, the five most recent
        users, comparisons and votes, and a database health flag. This is what
        the admin dashboard renders.
      operationId: adminGetDashboard
      responses:
        '200':
          description: Dashboard data
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      metrics:
                        type: object
                        properties:
                          total_users:
                            type: integer
                          active_models:
                            type: integer
                          total_comparisons:
                            type: integer
                          total_votes:
                            type: integer
                      api_keys:
                        type: object
                        properties:
                          total:
                            type: integer
                          active:
                            type: integer
                          in_cooldown:
                            type: integer
                      health:
                        type: object
                        properties:
                          supabase_realtime:
                            type: string
                            enum:
                              - online
                              - offline
                          redis:
                            type: string
                            description: Always `offline`; there is no Redis. Ignore it.
                      total_users:
                        type: integer
                      total_models:
                        type: integer
                      total_comparisons:
                        type: integer
                      total_votes:
                        type: integer
                      active_models_count:
                        type: integer
                      recent_activity:
                        type: object
                        properties:
                          recent_users:
                            type: array
                            items:
                              $ref: '#/components/schemas/AdminUser'
                          recent_comparisons:
                            type: array
                            items:
                              $ref: '#/components/schemas/AdminComparison'
                          recent_votes:
                            type: array
                            items:
                              $ref: '#/components/schemas/AdminVote'
                      provider_health:
                        type: array
                        items:
                          type: object
                          properties:
                            provider_name:
                              type: string
                            display_name:
                              type: string
                            is_enabled:
                              type: boolean
                            total_keys:
                              type: integer
                            active_keys:
                              type: integer
                            keys_in_cooldown:
                              type: integer
                            total_calls:
                              type: integer
                            total_failures:
                              type: integer
                      api_key_metrics:
                        type: object
                        properties:
                          total_keys:
                            type: integer
                          active_keys:
                            type: integer
                          keys_in_cooldown:
                            type: integer
                      system_health_status:
                        type: string
                        enum:
                          - healthy
                          - unhealthy
        '401':
          description: Missing, expired or invalid bearer token.
        '403':
          description: Signed in, but `public.users.role` is not `admin`.
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AdminUser:
      type: object
      properties:
        user_id:
          type: string
          format: uuid
          description: Supabase Auth user ID (primary key).
          example: 8b1f3c2a-4d5e-4f60-8a7b-9c0d1e2f3a4b
        full_name:
          type:
            - string
            - 'null'
          description: Display name.
          example: Asha Patel
        email:
          type:
            - string
            - 'null'
          format: email
          description: Email address.
          example: asha@example.com
        role:
          type: string
          enum:
            - admin
            - user
          description: >-
            Role read by the API on every authenticated request. `admin` unlocks
            `/api/admin/*`.
          example: user
        created_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the row was created.
        last_login_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Last sign-in, when recorded.
    AdminComparison:
      type: object
      properties:
        comparison_id:
          type: string
          format: uuid
          description: Comparison ID. Also returned to the arena as `comparisonId`.
        user_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Who ran the battle.
        thread_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Thread, when known.
        prompt_text:
          type:
            - string
            - 'null'
          description: The prompt both models answered.
          example: Explain TCP vs UDP with a pizza analogy.
        model1_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Left model. Resolve names with `GET /api/admin/models`.
        model2_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Right model.
        model1_response:
          type:
            - string
            - 'null'
          description: Left response.
        model2_response:
          type:
            - string
            - 'null'
          description: Right response.
        model1_time_ms:
          type:
            - integer
            - 'null'
          description: Response time recorded for the left model, in ms.
          example: 2410
        model2_time_ms:
          type:
            - integer
            - 'null'
          description: Response time recorded for the right model, in ms.
          example: 2410
        mode:
          type:
            - string
            - 'null'
          description: Mode, when recorded.
        category:
          type:
            - string
            - 'null'
          description: Reserved for category leaderboards.
        is_revealed:
          type:
            - boolean
            - 'null'
          description: Set to `true` once a vote is recorded.
          example: false
        is_flagged:
          type:
            - boolean
            - 'null'
          description: Reserved for moderation.
        created_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Created at.
    AdminVote:
      type: object
      properties:
        vote_id:
          type: string
          format: uuid
          description: Vote ID.
        user_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Voter.
        comparison_id:
          type: string
          format: uuid
          description: The comparison voted on.
        winner_model_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Winning model. `null` for `tie` and `both-bad`.
        vote_choice:
          type:
            - string
            - 'null'
          enum:
            - left
            - right
            - tie
            - both-bad
          description: What the voter picked.
          example: left
        vote_duration_ms:
          type:
            - integer
            - 'null'
          description: Time from responses shown to vote, in ms.
          example: 8200
        voted_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the vote was cast.
        revealed_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When identities were revealed to the voter.
        picked_model_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Alias of `winner_model_id`.
        choice:
          type:
            - string
            - 'null'
          description: Alias of `vote_choice`.
        created_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Alias of `voted_at`.
    Error:
      type: object
      properties:
        success:
          type: boolean
          description: Always `false`.
          example: false
        error:
          type: string
          description: What went wrong.
          example: 'Role must be one of: admin, user'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Supabase access token of an account with `role = 'admin'` in
        `public.users`.

````

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