Skip to content

reset-password ​

Method: POST
Path: /auth/reset-password

Tags: Account recovery

Summary ​

Reset password

Description ​

Resets the user's password using the otp_token from the forgot-password endpoint. Returns new access_token and refresh_token. A code is valid for a limited time after it is sent, and is used up after 5 wrong tries; then request a new one. A 400's code says why: invalid-otp (a wrong, unknown or used code), otp-expired or otp-attempts-exceeded (the 5th wrong try).

Storefront SDK Usage ​

SDK Method: sdk.auth.resetPassword()

Example:

typescript
// Reset password with the OTP and OTP token from the forgot password flow
const { data, error } = await sdk.auth.resetPassword({
  new_password: "newSecurePassword123",
  confirm_password: "newSecurePassword123",
  otp_token: "abc123otptoken",
  otp: "1234"
});

if (error) {
  console.error("Password reset failed:", error.message);
} else {
  console.log("Password reset successful");
  console.log("New access token:", data.access_token);
}

TypeScript Definition ​

typescript
"reset-password": {
        parameters: {
            query?: never;
            header?: never;
            path?: never;
            cookie?: never;
        };
        requestBody: {
            content: {
                "application/json": {
                    /** @description The new password that the user wants to set for their account. */
                    new_password: string;
                    /** @description A confirmation of the new password. */
                    confirm_password: string;
                    /** @description A string representing the OTP token which facilitas the resetting of user’s account password. */
                    otp_token: string;
                    /** @description A string representing the one-time password. */
                    otp: string;
                };
            };
        };
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        /** @description A descriptive message confirming the success or failure of the reset password operation. */
                        message: string;
                        /** @description Indicates whether the request was successful or failure (true for success, false for failure). */
                        success: boolean;
                        /** @description An object containing the response content. */
                        content: {
                            /** @description It is a string-based token utilized for authentication and authorization. */
                            access_token: string;
                            /** @description It is a string-based token designed for refreshing the user's access token. */
                            refresh_token: string;
                            /** @description An object representing user details. */
                            user: components["schemas"]["User"];
                        };
                    };
                };
            };
            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 ​

ReferenceResolves To
components["schemas"]["User"]User
components["responses"]["AuthBadRequest"]AuthBadRequest
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["Forbidden"]Forbidden
components["responses"]["NotFound"]NotFound
components["responses"]["InternalServerError"]InternalServerError
components["responses"]["GatewayTimeout"]GatewayTimeout

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 ​

json
{
  "tags": [
    "Account recovery"
  ],
  "operationId": "reset-password",
  "summary": "Reset password",
  "description": "Resets the user's password using the `otp_token` from the forgot-password endpoint. Returns new `access_token` and `refresh_token`. A code is valid for a limited time after it is sent, and is used up after 5 wrong tries; then request a new one. A 400's `code` says why: `invalid-otp` (a wrong, unknown or used code), `otp-expired` or `otp-attempts-exceeded` (the 5th wrong try).",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/reset-password",
    "description": "API reference for the reset-password operation"
  },
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "new_password",
            "confirm_password",
            "otp_token",
            "otp"
          ],
          "properties": {
            "new_password": {
              "description": "The new password that the user wants to set for their account.",
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            "confirm_password": {
              "description": "A confirmation of the new password.",
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            "otp_token": {
              "description": "A string representing the OTP token which facilitas the resetting of user’s account password.",
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            "otp": {
              "description": "A string representing the one-time password.",
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            }
          }
        }
      }
    }
  },
  "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 reset password operation.",
                "type": "string"
              },
              "success": {
                "description": "Indicates whether the request was successful or failure (true for success, false for failure).",
                "type": "boolean"
              },
              "content": {
                "description": "An object containing the response content.",
                "properties": {
                  "access_token": {
                    "description": "It is a string-based token utilized for authentication and authorization.",
                    "type": "string"
                  },
                  "refresh_token": {
                    "description": "It is a string-based token designed for refreshing the user's access token.",
                    "type": "string"
                  },
                  "user": {
                    "description": "An object representing user details.",
                    "$ref": "#/components/schemas/User"
                  }
                },
                "required": [
                  "access_token",
                  "refresh_token",
                  "user"
                ],
                "type": "object"
              }
            }
          }
        }
      }
    },
    "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": "resetPassword"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: