Consumer Authentication

/

Frontend SDKs

/

Headless

/

Users

/

Delete authentication factors

Delete authentication factors

Wraps Stytch's delete authentication factors family of endpoints and can be used to remove factors from a user.

These methods cannot be used to remove all factors from a user. A user must have at least one email, phone number, or OAuth provider associated with their account at all times, otherwise they will not be able to log in again.

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

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


method_id*string
import React, { useCallback } from 'react';
import { useStytch } from '@stytch/react';

export const DeleteAuthenticationFactors = () => {
  const stytch = useStytch();

  const deleteEmail = useCallback(() => {
    stytch.user.deleteEmail('email-test-81bf03a8-86e1-4d95-bd44-bb3495224953');
  }, [stytch]);

  const deletePhoneNumber = useCallback(() => {
    stytch.user.deletePhoneNumber('phone-number-test-d5a3b680-e8a3-40c0-b815-ab79986666d0');
  }, [stytch]);

  const deleteWebauthnRegistration = useCallback(() => {
    stytch.user.deleteWebauthnRegistration('webauthn-registration-test-5c44cc6a-8af7-48d6-8da7-ea821342f5a6');
  }, [stytch]);

  const deleteOAuthRegistration = useCallback(() => {
    stytch.user.deleteOAuthRegistration('oauth-user-test-de86770c-911d-463f-80e7-f1b089cead14');
  }, [stytch]);

  const deleteBiometricRegistration = useCallback(() => {
    stytch.user.deleteBiometricRegistration('biometric-registration-test-6966a6fc-5264-46ee-9ba4-98c6322a5134');
  }, [stytch]);

  const deleteTotp = useCallback(() => {
    stytch.user.deleteTOTP('totp-test-41920359-8bbb-4fe8-8fa3-aaa83f35f02c');
  }, [stytch]);

  return (
    <>
      <button onClick={deleteEmail}>Delete email</button>
      <button onClick={deletePhoneNumber}>Delete phone number</button>
      <button onClick={deleteWebauthnRegistration}>Delete WebAuthn registration</button>
      <button onClick={deleteOAuthRegistration}>Delete OAuth registration</button>
      <button onClick={deleteBiometricRegistration}>Delete Biometric registration</button>
      <button onClick={deleteTotp}>Delete TOTP registration</button>
    </>
  );
};

RESPONSE

200
{
"status_code": 200,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
"user": {...}
}