create

abstract suspend fun create(request: ITOTPsCreateParameters): TOTPsCreateResponse

Creates a new TOTP instance for the current user and returns the secret, QR code URL, and recovery codes. Calls the POST /sdk/v1/totps endpoint. The user should scan the QR code with their authenticator app, then call authenticate to verify setup.

Kotlin:

StytchConsumer.totps.create(TOTPsCreateParameters())

iOS:

let params = TOTPsCreateParameters()
let response = try await StytchConsumer.totps.create(params)

React Native:

StytchConsumer.totps.create({})

Return

TOTPsCreateResponse containing the TOTP secret, qrCode URL, and recoveryCodes.

Parameters

request
  • ITOTPsCreateParameters

  • expirationMinutes? — Time before the TOTP setup expires if not verified, in minutes.

Throws

StytchError

if the request fails or the user already has an active TOTP instance.

if the coroutine is cancelled.