create

abstract suspend fun create(request: IB2BTOTPsCreateParameters): B2BTOTPsCreateResponse

Creates a new TOTP instance for the current member and returns the secret, QR code URL, and recovery codes. Calls the POST /sdk/v1/b2b/totp endpoint. Automatically includes the intermediate session token if one is present. The member should scan the QR code with their authenticator app, then call authenticate to verify setup.

Kotlin:

StytchB2B.totp.create(
B2BTOTPsCreateParameters(
organizationId = "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
memberId = "member-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
)
)

iOS:

let params = B2BTOTPsCreateParameters(
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
memberId: "member-test-d5a3b680-e8a3-40c0-b815-ab79986666d0"
)
let response = try await StytchB2B.totp.create(params)

React Native:

StytchB2B.totp.create({
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
memberId: "member-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
})

Return

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

Parameters

request
  • IB2BTOTPsCreateParameters

  • organizationId — The ID of the organization.

  • memberId — The ID of the member to create the TOTP instance for.

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

Throws

StytchError

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

if the coroutine is cancelled.