Skip to main content
The password reset functionality is split into two endpoints: one to request a reset token and another to actually reset the password.

Request Password Reset

Initiates the password reset process by sending a reset token to the user’s email address.

Request Body

string
required
User’s email address. Must be a valid email format.

Response

boolean
Indicates whether the request was successful.
object

Status Codes

Success
Request processed successfully.
Bad Request
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

Completes the password reset process using the token received via email.

Request Body

string
required
The reset token received via email.
string
required
The new password. Must be at least 6 characters long.

Response

boolean
Indicates whether the request was successful.
object

Status Codes

Success
Password reset successful.
Bad Request
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 resetToken and resetTokenExpires fields are set to null after successful reset

Complete Password Reset Flow

  1. User requests password reset: Send POST request to /api/auth/forgot-password with email
  2. System sends email: User receives email with reset token (valid for 1 hour)
  3. User clicks reset link: Frontend extracts token from URL
  4. User enters new password: Send POST request to /api/auth/reset-password with token and new password
  5. 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