Skip to content

register-with-phone

Method: POST
Path: /auth/register/phone

Tags: Auth

Summary

Register with phone

Description

This API provides the functionality to register a user using their phone number. This allows you to securely register users and obtain access and refresh tokens for subsequent API calls.

Storefront SDK Usage

SDK Method: sdk.auth.registerWithPhone()

Example:

typescript
// Register a new user with phone number
const { data, error } = await sdk.auth.registerWithPhone({
  phone: "9876543210",
  country_code: "+91",
  first_name: "John",
  last_name: "Doe",
  email: "john.doe@example.com"
});

if (error) {
  console.error("Phone registration failed:", error.message);
} else {
  console.log("Registration successful:", data.user.first_name);
  console.log("User ID:", data.user.id);
  console.log("Access token:", data.access_token);
}

TypeScript Definition

typescript
"register-with-phone": {
        parameters: {
            query?: never;
            header?: never;
            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. */
                    phone: string;
                    /** @description A string representing the first name. */
                    first_name: string;
                    /** @description A string representing the last name. */
                    last_name?: string | null;
                    /** @description A string representing the email address. */
                    email?: string | null;
                };
            };
        };
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        /** @description A descriptive message confirming the success or failure of the Registration 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 An object representing user details. */
                            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"]["BadRequest"];
            401: components["responses"]["Unauthorized"];
        };
    };

Component References

ReferenceResolves To
components["schemas"]["User"]User
components["responses"]["BadRequest"]BadRequest
components["responses"]["Unauthorized"]Unauthorized

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": "register-with-phone",
  "summary": "Register with phone",
  "description": "This API provides the functionality to register a user using their phone number. This allows you to securely register users and obtain access and refresh tokens for subsequent API calls.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/register-with-phone",
    "description": "API reference for the register-with-phone operation"
  },
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "phone",
            "first_name"
          ],
          "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.",
              "type": [
                "string",
                "null"
              ],
              "const": "+91"
            },
            "phone": {
              "description": "10 digit phone number without country code.",
              "type": "string"
            },
            "first_name": {
              "description": "A string representing the first name.",
              "type": "string"
            },
            "last_name": {
              "description": "A string representing the last name.",
              "type": [
                "string",
                "null"
              ]
            },
            "email": {
              "description": "A string representing the email address.",
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      }
    }
  },
  "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 Registration 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": "An object representing user details.",
                    "$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"
              }
            }
          }
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/BadRequest"
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "auth",
  "x-speakeasy-ignore": true,
  "x-speakeasy-name-override": "registerWithPhone"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: