Updates the authenticated user’s password. Requires the current password for verification.
Authentication
This endpoint requires both API key and JWT authentication.
Your API key for accessing the API
Bearer token in the format: Bearer <token>
Request Body
User’s current password for verification
New password to set. Must be different from the old password.
Response
Indicates if the request was successful
Response message indicating the result of the password update
Example Request
curl --request PATCH \
--url https://api.example.com/api/user/password \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' \
--header 'Content-Type: application/json' \
--header 'x-api-key: your_api_key_here' \
--data '{
"oldPassword": "currentPassword123",
"newPassword": "newSecurePassword456"
}'
Example Response
{
"success": true,
"message": "Password updated successfully"
}
Error Responses
{
"success": false,
"message": "New password cannot be the same as the old password"
}
Security Notes
- The old password is verified using bcrypt comparison before allowing the update
- The new password must be different from the old password
- The new password is hashed using bcrypt with a salt factor of 10 before storage
- Both
oldPassword and newPassword fields are required