Skip to main content

Overview

Initiates the password reset flow by sending an OTP to the specified email address. Use the received OTP with the Reset Password endpoint.

Endpoint

POST /api/auth/forgot-password

Request

Headers

HeaderValue
Content-Typeapplication/json

Body parameters

email
string
required
The email address associated with the account to reset.

Response

Success

...data
object
Confirmation message returned by the server indicating the OTP was sent.

Error

error
string
Human-readable error message describing why the request failed.
After receiving the OTP by email, proceed to Reset Password to set a new password.

Example

TypeScript
import { SERVER_ENDPOINT } from "@env";

const API = SERVER_ENDPOINT ?? "";

const forgotPassword = async (email: string) => {
  const res = await fetch(`${API}/api/auth/forgot-password`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      email,
    }),
  });

  const data = await res.json();

  if (!res.ok) {
    throw new Error(data.error || "Forgot password request failed");
  }

  return data;
};