Zum Hauptinhalt springen

Reset Password Endpoint

Overview

This endpoint allows users to reset their password using a one-time password (OTP).

Request Details

HTTP Method

POST

Route

/[email]/reset-password

Headers

HeaderValueRequiredDescription
Content-Typeapplication/jsonYesIndicates JSON request body

Route Parameters

ParameterTypeRequiredDescription
emailstringYesThe email address of the user

Query Parameters

No query parameters required.

Request Body

FieldTypeRequiredDescription
otpstringYesOne-time password received via email
new_passwordstringYesNew password for the account

TypeScript Interface

interface ResetPasswordRequest {
otp: string
new_password: string
}

interface ResetPasswordResponse {
success: boolean
message: string
}

Python Model

from pydantic import BaseModel

class ResetPasswordRequest(BaseModel):
otp: str
new_password: str

class ResetPasswordResponse(BaseModel):
success: bool
message: str

Response Format

Success Response (200 OK)

{
"success": true,
"message": "Successfully validated OTP and reset password."
}

Error Responses

Invalid or Expired OTP

{
"success": false,
"message": "Invalid or expired OTP."
}

No OTP Found

{
"success": false,
"message": "No OTP found. Please request a new OTP."
}

Password Reset Failed

{
"success": false,
"message": "Something went wrong. Could not reset password. Please try again."
}

Code Examples

Python Example (using httpx)

import httpx
from pydantic import BaseModel
from typing import Optional

class ResetPasswordRequest(BaseModel):
otp: str
new_password: str

class ResetPasswordResponse(BaseModel):
success: bool
message: str

async def reset_password(email: str, otp: str, new_password: str) -> ResetPasswordResponse:
async with httpx.AsyncClient() as client:
response = await client.post(
f"https://neptun-webui.vercel.app/{email}/reset-password",
json={"otp": otp, "new_password": new_password}
)
response.raise_for_status()
return ResetPasswordResponse(**response.json())

cURL Example

curl -X POST https://neptun-webui.vercel.app/user@example.com/reset-password \
-H "Content-Type: application/json" \
-d '{"otp": "123456", "new_password": "newSecurePassword123"}'

TypeScript/JavaScript Example (using fetch)

async function resetPassword(
email: string,
otp: string,
newPassword: string
): Promise<ResetPasswordResponse> {
const response = await fetch(
`https://neptun-webui.vercel.app/${email}/reset-password`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
otp,
new_password: newPassword,
}),
}
)

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}

return await response.json() as ResetPasswordResponse
}