login-with-password
Method: POST
Path: /auth/login/password
Tags: Authentication
Summary
Login with password
Description
Authenticates a user with email/phone and password. Returns a User object with access_token and refresh_token.
Storefront SDK Usage
SDK Method: sdk.auth.loginWithPassword()
Example:
typescript
// Login with email and password
const { data, error } = await sdk.auth.loginWithPassword({
email: "customer@example.com",
password: "securePassword123"
});
if (error) {
console.error("Password login failed:", error.message);
} else {
console.log("Login successful:", data.user.email);
console.log("Access token:", data.access_token);
}TypeScript Definition
typescript
"login-with-password": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": {
/** @description Optional cart ID to help identify a failed cart transfer after sign-in. It does not select or change the cart being transferred. */
cart_id?: string;
} | {
/** @description User's phone number. */
phone: string;
country_code?: components["schemas"]["CountryCode"];
/** @description The password associated with the user's account. */
password: string;
} | {
/** Format: email */
email: string;
password: string;
};
};
};
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 Information about the user, including their name, email, profile image, etc. */
user: components["schemas"]["User"];
/** @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;
};
};
};
};
400: components["responses"]["AuthBadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
404: components["responses"]["NotFound"];
500: components["responses"]["InternalServerError"];
504: components["responses"]["GatewayTimeout"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["CountryCode"] | CountryCode |
components["schemas"]["User"] | User |
components["responses"]["AuthBadRequest"] | AuthBadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["Forbidden"] | Forbidden |
components["responses"]["NotFound"] | NotFound |
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.
404
Requested resource not found
500
The request failed because of an unexpected error.
504
The request timed out.
OpenAPI Definition
json
{
"tags": [
"Authentication"
],
"operationId": "login-with-password",
"summary": "Login with password",
"description": "Authenticates a user with email/phone and password. Returns a `User` object with `access_token` and `refresh_token`.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/login-with-password",
"description": "API reference for the login-with-password operation"
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"cart_id": {
"description": "Optional cart ID to help identify a failed cart transfer after sign-in. It does not select or change the cart being transferred.",
"type": "string"
}
},
"anyOf": [
{
"required": [
"phone",
"password"
],
"title": "phone",
"properties": {
"phone": {
"description": "User's phone number.",
"type": "string",
"pattern": "^\\d{10}$"
},
"country_code": {
"$ref": "#/components/schemas/CountryCode"
},
"password": {
"description": "The password associated with the user's account.",
"type": "string",
"minLength": 1,
"pattern": "\\S"
}
}
},
{
"required": [
"email",
"password"
],
"title": "email",
"properties": {
"email": {
"type": "string",
"format": "email"
},
"password": {
"type": "string",
"minLength": 1,
"pattern": "\\S"
}
}
}
]
}
}
}
},
"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": {
"user": {
"description": "Information about the user, including their name, email, profile image, etc.",
"$ref": "#/components/schemas/User"
},
"access_token": {
"description": "It is a string-based token utilized for authentication and authorization.",
"type": "string"
},
"refresh_token": {
"description": "It is a string-based token designed for refreshing the user's access token.",
"type": "string"
}
},
"required": [
"user",
"access_token",
"refresh_token"
],
"type": "object"
}
}
}
}
},
"links": {
"GetPasswordUserCart": {
"operationId": "get-user-cart",
"parameters": {
"user_id": "$response.body#/content/user/id"
},
"description": "Retrieve the cart for the logged-in user."
},
"RefreshPasswordToken": {
"operationId": "refresh-token",
"requestBody": {
"refresh_token": "$response.body#/content/refresh_token"
},
"description": "Refresh the access token using the refresh token."
}
}
},
"400": {
"$ref": "#/components/responses/AuthBadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
},
"504": {
"$ref": "#/components/responses/GatewayTimeout"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": true,
"x-speakeasy-name-override": "loginWithPassword"
}Auto-generated from OpenAPI spec and TypeScript definitions