> ## Content Index
> Fetch the complete content index at: https://blog.fabrixly.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Use Analytics and License Management APIs
- URL: https://blog.fabrixly.com/how-to-use-analytics-and-license-management-apis/
- Published: 2026-07-07T14:10:44.000Z
- Updated: 2026-07-07T14:10:44.000Z
- Author: Fabrixly
- Tags: Documentation

This guide describes how to view dashboard metrics, audit logs, and manage system licenses in Fabrixly-IDS.

---

## 🔐 Authentication & Prerequisites

All analytics and license management endpoints require administrative authentication. To call them:

1. **Include the Token in the Authorization Header**: Add `-H "Authorization: Bearer <your-admin-jwt-token>"` to your API calls.

**Obtain an Admin JWT Token**:

```bash
curl -X POST https://ids.fabrixly.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "admin@example.com",
    "password": "your-admin-password"
  }'

```

*Note: This returns a JSON response containing a `token`.*

---

## Part A: Analytics & Audit Logs APIs

### 1\. Get Dashboard Statistics

Retrieves system-wide metrics (total organizations, users, active clients, and active sessions).

- **HTTP Method**: `GET`
- **Path**: `/api/analytics/stats`
- **Headers**:
  - `Authorization: Bearer <your-admin-jwt-token>`

#### Example Request (curl)

```bash
curl -X GET https://ids.fabrixly.com/api/analytics/stats \
  -H "Authorization: Bearer <your-admin-jwt-token>"

```

#### Response (`200 OK`)

```json
{
  "totalOrganizations": 12,
  "totalUsers": 1250,
  "totalClients": 8,
  "activeSessions": 45,
  "signupsHistory": [
    { "date": "07/01/2026", "count": 10 },
    { "date": "07/02/2026", "count": 15 }
  ],
  "roleDistribution": [
    { "name": "ORG_ADMIN", "value": 15 },
    { "name": "USER", "value": 1235 }
  ]
}

```

---

### 1b. Get Real-Time Live Users

Retrieves the count of currently active online users/sessions.

- **HTTP Method**: `GET`
- **Path**: `/api/analytics/live-users`
- **Headers**:
  - `Authorization: Bearer <your-admin-jwt-token>`

#### Example Request (curl)

```bash
curl -X GET https://ids.fabrixly.com/api/analytics/live-users \
  -H "Authorization: Bearer <your-admin-jwt-token>"

```

---

### 1c. Get User Activity History

Retrieves daily counts of auth events (successful logins, logouts, OTP verifications) over the last 30 days.

- **HTTP Method**: `GET`
- **Path**: `/api/analytics/activity`
- **Headers**:
  - `Authorization: Bearer <your-admin-jwt-token>`

#### Example Request (curl)

```bash
curl -X GET https://ids.fabrixly.com/api/analytics/activity \
  -H "Authorization: Bearer <your-admin-jwt-token>"

```

---

### 2\. View Audit Logs

Search and filter security/audit logs (e.g. successful logins, created clients, password changes).

- **HTTP Method**: `GET`
- **Path**: `/api/analytics/audit-logs`
- **Query Parameters**:
  - `page`: (integer) Page number (default: `1`).
  - `limit`: (integer) Logs per page (default: `20`).
  - `action`: (string) Filter by log action (e.g., `USER_LOGIN`, `CLIENT_CREATED`).
- **Headers**:
  - `Authorization: Bearer <your-admin-jwt-token>`

#### Example Request (curl)

```bash
curl -X GET "https://ids.fabrixly.com/api/analytics/audit-logs?page=1&limit=5&action=USER_LOGIN" \
  -H "Authorization: Bearer <your-admin-jwt-token>"

```

---

## Part B: License Management APIs

Administrators can install, inspect, and manually trigger validation checks on their self-hosted instance license.

### 1\. Retrieve License State & Usage

View the active license licensee details, limits (maximum organizations, MAUs), and verification validation status.

- **HTTP Method**: `GET`
- **Path**: `/api/system/license`
- **Headers**:
  - `Authorization: Bearer <your-admin-jwt-token>` (System Admin privileges required)

#### Example Request (curl)

```bash
curl -X GET https://ids.fabrixly.com/api/system/license \
  -H "Authorization: Bearer <your-admin-jwt-token>"

```

#### Response (`200 OK`)

```json
{
  "selfHosted": true,
  "hasLicense": true,
  "license": {
    "licensee": "Enterprise Customer LLC",
    "expiresAt": "2027-12-31T23:59:59Z",
    "limits": {
      "maxOrganizations": 100,
      "maxMaus": 10000
    },
    "features": {
      "magic_link_enabled": true,
      "mobile_auth_enabled": true,
      "passwordless_enabled": true
    }
  },
  "usage": {
    "maus": 1250,
    "organizations": 12
  },
  "validation": {
    "status": "valid",
    "errorMessage": null,
    "lastSuccessfulValidationAt": "2026-07-07T12:00:00Z",
    "instanceId": "inst_789abc123",
    "daysRemaining": 60
  }
}

```

---

### 2\. Install a License Key

Installs or replaces the cryptographic licensing activation key.

- **HTTP Method**: `POST`
- **Path**: `/api/system/license`
- **Headers**:
  - `Content-Type: application/json`
  - `Authorization: Bearer <your-admin-jwt-token>` (System Admin privileges required)

#### Example Request (curl)

```bash
curl -X POST https://ids.fabrixly.com/api/system/license \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your-admin-jwt-token>" \
  -d '{
    "licenseKey": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaWNlbnNlZSI6IkVudGVycHJpc2UgQ3VzdG9tZXIgTExDIiw..."
  }'

```

#### Response (`200 OK`)

```json
{
  "message": "License installed successfully",
  "licensee": "Enterprise Customer LLC"
}

```

---

### 3\. Force License Validation Check

Forces the instance to initiate a callback verification with the licensing backend authority.

- **HTTP Method**: `POST`
- **Path**: `/api/system/license/validate`
- **Headers**:
  - `Authorization: Bearer <your-admin-jwt-token>` (System Admin privileges required)

#### Example Request (curl)

```bash
curl -X POST https://ids.fabrixly.com/api/system/license/validate \
  -H "Authorization: Bearer <your-admin-jwt-token>"

```

#### Response (`200 OK`)

```json
{
  "message": "License validation check completed successfully",
  "status": "valid"
}

```