Restore Password with OTP
The POST /v2/restorePasswordOTP endpoint enables users to securely reset their password using a One-Time Password (OTP) sent to their registered email address. The caller must supply the OTP code together with a new password and its confirmation to complete the reset. If the OTP is valid and all fields pass validation the endpoint removes the current password and replaces it with the new one.
Endpoint
POST /v2/restorePasswordOTP
Authentication
Bearer token required. Obtain via:
POST https://api.banking.netevia.dev/api/auth/v2
Include in header: Authorization: Bearer {token}
Token lifetime: 10 minutes. Refresh via POST /api/auth/refresh.
When to use
Use this endpoint as the second step in the two-step password recovery flow: after calling the forgot-password endpoint (which dispatches an OTP to the user's email), call this endpoint to validate the OTP and commit the new password. This is the appropriate endpoint whenever a user has lost access to their account password and needs to regain it through a verified, OTP-gated reset rather than a simple in-session change.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| nickName | string | Yes | The username (nickname) of the account whose password is being restored. Minimum length: 1. |
| code | string | Yes | The One-Time Password (OTP) received via the user's registered email. Minimum length: 1. |
| password | string | Yes | The new password to set for the account. Minimum length: 1. Use a strong password with sufficient length and complexity. |
| passwordConfirm | string | Yes | Exact repeat of the new password for confirmation. Must match password. Minimum length: 1. |
{
"nickName": "john.doe",
"code": "847291",
"password": "N3wS3cur3P@ssw0rd!",
"passwordConfirm": "N3wS3cur3P@ssw0rd!"
}Response
200 OK
| Field | Type | Description |
|---|---|---|
| restoreState | string (nullable) | Indicates the outcome state of the restore operation (e.g., "Success" or a descriptive state string). |
| errors | array of strings (nullable) | List of error messages if the operation failed. Empty or null on success. |
| success | string (nullable) | A human-readable success message when the password was reset successfully. null on failure. |
{
"restoreState": "Success",
"errors": null,
"success": "Password has been successfully restored."
}Example failure response (invalid OTP):
{
"restoreState": "Failed",
"errors": [
"The provided OTP code is invalid or has expired."
],
"success": null
}Error Codes
| Code | When it happens |
|---|---|
| 400 | Missing required fields (nickName, code, password, or passwordConfirm), password and passwordConfirm do not match, or field minimum-length constraint violated |
| 401 | Token missing, expired, or invalid |
| 403 | Insufficient permissions to perform a password restore for the given account |
| 404 | No account found matching the provided nickName |
| 500 | Internal server error |
Common Mistakes
- Sending
passwordandpasswordConfirmwith different values — both fields must be identical or the request will be rejected. - Using an expired or already-consumed OTP code — OTP codes are single-use and time-limited; request a new OTP via the forgot-password endpoint if the code has expired.
- Omitting
nickName— the request schema inheritsnickNameas a required field from the base forgot-password model; leaving it out will trigger a 400 validation error. - Submitting empty strings for any required field — all four fields enforce
minLength: 1.
Related Endpoints
POST /v2/forgotPassword— Initiates the password recovery flow by sending an OTP to the user's registered emailPOST /api/auth/v2— Authenticates a user and returns a Bearer token after a successful password restorePOST /api/auth/refresh— Refreshes an expiring Bearer token
Example
curl -X POST https://api.banking.netevia.dev/v2/restorePasswordOTP \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"nickName": "john.doe",
"code": "847291",
"password": "N3wS3cur3P@ssw0rd!",
"passwordConfirm": "N3wS3cur3P@ssw0rd!"
}'