Skip to main content

Get Profile

Retrieves the authenticated user’s profile. Automatically creates a profile if one doesn’t exist.

Response

profile
object
User profile object

Example Request

curl https://your-domain.com/api/profile

Example Response

{
  "profile": {
    "id": "uuid-here",
    "email": "user@example.com",
    "name": "John Doe",
    "user_type": "user",
    "bio": "Aspiring developer",
    "profile_image": "https://example.com/avatar.jpg",
    "currency": "USD",
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}

Update Profile

Updates the authenticated user’s profile information.

Request Body

name
string
User display name
bio
string
User biography/description
profile_image
string
Profile image URL
currency
string
Preferred currency (ISO 4217 code)

Response

profile
object
Updated profile object

Example Request

curl -X PUT https://your-domain.com/api/profile \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jane Doe",
    "bio": "Full-stack developer",
    "currency": "EUR"
  }'

Delete Account

Deletes the authenticated user’s account and all associated data.

Response

message
string
Success confirmation message

Example Request

curl -X DELETE https://your-domain.com/api/profile

Notes

This action is irreversible. It deletes:
  • User authentication account
  • Profile data
  • All enrollments
  • All progress records
  • All quiz results

List Learners (Admin/Instructor)

Retrieves a list of all learners (users with user_type = “user”). Requires admin or instructor authentication.

Query Parameters

Search by name or email
enrollmentFilter
string
Filter by enrollment status: “all”, “enrolled”, “not-enrolled”

Response

learners
array
Array of learner objects

Example Request

curl https://your-domain.com/api/learners?search=john&enrollmentFilter=enrolled

Example Response

{
  "learners": [
    {
      "id": "uuid-1",
      "name": "John Doe",
      "email": "john@example.com",
      "profileImage": "https://example.com/john.jpg",
      "enrolledCourses": [1, 2, 5],
      "completedCourses": [1],
      "progress": {
        "1": 100,
        "2": 45,
        "5": 10
      }
    }
  ]
}

Get Learner Purchases (Admin/Instructor)

Retrieves all purchases (payments) for a specific learner. Requires admin or instructor authentication.

Path Parameters

id
string
required
Learner UUID

Response

purchases
array
Array of purchase objects

Example Request

curl https://your-domain.com/api/learners/uuid-here/purchases

User Types

The platform supports three user types:
User TypeDescriptionPermissions
userRegular learnerEnroll in courses, view content, submit quizzes
instructorCourse creatorAll learner permissions + create courses
adminPlatform administratorFull access to all features and data

Profile Auto-Creation

When a new user signs up, the GET /api/profile endpoint automatically:
  1. Checks if a profile exists
  2. If not, creates one with:
    • user_type: “user” (default)
    • name: Derived from email or user metadata
    • currency: “USD” (default)
  3. Returns the profile
This ensures every authenticated user always has a valid profile.

Error Codes

Status CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Authentication required
403Forbidden - Insufficient permissions
404Not Found - Profile or user not found
500Internal Server Error