Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/barcode8/VideoHub/llms.txt

Use this file to discover all available pages before exploring further.

These endpoints let authenticated users update their own account. Password changes verify the existing credential before persisting the new hash. Display name updates are sent as JSON, while avatar and cover image updates use multipart/form-data because Multer handles the file upload before passing control to the controller, which then pushes the file to Cloudinary and saves the returned URL to the user document.
Every endpoint on this page requires a valid access token. Requests without a token, or with an expired token, receive a 401 Unauthorized response. Obtain a fresh token via POST /api/v1/users/refresh-token if yours has expired.

Endpoints on this page

MethodPathAuth Required
POST/api/v1/users/change-passwordYes
PATCH/api/v1/users/change-detailsYes
PATCH/api/v1/users/change-avatarYes
PATCH/api/v1/users/change-coverimageYes

Change password

POST /api/v1/users/change-password Verifies the user’s current password against the stored bcrypt hash, then hashes and saves the new password. The validateBeforeSave: true option ensures Mongoose schema validators run on the updated document before it is persisted.

Request parameters

oldPassword
string
required
The user’s current plain-text password. Compared against the stored bcrypt hash via isPasswordCorrect().
newPassword
string
required
The desired new password in plain text. Hashed with bcrypt (10 rounds) via the pre("save") Mongoose hook before being stored.

Response fields

Returns HTTP 200.
data
object
An empty object {}. No user data is returned after a password change.
message
string
"Password Changed Successfully"

Error responses

StatusCondition
401oldPassword does not match the hash stored in the database.

Example

curl -X POST http://localhost:5000/api/v1/users/change-password \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{"oldPassword": "SuperSecret42", "newPassword": "NewSecret99!"}'
{
  "statusCode": 200,
  "data": {},
  "message": "Password Changed Successfully ",
  "success": true
}

Update display name

PATCH /api/v1/users/change-details Updates the fullName field on the authenticated user’s account. Uses findByIdAndUpdate with { new: true } so the response contains the document as it appears after the update. The password field is stripped from the returned document via .select("-password").
Only fullName is updated by this endpoint. The username and email fields are not modified here — the controller’s $set block contains only fullName.

Request parameters

fullName
string
required
The new display name to show on the channel profile and across the platform.

Response fields

Returns HTTP 200 with the updated user object (password omitted).
data
object
The updated user document.
message
string
"Account details updated successfully"

Example

curl -X PATCH http://localhost:5000/api/v1/users/change-details \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{"fullName": "Jane M. Doe"}'
{
  "statusCode": 200,
  "data": {
    "_id": "6650a1f2e4b0c3d9a1234567",
    "username": "janedoe",
    "email": "jane@example.com",
    "fullName": "Jane M. Doe",
    "avatar": "https://res.cloudinary.com/demo/image/upload/avatar.jpg",
    "coverImage": "https://res.cloudinary.com/demo/image/upload/cover.jpg",
    "updatedAt": "2024-05-25T09:00:00.000Z"
  },
  "message": "Account details updated successfully",
  "success": true
}

Change avatar

PATCH /api/v1/users/change-avatar Replaces the user’s avatar with a new image. The file is received by Multer (upload.single("avatar")), stored temporarily on disk, then uploaded to Cloudinary. The Cloudinary URL returned from the upload is saved to the user document, replacing the previous avatar URL.
The old avatar file on Cloudinary is not automatically deleted when you upload a new one. If storage cleanup matters for your deployment, implement a Cloudinary asset deletion step in the controller.

Request parameters

avatar
file
required
The image file to use as the new avatar. Sent as multipart/form-data with field name avatar. Supported formats depend on your Cloudinary plan (JPEG, PNG, WebP, and GIF are all accepted by default).

Response fields

Returns HTTP 200 with the updated user object (password omitted).
data
object
The updated user document.
message
string
"Avatar image updated successfully"

Error responses

StatusCondition
401No file was received (the avatar field is missing from the form).
401Cloudinary upload succeeded but returned no URL (upload error).

Example

curl -X PATCH http://localhost:5000/api/v1/users/change-avatar \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  --form "avatar=@/path/to/new_avatar.jpg"
{
  "statusCode": 200,
  "data": {
    "_id": "6650a1f2e4b0c3d9a1234567",
    "username": "janedoe",
    "fullName": "Jane M. Doe",
    "avatar": "https://res.cloudinary.com/demo/image/upload/v1716638400/new_avatar.jpg",
    "coverImage": "https://res.cloudinary.com/demo/image/upload/cover.jpg",
    "updatedAt": "2024-05-25T10:00:00.000Z"
  },
  "message": "Avatar image updated successfully",
  "success": true
}

Change cover image

PATCH /api/v1/users/change-coverimage Replaces the user’s channel cover image with a new one. The upload flow is identical to the avatar endpoint: Multer receives the file via upload.single("coverImage"), uploads it to Cloudinary, and persists the returned URL on the user document.
Cover images are displayed at the top of a user’s channel page. For best results, use a high-resolution landscape image (recommended: 2560 × 1440 px) in JPEG or PNG format.

Request parameters

coverImage
file
required
The image file for the new channel cover. Sent as multipart/form-data with field name coverImage.

Response fields

Returns HTTP 200 with the updated user object (password omitted).
data
object
The updated user document.
message
string
"Cover image updated successfully"

Error responses

StatusCondition
401No file was received (the coverImage field is missing from the form).
401Cloudinary upload succeeded but returned no URL (upload error).

Example

curl -X PATCH http://localhost:5000/api/v1/users/change-coverimage \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  --form "coverImage=@/path/to/new_cover.jpg"
{
  "statusCode": 200,
  "data": {
    "_id": "6650a1f2e4b0c3d9a1234567",
    "username": "janedoe",
    "fullName": "Jane M. Doe",
    "avatar": "https://res.cloudinary.com/demo/image/upload/avatar.jpg",
    "coverImage": "https://res.cloudinary.com/demo/image/upload/v1716642000/new_cover.jpg",
    "updatedAt": "2024-05-25T11:00:00.000Z"
  },
  "message": "Cover image updated successfully",
  "success": true
}

Build docs developers (and LLMs) love