Users
Authentication, profile, phone, password, and merge operations.
Methods
Login
Use: users.login(input, options?).
| Field | Type | Required | Description |
|---|---|---|---|
input.email | string | Required | Login email. |
input.password | string | Required | Login password. |
Returns: SazitoResponse<{ jwt: string; user?: User }>.
Request Mobile OTP
Use: users.requestMobileOTP(input, options?).
| Field | Type | Required | Description |
|---|---|---|---|
input.mobilePhone | string | Required | Mobile number for OTP request. |
Verify Mobile OTP
Use: users.verifyMobileOTP(input, options?).
| Field | Type | Required | Description |
|---|---|---|---|
input.mobilePhone | string | Required | Mobile number. |
input.token | string | Required | OTP token. |
Request Email Login
Use: users.requestEmailLogin(input, options?).
| Field | Type | Required | Description |
|---|---|---|---|
input.email | string | Required | Email for passwordless login request. |
Register
Use: users.register(input, options?).
| Field | Type | Required | Description |
|---|---|---|---|
input.email | string | Required | User email. |
input.password | string | Required | Password. |
input.passwordConfirmation | string | Required | Password confirmation. |
input.firstName | string | Optional | First name. |
input.lastName | string | Optional | Last name. |
input.mobilePhone | string | Optional | Mobile phone. |
Get Current User
Use: users.getCurrentUser(options?).
Returns current authenticated user.
Update Profile
Use: users.updateProfile(userId, data, options?).
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | number | Required | User ID. |
data | UpdateProfileInput | Required | Profile fields to update. |
Request Mobile Phone Update
Use: users.requestMobilePhoneUpdate(input, options?).
| Field | Type | Required | Description |
|---|---|---|---|
input.mobilePhone | string | Required | New mobile phone. |
Verify Mobile Phone Update
Use: users.verifyMobilePhoneUpdate(input, options?).
| Field | Type | Required | Description |
|---|---|---|---|
input.mobilePhone | string | Required | New mobile phone. |
input.token | string | Required | Verification token. |
Forgot Password
Use: users.forgotPassword(input, options?).
| Field | Type | Required | Description |
|---|---|---|---|
input.email | string | Required | Email to send reset link/token. |
Revive Password
Use: users.revivePassword(input, options?).
| Field | Type | Required | Description |
|---|---|---|---|
input.forgotPasswordToken | string | Required | Password reset token. |
input.password | string | Required | New password. |
input.passwordConfirmation | string | Required | Password confirmation. |
Merge User
Use: users.mergeUser(options?).
Merges guest data into current authenticated user.
User fields
| Field | Type | Required | Description |
|---|---|---|---|
id | number | Required | User ID. |
email | string | Optional | User email. |
mobilePhone | string | Optional | User mobile phone. |
firstName | string | Optional | First name. |
lastName | string | Optional | Last name. |
birthDate | string | Optional | Birth date. |
Examples
// app/lib/sazito-client.ts
import { createSazitoClient } from '@sazito/client-sdk';
export const sazito = createSazitoClient({
domain: process.env.NEXT_PUBLIC_SAZITO_DOMAIN!,
});// app/[lang]/(home)/page.tsx
'use client';
import { useEffect, useState } from 'react';
import { sazito } from '@/app/lib/sazito-client';
export default function Example() {
const [data, setData] = useState<any>(null);
useEffect(() => {
sazito.users.getCurrentUser().then((res) => setData(res.data ?? null));
}, []);
return <pre>{JSON.stringify(data, null, 2)}</pre>;
}Type Details
The following tables are generated from SDK TypeScript types and include nested object fields.
LoginInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
email | string | Required |
password | string | Required |
RegisterInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
email | string | Required |
password | string | Required |
passwordConfirmation | string | Required |
firstName | string | Optional |
lastName | string | Optional |
mobilePhone | string | Optional |
MobileLoginInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
mobilePhone | string | Required |
VerifyMobileInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
mobilePhone | string | Required |
token | string | Required |
EmailLoginRequestInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
email | string | Required |
ForgotPasswordInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
email | string | Required |
ResetPasswordInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
forgotPasswordToken | string | Required |
password | string | Required |
passwordConfirmation | string | Required |
UpdateProfileInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
firstName | string | Optional |
lastName | string | Optional |
email | string | Optional |
password | string | Optional |
passwordConfirmation | string | Optional |
birthDate | string | Optional |
UpdateMobilePhoneRequestInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
mobilePhone | string | Required |
UpdateMobilePhoneVerificationInput
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
mobilePhone | string | Required |
token | string | Required |
LoginResponse
Source: src/api/users.ts
| Field | Type | Required |
|---|---|---|
jwt | string | Required |
user | User | Optional |
User
Source: src/types/invoice.ts
| Field | Type | Required |
|---|---|---|
id | number | Optional |
email | string | Optional |
mobilePhone | string | Optional |
firstName | string | Optional |
lastName | string | Optional |
birthDate | string | Optional |