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

# Get All Users

> Retrieve all users with pagination and filtering. Only accessible by administrators.


# Get All Users

Retrieve all users with pagination and filtering. Only accessible by administrators.

## Endpoint

```
GET /users
```

## Description

This endpoint allows administrators to retrieve a paginated list of all users in the system. It supports filtering by various criteria including role, license, status, and search terms. This is an administrative endpoint that requires appropriate permissions.

## Authentication

Required. Include your API key in the Authorization header.

```bash theme={null}
Authorization: Bearer sk-your-api-key-here
```

## Request

### Query Parameters

| Parameter   | Type    | Required | Default   | Description                                                     |
| ----------- | ------- | -------- | --------- | --------------------------------------------------------------- |
| `page`      | integer | No       | 1         | Page number for pagination                                      |
| `limit`     | integer | No       | 20        | Number of users per page (1-100)                                |
| `search`    | string  | No       | -         | Search term for name, email, or username                        |
| `role`      | string  | No       | -         | Filter by user role (admin, user, globalReader)                 |
| `license`   | string  | No       | -         | Filter by user license (Essential, Growth, Ultra, Early Access) |
| `status`    | integer | No       | -         | Filter by user status (0=inactive, 1=active)                    |
| `sortBy`    | string  | No       | createdAt | Field to sort by                                                |
| `sortOrder` | string  | No       | desc      | Sort order (asc, desc)                                          |

### Example Request

```bash theme={null}
curl -X GET "https://{customer.name}.hiperai.ai/api/external/users?page=1&limit=20&role=user&status=1" \
  -H "Authorization: Bearer sk-your-api-key-here"
```

With search:

```bash theme={null}
curl -X GET "https://{customer.name}.hiperai.ai/api/external/users?search=john&license=Growth" \
  -H "Authorization: Bearer sk-your-api-key-here"
```

## Response

### Success Response (200)

```json theme={null}
{
  "success": true,
  "users": [
    {
      "id": "60a7c8f5e8b4f5001f7a8c23",
      "name": "John Doe",
      "username": "johndoe",
      "email": "john@example.com",
      "role": "user",
      "license": "Growth",
      "status": 1,
      "isVerified": true,
      "setupCompleted": true,
      "authType": "basic",
      "mfaEnabled": false,
      "customRole": {
        "id": "60a7c8f5e8b4f5001f7a8c24",
        "name": "custom_role",
        "displayName": "Custom Role"
      },
      "createdAt": "2024-01-01T00:00:00.000Z",
      "updatedAt": "2024-01-15T10:30:00.000Z",
      "lastActive": "2024-01-15T10:30:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "pages": 8
  }
}
```

### Response Fields

| Field                            | Type    | Description                                                  |
| -------------------------------- | ------- | ------------------------------------------------------------ |
| `success`                        | boolean | Always `true` for successful requests                        |
| `users`                          | array   | Array of user objects                                        |
| `users[].id`                     | string  | User's unique identifier                                     |
| `users[].name`                   | string  | User's full name                                             |
| `users[].username`               | string  | User's username                                              |
| `users[].email`                  | string  | User's email address                                         |
| `users[].role`                   | string  | User's role (admin, user, globalReader)                      |
| `users[].license`                | string  | User's license tier (Essential, Growth, Ultra, Early Access) |
| `users[].status`                 | integer | User status (0=inactive, 1=active)                           |
| `users[].isVerified`             | boolean | Whether user is verified                                     |
| `users[].setupCompleted`         | boolean | Whether user setup is completed                              |
| `users[].authType`               | string  | Authentication type (basic, auth0)                           |
| `users[].mfaEnabled`             | boolean | Whether MFA is enabled                                       |
| `users[].customRole`             | object  | Custom role information (if assigned)                        |
| `users[].customRole.id`          | string  | Custom role ID                                               |
| `users[].customRole.name`        | string  | Custom role name                                             |
| `users[].customRole.displayName` | string  | Custom role display name                                     |
| `users[].createdAt`              | string  | User creation timestamp                                      |
| `users[].updatedAt`              | string  | User last update timestamp                                   |
| `users[].lastActive`             | string  | User's last activity timestamp                               |
| `pagination`                     | object  | Pagination information                                       |
| `pagination.page`                | integer | Current page number                                          |
| `pagination.limit`               | integer | Items per page                                               |
| `pagination.total`               | integer | Total number of users                                        |
| `pagination.pages`               | integer | Total number of pages                                        |

## Example Usage

### JavaScript

```javascript theme={null}
const response = await fetch('https://{customer.name}.hiperai.ai/api/external/users?page=1&limit=20', {
  headers: {
    'Authorization': 'Bearer sk-your-api-key-here'
  }
});

const data = await response.json();

if (data.success) {
  console.log(`Showing ${data.users.length} of ${data.pagination.total} users`);
  data.users.forEach(user => {
    console.log(`${user.name} (${user.email}) - ${user.role}`);
  });
}
```

### Python

```python theme={null}
import requests

headers = {
    'Authorization': 'Bearer sk-your-api-key-here'
}

params = {
    'page': 1,
    'limit': 20,
    'role': 'user',
    'status': 1
}

response = requests.get('https://{customer.name}.hiperai.ai/api/external/users', 
                      headers=headers, params=params)
data = response.json()

if data['success']:
    print(f"Showing {len(data['users'])} of {data['pagination']['total']} users")
    for user in data['users']:
        print(f"{user['name']} ({user['email']}) - {user['role']}")
```

### cURL

```bash theme={null}
curl -X GET "https://{customer.name}.hiperai.ai/api/external/users?page=1&limit=20" \
  -H "Authorization: Bearer sk-your-api-key-here"
```

## Error Responses

### 401 Unauthorized

```json theme={null}
{
  "success": false,
  "error": "Invalid API key",
  "message": "The provided API key is invalid or has been revoked"
}
```

### 403 Forbidden

```json theme={null}
{
  "success": false,
  "error": "Access denied",
  "message": "Admin access required"
}
```

## Filtering Examples

### Search by Name or Email

```bash theme={null}
curl -X GET "https://{customer.name}.hiperai.ai/api/external/users?search=john" \
  -H "Authorization: Bearer sk-your-api-key-here"
```

### Filter by Role

```bash theme={null}
curl -X GET "https://{customer.name}.hiperai.ai/api/external/users?role=admin" \
  -H "Authorization: Bearer sk-your-api-key-here"
```

### Filter by License

```bash theme={null}
curl -X GET "https://{customer.name}.hiperai.ai/api/external/users?license=Growth" \
  -H "Authorization: Bearer sk-your-api-key-here"
```

### Filter by Status

```bash theme={null}
curl -X GET "https://{customer.name}.hiperai.ai/api/external/users?status=1" \
  -H "Authorization: Bearer sk-your-api-key-here"
```

### Sort by Last Active

```bash theme={null}
curl -X GET "https://{customer.name}.hiperai.ai/api/external/users?sortBy=lastActive&sortOrder=desc" \
  -H "Authorization: Bearer sk-your-api-key-here"
```

## Use Cases

* **User Management**: View and manage all users in the system
* **User Analytics**: Analyze user distribution by role, license, or status
* **Search and Filter**: Find specific users based on various criteria
* **Administrative Tasks**: Support administrative operations and reporting

## Role Descriptions

* **admin**: Full system access with administrative control
* **user**: Standard access to chat features and personal knowledge bases
* **globalReader**: Read-only access to admin panel with viewing permissions

## License Descriptions

* **Essential**: Basic tier with 29,000 points/month
* **Growth**: Mid-tier with enhanced features
* **Ultra**: Premium tier with maximum features
* **Early Access**: Beta tier with experimental capabilities

## Rate Limits

This endpoint follows the standard rate limits:

* 60 requests per minute
* 1000 requests per hour


## OpenAPI

````yaml GET /users
openapi: 3.0.3
info:
  title: SecureAI External API
  description: >
    SecureAI External API provides AI chat completion and image generation
    capabilities with knowledge base retrieval, 

    security policies, and comprehensive usage tracking. This API is designed
    for external developers 

    and integrations using API key authentication.


    ## Key Features

    - **RAG (Retrieval-Augmented Generation)**: Automatically search knowledge
    bases for relevant context

    - **Multi-Model Support**: OpenAI, Anthropic, Google, Meta, and other AI
    models

    - **Model Redundancy & Failover**: Caller-defined failover chains (primary +
    fallbacks) with per-attempt timeouts

    - **OpenAI-Compatible Endpoint**: Point any OpenAI SDK at `/api/external/v1`
    — no code changes

    - **Image Generation**: Generate and edit images using Google Gemini 2.5
    Flash Image

    - **Speech-to-Speech (S2S)**: Real-time voice conversations using OpenAI
    Realtime API with WebRTC

    - **Security Policies**: SMLTP policy enforcement, per-call Prompt Shield,
    and signed compliance receipts

    - **Usage Tracking**: Comprehensive usage monitoring, self-service quota,
    and rate limiting

    - **Knowledge Base Integration**: Access to personal and shared knowledge
    bases

    - **User Management**: Complete user, group, and role management
    capabilities

    - **Audit Logging**: Comprehensive activity and security audit logs


    ## Authentication

    All endpoints (except health check) require API key authentication using
    Bearer token:

    ```

    Authorization: Bearer sk-your-api-key-here

    ```


    ## Billing and Usage

    By default, API requests are billed to the user account that owns the API
    key. You can specify 

    a different user to bill by including the `user_id` parameter in your
    request. This allows for:

    - Multi-tenant applications with per-user billing

    - Flexible completion limit management

    - Per-user "Usage by Model" settings


    ## Rate Limits

    - Default: 60 requests per minute, 1000 requests per hour

    - Daily limits: 100 requests (configurable)

    - Monthly limits: 10,000 requests (configurable)


    ## Base URL

    ```

    https://secureai.hiperai.ai/api/external

    ```
  version: 1.1.0
  contact:
    name: SecureAI Support
    email: support@secureai.hiperai.ai
  license:
    name: Proprietary
    url: https://secureai.hiperai.ai/terms
servers:
  - url: https://secureai.hiperai.ai/api/external
    description: Production server
  - url: http://localhost:3010/api/external
    description: Development server
security:
  - ApiKeyAuth: []
tags:
  - name: System
    description: System health and status endpoints
  - name: Discovery
    description: Endpoints to discover available models, indexes, and policies
  - name: Chat
    description: AI chat completion endpoints
  - name: User Management
    description: Endpoints for managing user accounts and roles
  - name: Index Management
    description: Endpoints for managing knowledge base indexes
  - name: Group Management
    description: Endpoints for managing user groups
  - name: SMLTP Security
    description: Endpoints for managing SMLTP security policies and audit logs
  - name: Role Management
    description: Endpoints for managing user roles
  - name: Activity Logs
    description: Endpoints for retrieving activity logs
externalDocs:
  description: SecureAI Documentation
  url: https://secureai.hiperai.ai/docs
paths:
  /users:
    get:
      tags:
        - User Management
      summary: Get All Users
      description: >
        Retrieve all users with pagination and filtering. Only accessible by
        administrators.
      parameters:
        - name: page
          in: query
          description: Page number for pagination
          required: false
          schema:
            type: integer
            default: 1
            minimum: 1
        - name: limit
          in: query
          description: Number of users per page
          required: false
          schema:
            type: integer
            default: 20
            minimum: 1
            maximum: 100
        - name: search
          in: query
          description: Search term for name, email, or username
          required: false
          schema:
            type: string
        - name: role
          in: query
          description: Filter by user role
          required: false
          schema:
            type: string
            enum:
              - admin
              - user
              - globalReader
        - name: license
          in: query
          description: Filter by user license
          required: false
          schema:
            type: string
            enum:
              - Essential
              - Growth
              - Ultra
              - Early Access
        - name: status
          in: query
          description: Filter by user status (0=inactive, 1=active)
          required: false
          schema:
            type: integer
            enum:
              - 0
              - 1
        - name: sortBy
          in: query
          description: Field to sort by
          required: false
          schema:
            type: string
            default: createdAt
        - name: sortOrder
          in: query
          description: Sort order
          required: false
          schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
      responses:
        '200':
          description: List of users
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  users:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          example: 60a7c8f5e8b4f5001f7a8c23
                        name:
                          type: string
                          example: John Doe
                        username:
                          type: string
                          example: johndoe
                        email:
                          type: string
                          example: john@example.com
                        role:
                          type: string
                          example: user
                        license:
                          type: string
                          example: Growth
                        status:
                          type: integer
                          example: 1
                        isVerified:
                          type: boolean
                          example: true
                        setupCompleted:
                          type: boolean
                          example: true
                        authType:
                          type: string
                          example: basic
                        mfaEnabled:
                          type: boolean
                          example: false
                        customRole:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: string
                              example: 60a7c8f5e8b4f5001f7a8c24
                            name:
                              type: string
                              example: custom_role
                            displayName:
                              type: string
                              example: Custom Role
                        createdAt:
                          type: string
                          format: date-time
                          example: '2024-01-01T00:00:00.000Z'
                        updatedAt:
                          type: string
                          format: date-time
                          example: '2024-01-15T10:30:00.000Z'
                        lastActive:
                          type: string
                          format: date-time
                          example: '2024-01-15T10:30:00.000Z'
                  pagination:
                    type: object
                    properties:
                      page:
                        type: integer
                        example: 1
                      limit:
                        type: integer
                        example: 20
                      total:
                        type: integer
                        example: 150
                      pages:
                        type: integer
                        example: 8
        '401':
          description: Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Access denied - admin only
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          example: Invalid API key
        message:
          type: string
          example: The provided API key is invalid or has been revoked
        request_id:
          type: string
          example: req-abc123
          description: Request ID for tracking (if available)
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      description: |
        API key authentication using Bearer token format.
        Example: `Authorization: Bearer sk-your-api-key-here`

````