forgot-password
Method: POST
Path: /auth/forgot-password
Tags: Account recovery
Summary
Forgot password
Description
Initiates password recovery by sending an OTP. Returns an otp_token to pass to the reset-password endpoint. Asking again while the code is valid sends the same code (and otp_token); once it has expired or been used up, a new one.
Storefront SDK Usage
SDK Method: sdk.auth.forgotPassword()
Example:
// Send password reset OTP
const { data, error } = await sdk.auth.forgotPassword({
email: "customer@example.com"
});
if (error) {
console.error("Password reset failed:", error.message);
} else {
console.log("OTP token:", data.otp_token);
console.log("Action:", data.otp_action);
}TypeScript Definition
"forgot-password": {
parameters: {
query?: never;
header?: {
/** @description This param is used to enable debug mode. If debug mode is enabled, the API will return OTP as well. This is only for development and testing purposes. */
"x-debug-mode"?: components["parameters"]["DebugMode"];
};
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["SendOtpWithEmail"] | components["schemas"]["SendOtpWithPhone"];
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @description A descriptive message confirming the success or failure of the operation. */
message: string;
/** @description Indicates whether the request was successful or failure (true for success, false for failure). */
success: boolean;
content: components["schemas"]["OtpContent"] & {
/** @enum {string} */
otp_action?: "reset-password";
};
};
};
};
400: components["responses"]["AuthBadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
/** @description No account matches. Inactive accounts also return `user-inactive`; contact support. */
404: components["responses"]["NotFound"];
500: components["responses"]["InternalServerError"];
504: components["responses"]["GatewayTimeout"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["parameters"]["DebugMode"] | DebugMode |
components["schemas"]["SendOtpWithEmail"] | SendOtpWithEmail |
components["schemas"]["SendOtpWithPhone"] | SendOtpWithPhone |
components["schemas"]["OtpContent"] | OtpContent |
components["responses"]["AuthBadRequest"] | AuthBadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["Forbidden"] | Forbidden |
components["responses"]["NotFound"] | NotFound |
components["responses"]["InternalServerError"] | InternalServerError |
components["responses"]["GatewayTimeout"] | GatewayTimeout |
Parameters
- x-debug-mode (header): This param is used to enable debug mode. If debug mode is enabled, the API will return OTP as well. This is only for development and testing purposes.
Request Body
Content Types: application/json
Responses
200
OK
400
Bad request
401
Authentication failed. Codes include token-required, token-expired and token_not_valid for an invalid or expired token.
403
Access denied. token-required requires an authenticated session; permission-denied means the caller cannot access this resource. On POS, session-expired requires signing in again.
404
Requested resource not found
500
The request failed because of an unexpected error.
504
The request timed out.
OpenAPI Definition
{
"tags": [
"Account recovery"
],
"operationId": "forgot-password",
"summary": "Forgot password",
"description": "Initiates password recovery by sending an OTP. Returns an `otp_token` to pass to the reset-password endpoint. Asking again while the code is valid sends the same code (and `otp_token`); once it has expired or been used up, a new one.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/forgot-password",
"description": "API reference for the forgot-password operation"
},
"parameters": [
{
"$ref": "#/components/parameters/DebugMode"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/SendOtpWithEmail"
},
{
"$ref": "#/components/schemas/SendOtpWithPhone"
}
]
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"description": "A descriptive message confirming the success or failure of the operation.",
"type": "string"
},
"success": {
"description": "Indicates whether the request was successful or failure (true for success, false for failure).",
"type": "boolean"
},
"content": {
"allOf": [
{
"$ref": "#/components/schemas/OtpContent"
},
{
"type": "object",
"properties": {
"otp_action": {
"type": "string",
"enum": [
"reset-password"
]
}
}
}
]
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/AuthBadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"description": "No account matches. Inactive accounts also return `user-inactive`; contact support.",
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
},
"504": {
"$ref": "#/components/responses/GatewayTimeout"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": true,
"x-speakeasy-name-override": "forgotPassword"
}Auto-generated from OpenAPI spec and TypeScript definitions