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. Requires an anonymous or logged-out access token. The code is never returned, even in debug mode.
Storefront SDK Usage
SDK Method: sdk.auth.forgotUsername()
Example:
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
"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;
content: components["schemas"]["OtpContent"] & {
/** @enum {string} */
otp_action?: "forgot-username";
};
};
};
};
400: components["responses"]["AuthBadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
500: components["responses"]["InternalServerError"];
504: components["responses"]["GatewayTimeout"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["ForgotUsernameWithFilters"] | ForgotUsernameWithFilters |
components["schemas"]["ForgotUsernameWithAttribute"] | ForgotUsernameWithAttribute |
components["schemas"]["OtpContent"] | OtpContent |
components["responses"]["AuthBadRequest"] | AuthBadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["Forbidden"] | Forbidden |
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.
500
The request failed because of an unexpected error.
504
The request timed out.
OpenAPI Definition
{
"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. Requires an anonymous or logged-out access token. The code is never returned, even in debug mode.",
"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": {
"anyOf": [
{
"$ref": "#/components/schemas/ForgotUsernameWithFilters"
},
{
"$ref": "#/components/schemas/ForgotUsernameWithAttribute"
}
],
"not": {
"anyOf": [
{
"required": [
"filters",
"attribute_id"
]
},
{
"required": [
"filters",
"attribute_value"
]
}
]
}
}
}
}
},
"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": {
"allOf": [
{
"$ref": "#/components/schemas/OtpContent"
},
{
"type": "object",
"properties": {
"otp_action": {
"type": "string",
"enum": [
"forgot-username"
]
}
}
}
]
}
}
}
}
},
"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/AuthBadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
},
"504": {
"$ref": "#/components/responses/GatewayTimeout"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": true,
"x-speakeasy-name-override": "forgotUsername"
}Auto-generated from OpenAPI spec and TypeScript definitions