Skip to main content
  import { useCallback } from 'react';
  import { useStytch } from '@stytch/react';

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

    const deleteEmail = useCallback(() => {
      stytch.user.deleteEmail('${emailId}');
    }, [stytch]);

    const deletePhoneNumber = useCallback(() => {
      stytch.user.deletePhoneNumber('${phoneId}');
    }, [stytch]);

    const deleteWebauthnRegistration = useCallback(() => {
      stytch.user.deleteWebauthnRegistration('${webauthnRegistrationId}');
    }, [stytch]);

    const deleteOAuthRegistration = useCallback(() => {
      stytch.user.deleteOAuthRegistration('${oauthUserRegistrationId}');
    }, [stytch]);

    const deleteBiometricRegistration = useCallback(() => {
      stytch.user.deleteBiometricRegistration('${biometricRegistrationId}');
    }, [stytch]);

    const deleteTotp = useCallback(() => {
      stytch.user.deleteTOTP('${totpId}');
    }, [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>
      </>
    );
  };
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
  "user": {...}
}
Wraps the 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.
If a user has enrolled another MFA method, this method will require MFA. See the Multi-factor authentication section for more details.

Parameters

method_id
string
required
ID of the email, phone number, Passkey, or WebAuthn registration to be deleted.

Response

user_id
string
The unique ID of the affected User.
user
object
The user object affected by call. See the User object for complete response field details.
request_id
string
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
status_code
number
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.