verify-otp
Method: POST
Path: /auth/verify-otp
Tags: Auth
Summary
Verify OTP
Description
Verifies the OTP sent via phone, email, or WhatsApp. On success, returns a User object with access_token and refresh_token. Pass the otp_token and otp_action received from the login endpoint.
Storefront SDK Usage
SDK Method: sdk.auth.verifyOtp()
Example:
typescript
// Verify OTP after login attempt
const { data, error } = await sdk.auth.verifyOtp({
otp: "1234",
otpToken: "56895455",
otpAction: "login" // or "register"
});
if (error) {
console.error("OTP verification failed:", error.message);
// Show error message, allow retry
} else {
console.log("Login successful:", data.user.email);
console.log("User ID:", data.user.id);
}TypeScript Definition
typescript
"verify-otp": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": {
/** @description A string representing the one-time password. */
otp: string;
/** @description A string representing the OTP token. */
otp_token: string;
/**
* @description A string indicating the action to be performed.
* @enum {string}
*/
otp_action: "login" | "register" | "reset-password" | "verify-phone" | "verify-email" | "update-phone" | "update-email";
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @description A string providing additional information about the response. */
message: string;
/** @description A boolean indicating whether the operation was successful or not. */
success: boolean;
/** @description An object containing the response content. */
content: {
/** @description An object representing user details. */
user: components["schemas"]["User"];
/** @description A string representing the access token. */
access_token: string;
/** @description A string representing the refresh token. */
refresh_token: string;
};
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
404: components["responses"]["NotFound"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["User"] | User |
components["responses"]["BadRequest"] | BadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["NotFound"] | NotFound |
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": "verify-otp",
"summary": "Verify OTP",
"description": "Verifies the OTP sent via phone, email, or WhatsApp. On success, returns a `User` object with `access_token` and `refresh_token`. Pass the `otp_token` and `otp_action` received from the login endpoint.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/verify-otp",
"description": "API reference for the verify-otp operation"
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"otp",
"otp_token",
"otp_action"
],
"properties": {
"otp": {
"description": "A string representing the one-time password.",
"type": "string"
},
"otp_token": {
"description": "A string representing the OTP token.",
"type": "string"
},
"otp_action": {
"description": "A string indicating the action to be performed.",
"type": "string",
"enum": [
"login",
"register",
"reset-password",
"verify-phone",
"verify-email",
"update-phone",
"update-email"
]
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"description": "A string providing additional information about the response.",
"type": "string"
},
"success": {
"description": " A boolean indicating whether the operation was successful or not.",
"type": "boolean"
},
"content": {
"description": "An object containing the response content.",
"properties": {
"user": {
"description": "An object representing user details.",
"$ref": "#/components/schemas/User"
},
"access_token": {
"description": "A string representing the access token.",
"type": "string"
},
"refresh_token": {
"description": "A string representing the refresh token.",
"type": "string"
}
},
"required": [
"user",
"access_token",
"refresh_token"
],
"type": "object"
}
}
}
}
},
"links": {
"GetVerifiedUserCart": {
"operationId": "get-user-cart",
"parameters": {
"user_id": "$response.body#/content/user/user_id"
},
"description": "Retrieve the cart for the verified user."
},
"GetVerifiedCustomer": {
"operationId": "get-customer-detail",
"parameters": {
"id": "$response.body#/content/user/user_id"
},
"description": "Retrieve customer details for the verified user."
},
"CreateAddressForVerifiedUser": {
"operationId": "create-address",
"parameters": {
"user_id": "$response.body#/content/user/user_id"
},
"description": "Create a new address for the verified user."
},
"GetVerifiedUserLoyalty": {
"operationId": "get-loyalty-details",
"parameters": {
"user_id": "$response.body#/content/user/user_id"
},
"description": "Retrieve loyalty details for the verified user."
},
"GetVerifiedUserWishlist": {
"operationId": "get-wishlist",
"parameters": {
"user_id": "$response.body#/content/user/user_id"
},
"description": "Retrieve the wishlist for the verified user."
},
"ListSavedPaymentMethods": {
"operationId": "list-saved-payment-methods",
"parameters": {
"customer_id": "$response.body#/content/user/user_id"
},
"description": "List saved payment methods for the verified user."
},
"ListCustomerCards": {
"operationId": "list-customer-cards",
"parameters": {
"customer_id": "$response.body#/content/user/user_id"
},
"description": "List saved cards for the verified user."
},
"RefreshVerifiedToken": {
"operationId": "refresh-token",
"requestBody": {
"refresh_token": "$response.body#/content/refresh_token"
},
"description": "Refresh the access token using the refresh token."
}
}
},
"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": "verifyOtp"
}Auto-generated from OpenAPI spec and TypeScript definitions