Skip to main content
POST
Change Password

Endpoint

Overview

Changes the authenticated user’s password. Requires the current password for verification. Password is hashed with bcrypt before storage.

Request

string
required
Current password for verification
string
required
New password. Minimum 8 characters.

Response

boolean
Always true on success
string
“Password changed successfully”

Implementation Details

Process Flow

  1. Authentication: Verifies user is authenticated
  2. Current Password Check: Compares provided password with stored hash
  3. Password Hashing: Hashes new password with bcrypt (10 rounds)
  4. Update: Updates password hash in database
  5. Audit Logging: Logs PASSWORD_CHANGE event

Code Reference

Status Codes

OK
Password changed successfully
Bad Request
Validation error (new password too short, etc.)
Unauthorized
Invalid current password or missing authentication
Not Found
User not found
Forbidden
Blocked by Arcjet

Example Request

Example Response

Security Considerations

  • Current password must be verified before change
  • New password is hashed with bcrypt (10 rounds)
  • Rate limiting applied (2 requests per bucket)
  • All password changes are logged in audit trail
  • Old password hash is completely replaced (no history kept)

Audit Events

  • PASSWORD_CHANGE: Password successfully changed

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
currentPassword
string
required
newPassword
string
required
Minimum string length: 8
verificationCode
string

Required if 2FA is enabled

Response

200

Password changed successfully