Consumer Authentication

/

Mobile SDKs

/

React Native SDK reference

/

Time-Based One-Time Passcodes (TOTP)

/

Create

Create

Wraps Stytch's create endpoint. Call this method to create a new TOTP instance for a user. The user can use the authenticator application of their choice to scan the QR code or enter the secret.

You can listen for successful user updates anywhere in the codebase with the stytch.user.onChange() method or useStytchUser() hook.

Note: If a user has enrolled another MFA method, this method will require MFA. See the Multi-factor authentication section for more details.


Method parameters


expiration_minutesint
import React, { useCallback } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { useStytch } from '@stytch/react-native';

export const CreateTOTP = () => {
  const stytch = useStytch();
  const createTotpRegistration = useCallback(() => {
    stytch.totp.create({
      expiration_minutes: 5,
    });
  }, [stytch]);

  return (
    <View>
      <TouchableOpacity onPress={createTotpRegistration}>
        <Text>Create TOTP Registraion</Text>
      </TouchableOpacity>
    </View>
  );
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "totp_id": "totp-test-41920359-8bbb-4fe8-8fa3-aaa83f35f02c",
  "session": null,
  "session_jwt": "",
  "session_token": "",
  "user": {...},
  "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6"
}