loginOrCreate
abstract suspend fun loginOrCreate(request: IOTPsEmailLoginOrCreateParameters): OTPsEmailLoginOrCreateResponse
Sends a one-time passcode via email to the provided address, logging in an existing user or creating a new one. Calls the POST /sdk/v1/otps/email/login_or_create endpoint.
Kotlin:
StytchConsumer.otps.email.loginOrCreate(
OTPsEmailLoginOrCreateParameters(email = "user@example.com")
)Content copied to clipboard
iOS:
let params = OTPsEmailLoginOrCreateParameters(email: "user@example.com")
let response = try await StytchConsumer.otps.email.loginOrCreate(params)Content copied to clipboard
React Native:
StytchConsumer.otps.email.loginOrCreate({ email: "user@example.com" })Content copied to clipboard
Return
OTPsEmailLoginOrCreateResponse containing the methodId needed for OtpClient.authenticate.
Parameters
request
IOTPsEmailLoginOrCreateParameters
email— The email address to send the OTP to.expirationMinutes?— Expiration for the OTP, in minutes.signupTemplateId?— Custom email template ID to use for new-user emails.loginTemplateId?— Custom email template ID to use for returning-user emails.locale?— Locale used for the email content (e.g."en").
Throws
StytchError
if the request fails.
if the coroutine is cancelled.