Skip to content

forgot-username ​

Method: POST
Path: /auth/forgot-username

Tags: Account recovery

Summary ​

Send a sign-in code to a forgotten account

Description ​

Starts recovering an account by its KYC document numbers: pass 1 to 5 filters, each a linked attribute from GET /auth/attributes?kind=linked and the customer's document number for it. A customer matches when it has every value. When exactly one customer matches, a one-time password goes by SMS to the sign-in phone of its primary user, or to their sign-in email when they have no phone; when the primary user is inactive or has neither, to the customer's earliest active user that has one. No match, several matches and a matched customer with no such user get the same response, which never shows the customer or its contact: pass its otp_token, with the code the shopper received, to POST /auth/forgot-username/verify-otp. Each request makes the session's earlier codes from this endpoint unusable. This replaces the earlier response, which returned the matched business and its users. Requires an anonymous access token.

Storefront SDK Usage ​

SDK Method: sdk.auth.forgotUsername()

Example:

typescript
const { data, error } = await sdk.auth.forgotUsername({
  filters: [
    { attribute_id: "01H9ATTRGSTIN12345", value: "27AAPFU0939F1ZV" }
  ]
});

if (error) {
  console.error("Account lookup failed:", error.message);
} else {
  // Same response whether or not an account matched
  console.log("OTP token:", data.otp_token);
  console.log("Action:", data.otp_action); // "forgot-username"
}

TypeScript Definition ​

typescript
"forgot-username": {
        parameters: {
            query?: never;
            header?: never;
            path?: never;
            cookie?: never;
        };
        requestBody: {
            content: {
                "application/json": components["schemas"]["ForgotUsernameWithFilters"] | components["schemas"]["ForgotUsernameWithAttribute"];
            };
        };
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        /** @example If an account matches, a one-time password has been sent to its registered contact. */
                        message: string;
                        success: boolean;
                        /** @description `otp_action` is `forgot-username`. The code itself is never returned, not even in debug mode. When no customer matches, the `otp_token` is one no code verifies. */
                        content: components["schemas"]["OtpContent"];
                    };
                };
            };
            400: components["responses"]["BadRequest"];
            401: components["responses"]["Unauthorized"];
        };
    };

Component References ​

ReferenceResolves To
components["schemas"]["ForgotUsernameWithFilters"]ForgotUsernameWithFilters
components["schemas"]["ForgotUsernameWithAttribute"]ForgotUsernameWithAttribute
components["schemas"]["OtpContent"]OtpContent
components["responses"]["BadRequest"]BadRequest
components["responses"]["Unauthorized"]Unauthorized

Request Body ​

Content Types: application/json

Responses ​

200 ​

OK

400 ​

Bad request

401 ​

Not authorized for given operation on the Resource

OpenAPI Definition ​

json
{
  "tags": [
    "Account recovery"
  ],
  "operationId": "forgot-username",
  "summary": "Send a sign-in code to a forgotten account",
  "description": "Starts recovering an account by its KYC document numbers: pass 1 to 5 `filters`, each a `linked` attribute from `GET /auth/attributes?kind=linked` and the customer's document number for it. A customer matches when it has every value. When exactly one customer matches, a one-time password goes by SMS to the sign-in phone of its primary user, or to their sign-in email when they have no phone; when the primary user is inactive or has neither, to the customer's earliest active user that has one. No match, several matches and a matched customer with no such user get the same response, which never shows the customer or its contact: pass its `otp_token`, with the code the shopper received, to `POST /auth/forgot-username/verify-otp`. Each request makes the session's earlier codes from this endpoint unusable. This replaces the earlier response, which returned the matched business and its users. Requires an anonymous access token.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/forgot-username",
    "description": "API reference for the forgot-username operation"
  },
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "oneOf": [
            {
              "$ref": "#/components/schemas/ForgotUsernameWithFilters"
            },
            {
              "$ref": "#/components/schemas/ForgotUsernameWithAttribute"
            }
          ]
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string",
                "examples": [
                  "If an account matches, a one-time password has been sent to its registered contact."
                ]
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "$ref": "#/components/schemas/OtpContent",
                "description": "`otp_action` is `forgot-username`. The code itself is never returned, not even in debug mode. When no customer matches, the `otp_token` is one no code verifies."
              }
            }
          }
        }
      },
      "links": {
        "VerifyForgotUsernameOtp": {
          "operationId": "verify-forgot-username-otp",
          "requestBody": {
            "otp_token": "$response.body#/content/otp_token"
          },
          "description": "Verify the code and sign in."
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/BadRequest"
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "auth",
  "x-speakeasy-ignore": true,
  "x-speakeasy-name-override": "forgotUsername"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: