Skip to main content
GET
/
api
/
user
/
data
Get User Data
curl --request GET \
  --url https://api.example.com/api/user/data
{
  "success": true,
  "user": {
    "_id": "user_2abc123def456",
    "name": "John Doe",
    "email": "john.doe@example.com",
    "imageUrl": "https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy...",
    "enrolledCourses": [
      "60d5ec49f1b2c72b8c8e4f1a",
      "60d5ec49f1b2c72b8c8e4f1b"
    ]
  }
}

Authentication

This endpoint requires authentication via Clerk. The userId is automatically extracted from the authentication token.

Response

success
boolean
required
Indicates whether the request was successful
user
object
User profile data
message
string
Error message if success is false

Response Examples

{
  "success": true,
  "user": {
    "_id": "user_2abc123def456",
    "name": "John Doe",
    "email": "john.doe@example.com",
    "imageUrl": "https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy...",
    "enrolledCourses": [
      "60d5ec49f1b2c72b8c8e4f1a",
      "60d5ec49f1b2c72b8c8e4f1b"
    ]
  }
}
{
  "success": false,
  "message": "User Not Found"
}
{
  "success": false,
  "message": "An unexpected error occurred"
}

Error Codes

Status CodeDescription
200Success or user not found (check success field)
401Unauthorized - Invalid or missing authentication token
500Internal server error