login-with-whatsapp
Method: POST
Path: /auth/login/whatsapp
Tags: Auth
Summary
Login with whatsapp
Description
This API enables users to authenticate into the system using their WhatsApp Number. It provides a secure way for users to Login by verifying their identity through a one-time password (OTP) sent to their WhatsApp Number.
Storefront SDK Usage
SDK Method: sdk.auth.loginWithWhatsApp()
Example:
typescript
// Login with WhatsApp number
const { data, error } = await sdk.auth.loginWithWhatsApp({
phone: "9876543210",
country_code: "+91",
register_if_not_exists: true
});
if (error) {
console.error("WhatsApp login failed:", error.message);
} else {
console.log("OTP sent to WhatsApp. Token:", data.otp_token);
console.log("Action:", data.otp_action); // "login" or "register"
}TypeScript Definition
typescript
"login-with-whatsapp": {
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": {
/**
* @description Two-letter code begin with a plus sign prefix that identifies different countries. By default it will be +91 if not provided.
* @constant
*/
country_code?: "+91";
/** @description 10 digit phone number without country code linked with WhatsApp. */
phone: 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"];
};
};
logout: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @description A descriptive message confirming the success or failure of the 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"]["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["schemas"]["User"] | User |
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
OpenAPI Definition
json
{
"tags": [
"Auth"
],
"operationId": "login-with-whatsapp",
"summary": "Login with whatsapp",
"description": "This API enables users to authenticate into the system using their WhatsApp Number. It provides a secure way for users to Login by verifying their identity through a one-time password (OTP) sent to their WhatsApp Number.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/login-with-whatsapp",
"description": "API reference for the login-with-whatsapp operation"
},
"parameters": [
{
"$ref": "#/components/parameters/DebugMode"
}
],
"requestBody": {
"description": "",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"phone"
],
"properties": {
"country_code": {
"description": "Two-letter code begin with a plus sign prefix that identifies different countries. By default it will be +91 if not provided.",
"const": "+91"
},
"phone": {
"description": "10 digit phone number without country code linked with WhatsApp.",
"type": "string"
},
"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"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "loginWithWhatsapp"
}Auto-generated from OpenAPI spec and TypeScript definitions