Endpoint: PATCH /users/update
Description: Update current user's profile information.
Headers:
-
Content-Type: application/json
-
Authorization: Bearer <token>
(optional if using cookies)
Cookies:
accessToken
(required if not using Authorization header)
Request Body:
{
"username": "string (optional, 3-30 chars, alphanumeric + underscore)",
"name": "string (optional, 2-50 chars)",
"email": "string (optional, valid email)",
"avatar": "string (optional, valid URL)"
}
Success Response (200):
{
"success": true,
"data": {
"_id": "507f1f77bcf86cd799439011",
"username": "johndoe_updated",
"name": "John Doe Updated",
"email": "john.updated@example.com",
"avatar": "https://example.com/avatar.jpg",
"createdAt": "2023-01-01T00:00:00.000Z",
"updatedAt": "2023-01-01T12:00:00.000Z"
}
}
Error Responses:
401 Unauthorized:
{
"success": false,
"message": "You are not logged in. Please log in to get access."
}
404 Not Found:
{
"success": false,
"message": "User not found"
}
422 Validation Error:
{
"success": false,
"message": "Validation failed",
"errors": {
"username": "Username must be between 3 and 30 characters",
"avatar": "Avatar must be a valid URL"
}
}