Skip to content

Admin

Administrative endpoints for platform management. All admin routes require authentication and the admin role.

Base path: /api/admin

Authentication: Bearer token required + admin role

DANGER

These endpoints are restricted to admin users. Regular users will receive a 403 Forbidden response.

Dashboard

GET /api/admin/dashboard

Get the admin dashboard summary with platform-wide statistics.

Response

json
{
  "success": true,
  "data": {
    "totalUsers": 250,
    "activeUsers": 180,
    "totalScans": 4520,
    "totalDrifts": 12400,
    "totalRepositories": 890,
    "activeRunners": 15
  }
}

Example

bash
curl -H "Authorization: Bearer ADMIN_TOKEN" \
  https://api.controlinfra.com/api/admin/dashboard

List Users

GET /api/admin/users

List all platform users with their status and usage info.

Query Parameters

ParameterTypeRequiredDescription
pagenumberNoPage number
limitnumberNoItems per page
searchstringNoSearch by name or email

Response

json
{
  "success": true,
  "data": [
    {
      "_id": "user1",
      "email": "user@example.com",
      "name": "John Doe",
      "role": "user",
      "createdAt": "2025-01-15T00:00:00.000Z",
      "lastLoginAt": "2025-06-15T10:00:00.000Z",
      "repoConfigCount": 5,
      "scanCount": 45
    }
  ]
}

System Health

GET /api/admin/health

Get system health information (database, Redis, external services).

Response

json
{
  "success": true,
  "data": {
    "status": "healthy",
    "database": { "status": "connected", "latency": 5 },
    "redis": { "status": "connected", "latency": 2 },
    "uptime": 864000
  }
}

Scheduler Management

Get Scheduler Status

GET /api/admin/scheduler/status

Get the current status of the scan scheduler.

Response

json
{
  "success": true,
  "data": {
    "running": true,
    "nextRun": "2025-06-15T12:00:00.000Z",
    "pendingScans": 3,
    "scheduledRepos": 42
  }
}

Trigger Due Scans

POST /api/admin/scheduler/run

Manually trigger all due scheduled scans.

Example

bash
curl -X POST -H "Authorization: Bearer ADMIN_TOKEN" \
  https://api.controlinfra.com/api/admin/scheduler/run

Fix Missing Schedules

POST /api/admin/scheduler/fix

Detect and fix repository configs that should have scheduled scans but don't.

Analytics

Behavior Analytics

GET /api/admin/behavior-analytics

Get website behavior analytics data (page views, interactions, etc.).

GET /api/admin/navigation-analytics

Get sidebar navigation usage analytics.