verify-forgot-username-otp
Method: POST
Path: /auth/forgot-username/verify-otp
Tags: Account recovery
Summary
Verify a forgotten account's sign-in code
Description
Verifies the one-time password POST /auth/forgot-username sent and signs the shopper in, as POST /auth/verify-otp does for a login: it returns the User with access_token and refresh_token, and the session's visitor data (cart, attribute values) moves to the account. When the customer has several active users (a business account), a call without user_id returns them in users instead, without signing in; call again with the same otp and otp_token and the chosen user's id as user_id. A wrong code, an expired one, the 5th wrong try (which uses the code up), and the token of a lookup that matched no account all get the same 400 (invalid-otp); after one, request a new code. Requires the access token the code was requested with.
Storefront SDK Usage
SDK Method: sdk.auth.verifyForgotUsernameOtp()
Example:
const { data, error } = await sdk.auth.verifyForgotUsernameOtp({
otp: "123456",
otp_token: "otp_token_from_forgot_username"
});
if (error) {
console.error("OTP verification failed:", error.message);
} else if ("users" in data) {
// Business account: let the shopper pick a user, then verify again
const chosen = data.users[0];
const { data: signedIn } = await sdk.auth.verifyForgotUsernameOtp({
otp: "123456",
otp_token: "otp_token_from_forgot_username",
user_id: chosen.id
});
} else {
console.log("Signed in as:", data.user.id);
}TypeScript Definition
"verify-forgot-username-otp": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": {
/** @description The code the shopper received. */
otp: string;
/** @description The `otp_token` of `POST /auth/forgot-username`. */
otp_token: string;
/** @description The user to sign in as, from `users`. Needed only when the business has several active users. */
user_id?: string;
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
message: string;
success: boolean;
/** @description Signed in: the `User` and its tokens. Several users to choose from: `users`. */
content: {
user: components["schemas"]["User"];
access_token: string;
refresh_token: string;
} | {
/** @description The business's active users, primary first. The code stays valid until it signs one in. */
users: components["schemas"]["ForgotUsernameUser"][];
};
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["User"] | User |
components["schemas"]["ForgotUsernameUser"] | ForgotUsernameUser |
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
{
"tags": [
"Account recovery"
],
"operationId": "verify-forgot-username-otp",
"summary": "Verify a forgotten account's sign-in code",
"description": "Verifies the one-time password `POST /auth/forgot-username` sent and signs the shopper in, as `POST /auth/verify-otp` does for a login: it returns the `User` with `access_token` and `refresh_token`, and the session's visitor data (cart, attribute values) moves to the account. When the customer has several active users (a business account), a call without `user_id` returns them in `users` instead, without signing in; call again with the same `otp` and `otp_token` and the chosen user's `id` as `user_id`. A wrong code, an expired one, the 5th wrong try (which uses the code up), and the token of a lookup that matched no account all get the same 400 (`invalid-otp`); after one, request a new code. Requires the access token the code was requested with.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/verify-forgot-username-otp",
"description": "API reference for the verify-forgot-username-otp operation"
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"otp",
"otp_token"
],
"properties": {
"otp": {
"description": "The code the shopper received.",
"type": "string"
},
"otp_token": {
"description": "The `otp_token` of `POST /auth/forgot-username`.",
"type": "string"
},
"user_id": {
"description": "The user to sign in as, from `users`. Needed only when the business has several active users.",
"type": "string"
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"type": "string"
},
"success": {
"type": "boolean"
},
"content": {
"description": "Signed in: the `User` and its tokens. Several users to choose from: `users`.",
"oneOf": [
{
"title": "Signed in",
"type": "object",
"properties": {
"user": {
"$ref": "#/components/schemas/User"
},
"access_token": {
"type": "string"
},
"refresh_token": {
"type": "string"
}
},
"required": [
"user",
"access_token",
"refresh_token"
]
},
{
"title": "Choose a user",
"type": "object",
"properties": {
"users": {
"description": "The business's active users, primary first. The code stays valid until it signs one in.",
"type": "array",
"items": {
"$ref": "#/components/schemas/ForgotUsernameUser"
}
}
},
"required": [
"users"
]
}
]
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": true,
"x-speakeasy-name-override": "verifyForgotUsernameOtp"
}Auto-generated from OpenAPI spec and TypeScript definitions