loginOrCreate
abstract suspend fun loginOrCreate(request: IOTPsSMSLoginOrCreateParameters): OTPsSMSLoginOrCreateResponse
Sends a one-time passcode via SMS to the provided phone number, logging in an existing user or creating a new one. Calls the POST /sdk/v1/otps/sms/login_or_create endpoint.
Kotlin:
StytchConsumer.otps.sms.loginOrCreate(
OTPsSMSLoginOrCreateParameters(phoneNumber = "+15005550006")
)Content copied to clipboard
iOS:
let params = OTPsSMSLoginOrCreateParameters(phoneNumber: "+15005550006")
let response = try await StytchConsumer.otps.sms.loginOrCreate(params)Content copied to clipboard
React Native:
StytchConsumer.otps.sms.loginOrCreate({ phoneNumber: "+15005550006" })Content copied to clipboard
Return
OTPsSMSLoginOrCreateResponse containing the methodId needed for OtpClient.authenticate.
Parameters
request
IOTPsSMSLoginOrCreateParameters
phoneNumber— The phone number to send the OTP to, in E.164 format (e.g."+15005550006").expirationMinutes?— Expiration for the OTP, in minutes.locale?— Locale used for the SMS message (e.g."en").enableAutofill?— Whether to enable OS-level OTP autofill hints on supported platforms.
Throws
StytchError
if the request fails.
if the coroutine is cancelled.