login-with-email
Method: POST
Path: /auth/login/email
Tags: Auth
Summary
Login with email
Description
This API enables users to authenticate into the system using their email address. It provides a secure way for users to Login by verifying their identity through a one-time password (OTP) sent to their email address.
Storefront SDK Usage
SDK Method: sdk.auth.loginWithEmail()
Example:
typescript
// Login with email address
const { data, error } = await sdk.auth.loginWithEmail({
email: "customer@example.com",
registerIfNotExists: true
});
if (error) {
console.error("Email login failed:", error.message);
} else {
console.log("OTP sent to email. Token:", data.otpToken);
console.log("Action:", data.action); // "login" or "register"
// Show OTP input form
}TypeScript Definition
typescript
"login-with-email": {
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": {
/**
* Format: email
* @description User's email address.
*/
email: string;
/**
* @description This is used to send OTP to unregistered phone. By default it sends OTP to registered phone only.
* To send OTP to unregistered phone it should be pass with true value like this,
* "register_if_not_exists": true
*/
register_if_not_exists?: boolean;
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @description A descriptive message confirming the success or failure of the Login process. */
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 The otp token is a unique code that is used for authentication during the Login process. */
otp_token: string;
/** @description It is used for verifying OTP and using subsequent API call. */
otp_action: string;
};
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
404: components["responses"]["NotFound"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["parameters"]["DebugMode"] | DebugMode |
components["responses"]["BadRequest"] | BadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["NotFound"] | NotFound |
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
Not authorized for given operation on the Resource
404
Requested resource not found
OpenAPI Definition
json
{
"tags": [
"Auth"
],
"operationId": "login-with-email",
"summary": "Login with email",
"description": "This API enables users to authenticate into the system using their email address. It provides a secure way for users to Login by verifying their identity through a one-time password (OTP) sent to their email address.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/login-with-email",
"description": "API reference for the login-with-email operation"
},
"parameters": [
{
"$ref": "#/components/parameters/DebugMode"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"email"
],
"properties": {
"email": {
"description": "User's email address.",
"type": "string",
"format": "email"
},
"register_if_not_exists": {
"description": "This is used to send OTP to unregistered phone. By default it sends OTP to registered phone only. \nTo send OTP to unregistered phone it should be pass with true value like this,\n\"register_if_not_exists\": true",
"type": "boolean"
}
}
}
}
}
},
"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 Login process.",
"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": {
"otp_token": {
"description": "The otp token is a unique code that is used for authentication during the Login process.",
"type": "string"
},
"otp_action": {
"description": "It is used for verifying OTP and using subsequent API call.",
"type": "string"
}
},
"required": [
"otp_token",
"otp_action"
],
"type": "object"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/NotFound"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "loginWithEmail"
}Auto-generated from OpenAPI spec and TypeScript definitions