Request Password Reset
Request Body
User’s email address. Must be a valid email format.
Response
Indicates whether the request was successful.
Status Codes
Request processed successfully.
Invalid email format.
Example Request
cURL
JavaScript
Example Response
Notes
- The reset token is valid for 1 hour (3600 seconds)
- An email with the reset link is sent asynchronously
- For security reasons, the response is always successful even if the email doesn’t exist
- The token is a 32-byte random hex string
Reset Password
Request Body
The reset token received via email.
The new password. Must be at least 6 characters long.
Response
Indicates whether the request was successful.
Status Codes
Password reset successful.
Invalid token, expired token, or validation error.
Error Response
Example Request
cURL
JavaScript
Python
Example Response
Notes
- The reset token expires 1 hour after generation
- Once a password is successfully reset, the token is cleared and cannot be reused
- The new password is securely hashed using bcrypt before storage
- Both
resetTokenandresetTokenExpiresfields are set to null after successful reset
Complete Password Reset Flow
- User requests password reset: Send POST request to
/api/auth/forgot-passwordwith email - System sends email: User receives email with reset token (valid for 1 hour)
- User clicks reset link: Frontend extracts token from URL
- User enters new password: Send POST request to
/api/auth/reset-passwordwith token and new password - Password updated: User can now log in with the new password
Security Considerations
- Reset tokens are cryptographically secure random strings
- Tokens expire after 1 hour
- Tokens are single-use (cleared after successful reset)
- The forgot-password endpoint doesn’t reveal whether an email exists in the system
- Password reset clears any existing reset tokens