All user state in the LMS Backend revolves around a singleDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Pragyat-Nikunj/Learning-Management-System-backend/llms.txt
Use this file to discover all available pages before exploring further.
User document. Authentication is cookie-based: on a successful sign-in or sign-up the server sets an HTTP-only token cookie containing a signed JWT. Protected endpoints verify this cookie via the isAuthenticated middleware — you do not need to pass Authorization headers manually if your HTTP client forwards cookies.
All endpoints are prefixed with
/api/v1/user. The base URL for local development is http://localhost:4000.POST /api/v1/user/signup
Create a new user account. ThevalidateSignUp middleware runs before the controller and rejects requests that fail field validation.
Auth required: No
Request body
Display name. Maximum 50 characters.
Valid email address. Stored in lowercase. Must be unique across all accounts.
Account password. Minimum 8 characters. Stored as a bcrypt hash.
Account role. Accepted values:
student, instructor, admin. Defaults to student.Response
true on successful account creation.Human-readable confirmation message.
The newly created user object. Does not include
password.The signed JWT. Also delivered as the
token HTTP-only cookie. You do not need to store this manually if your client handles cookies automatically.Errors
| Status | Condition |
|---|---|
400 | Validation failed (missing or malformed fields) |
400 | A user with that email already exists |
POST /api/v1/user/signin
Authenticate an existing user. On success, sets an HTTP-onlytoken cookie that must be included in all subsequent protected requests.
Auth required: No
Request body
Registered email address.
Account password in plain text. Compared against the stored bcrypt hash.
Response
true on successful authentication.Welcome message including the user’s name.
The authenticated user object (same shape as signup response — does not include
password).The signed JWT. Also delivered as the
token HTTP-only cookie.Use
--cookie-jar cookies.txt with cURL to persist the token cookie. Subsequent requests can then use --cookie cookies.txt to send it automatically.Errors
| Status | Condition |
|---|---|
401 | Invalid email or password |
POST /api/v1/user/signout
Clear thetoken cookie to end the current session.
Auth required: No (cookie is cleared regardless of its validity)
Response
GET /api/v1/user/profile
Retrieve the authenticated user’s full profile. TheenrolledCourses array is populated with title, thumbnail, and description from each linked course.
Auth required: Yes
Response
true on success.The user document with enrolled courses populated and the virtual
totalEnrolledCourses count appended.Errors
| Status | Condition |
|---|---|
401 | Missing or invalid auth cookie |
404 | Authenticated user not found in database |
PATCH /api/v1/user/profile
Update the authenticated user’s profile. Send asmultipart/form-data if you are uploading a new avatar image; otherwise application/json is accepted for text-only fields.
Auth required: Yes
Request — multipart/form-data
Updated display name.
Updated email address. Stored lowercase.
Biography text. Maximum 200 characters.
New avatar image file. When provided, the old avatar is deleted from Cloudinary and replaced with the newly uploaded image. The field name must be
avatar.Response
true on success."Profile updated successfully."The updated user document.
Errors
| Status | Condition |
|---|---|
401 | Missing or invalid auth cookie |
404 | Authenticated user not found |
PATCH /api/v1/user/password
Change the password for the authenticated account. Auth required: YesRequest body
The replacement password. Minimum 8 characters. Saved as a new bcrypt hash.
Response
Errors
| Status | Condition |
|---|---|
400 | newPassword is missing from the request body |
401 | Missing or invalid auth cookie |
404 | User not found |
POST /api/v1/user/forgot-password
Generate a short-lived password reset token for the given email address. In the current implementation the raw token is returned directly in the response body — in production you would email it to the user instead. Auth required: NoRequest body
The email address associated with the account that needs a password reset.
Response
true when a token is generated."Password reset token generated successfully"Errors
| Status | Condition |
|---|---|
400 | Email field is missing |
404 | No account found for that email |
POST /api/v1/user/reset-password/:token
Reset the account password using a valid token obtained from the forgot-password endpoint. The token is valid for 10 minutes from the time it was generated. Auth required: NoPath parameters
The raw reset token returned by
POST /api/v1/user/forgot-password.Request body
The new password. Minimum 8 characters.
Response
Errors
| Status | Condition |
|---|---|
400 | Token is missing from path |
400 | newPassword is missing |
400 | Token is invalid or has expired (older than 10 minutes) |
DELETE /api/v1/user/account
Permanently delete the authenticated user’s account. If the user has a custom avatar stored in Cloudinary, it is also deleted. The operation is irreversible. Auth required: YesResponse
true on successful deletion."User account deleted successfully"The deleted user document as it existed before removal.
Errors
| Status | Condition |
|---|---|
401 | Missing or invalid auth cookie |
404 | User not found |