Skip to content

register-with-email ​

Method: POST
Path: /auth/register/email

Tags: Authentication

Summary ​

Register with email

Description ​

Sends a registration code. Call verify-otp with otp_action: register to create the user. Add another contact after signing in with update-user. Asking again while the code is valid sends the same code (and otp_token); once it has expired or been used up, a new one.

Storefront SDK Usage ​

SDK Method: sdk.auth.registerWithEmail()

Example:

typescript
// Register a new user with email address
const { data, error } = await sdk.auth.registerWithEmail({
  email: "jane.smith@example.com",
  first_name: "Jane",
  last_name: "Smith"
});

if (error) {
  console.error("Email registration failed:", error.message);
} else {
  console.log("OTP token:", data.otp_token);
  console.log("Action:", data.otp_action);
}

TypeScript Definition ​

typescript
"register-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 */
                    email: string;
                    first_name: string;
                    last_name?: string;
                };
            };
        };
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                        content: components["schemas"]["OtpContent"] & {
                            /** @enum {string} */
                            otp_action?: "register";
                        };
                    };
                };
            };
            400: components["responses"]["AuthBadRequest"];
            401: components["responses"]["Unauthorized"];
            403: components["responses"]["Forbidden"];
            500: components["responses"]["InternalServerError"];
            504: components["responses"]["GatewayTimeout"];
        };
    };

Component References ​

ReferenceResolves To
components["parameters"]["DebugMode"]DebugMode
components["schemas"]["OtpContent"]OtpContent
components["responses"]["AuthBadRequest"]AuthBadRequest
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["Forbidden"]Forbidden
components["responses"]["InternalServerError"]InternalServerError
components["responses"]["GatewayTimeout"]GatewayTimeout

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 ​

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.

500 ​

The request failed because of an unexpected error.

504 ​

The request timed out.

OpenAPI Definition ​

json
{
  "tags": [
    "Authentication"
  ],
  "operationId": "register-with-email",
  "summary": "Register with email",
  "description": "Sends a registration code. Call `verify-otp` with `otp_action: register` to create the user. Add another contact after signing in with `update-user`. Asking again while the code is valid sends the same code (and `otp_token`); once it has expired or been used up, a new one.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/register-with-email",
    "description": "API reference for the register-with-email operation"
  },
  "parameters": [
    {
      "$ref": "#/components/parameters/DebugMode"
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "email",
            "first_name"
          ],
          "properties": {
            "email": {
              "type": "string",
              "format": "email"
            },
            "first_name": {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            "last_name": {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/OtpContent"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "otp_action": {
                        "type": "string",
                        "enum": [
                          "register"
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/AuthBadRequest"
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "403": {
      "$ref": "#/components/responses/Forbidden"
    },
    "500": {
      "$ref": "#/components/responses/InternalServerError"
    },
    "504": {
      "$ref": "#/components/responses/GatewayTimeout"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "auth",
  "x-speakeasy-ignore": true,
  "x-speakeasy-name-override": "registerWithEmail"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: