Skip to main content

Get All Users

Retrieve all users with enrollment statistics, educator status, and course creation counts.

Authentication

Authorization
string
required
Bearer token with admin role required

Response

success
boolean
Indicates if the request was successful
users
array
Array of users sorted by registration date (newest first)
{
  "success": true,
  "users": [
    {
      "_id": "user_2abc123def456",
      "name": "John Smith",
      "email": "[email protected]",
      "imageUrl": "https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ18yYWJjMTIzZGVmNDU2In0",
      "enrolledCount": 5,
      "coursesCreated": 3,
      "isEducator": true,
      "createdAt": "2024-01-15T08:30:00.000Z"
    },
    {
      "_id": "user_3xyz789ghi012",
      "name": "Sarah Johnson",
      "email": "[email protected]",
      "imageUrl": "https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ18zeHl6Nzg5Z2hpMDEyIn0",
      "enrolledCount": 12,
      "coursesCreated": 0,
      "isEducator": false,
      "createdAt": "2024-01-14T14:20:00.000Z"
    },
    {
      "_id": "user_4mno345pqr678",
      "name": "Michael Chen",
      "email": "[email protected]",
      "imageUrl": "https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ180bW5vMzQ1cHFyNjc4In0",
      "enrolledCount": 3,
      "coursesCreated": 7,
      "isEducator": true,
      "createdAt": "2024-01-13T11:45:00.000Z"
    },
    {
      "_id": "user_5stu901vwx234",
      "name": "Emily Davis",
      "email": "[email protected]",
      "imageUrl": "https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ181c3R1OTAxdnd4MjM0In0",
      "enrolledCount": 8,
      "coursesCreated": 0,
      "isEducator": false,
      "createdAt": "2024-01-12T16:10:00.000Z"
    }
  ]
}

Notes

  • Users are sorted by registration date in descending order (newest first)
  • The isEducator field is fetched from Clerk’s public metadata
  • Regular students will have isEducator: false and coursesCreated: 0
  • The endpoint queries up to 500 users from Clerk for role metadata
  • enrolledCount represents active enrollments in courses
  • coursesCreated counts all courses created by the educator, regardless of publication status

Build docs developers (and LLMs) love