Skip to content

verify-otp

Method: POST
Path: /auth/verify-otp

Tags: Auth

Summary

Verify OTP

Description

This API endpoint allows you to verify a one-time password (OTP) for authentication purposes. By sending a request to this endpoint with the necessary parameters, you can confirm the validity of the OTP provided by the user.

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

ReferenceResolves 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": "This API endpoint allows you to verify a one-time password (OTP) for authentication purposes. By sending a request to this endpoint with the necessary parameters, you can confirm the validity of the OTP provided by the user.",
  "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"
              }
            }
          }
        }
      }
    },
    "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

Last updated: