Skip to main content
import { useState } from 'react';
import { View, TextInput, Button } from 'react-native';
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const ResetPasswordStart = () => {
  const stytch = useStytchB2BClient();
  const [email, setEmail] = useState('');

  const startReset = async () => {
    const response = await stytch.passwords.resetByEmailStart({
      organization_id: 'organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931',
      email_address: email,
      reset_password_redirect_url: 'https://example.com/reset-password',
    });
    console.log('Reset email sent:', response);
  };

  return (
    <View>
      <TextInput
        value={email}
        onChangeText={setEmail}
        placeholder="Email"
        keyboardType="email-address"
      />
      <Button title="Send Reset Email" onPress={startReset} />
    </View>
  );
};
passwords.resetByEmailStart wraps the Reset By Email Start Password API endpoint. This endpoint initiates a password reset for the email address provided. This will trigger an email to be sent to the address, containing a magic link that will allow the member to set a new password and authenticate.

Parameters

email_address
string
required
The email address of the Member.
organization_id
string
required
Globally unique UUID that identifies a specific Organization. You may also use the organization_slug or organization_external_id here as a convenience.
reset_password_redirect_url
string
The URL that the Member clicks from the reset password link. This URL should be an endpoint in the backend server that verifies the request by querying Stytch’s authenticate endpoint and finishes the reset password flow. If this value is not passed, the default reset_password_redirect_url that you set in your Dashboard is used. If you have not set a default reset_password_redirect_url, an error is returned.
login_redirect_url
string
The URL that Members are redirected to upon clicking the “Log in without password” button in password reset emails.After Members are redirected to the login redirect URL, your application should retrieve the token value from the URL parameters and call the Magic Link Authenticate endpoint to log the Member in without requiring a password reset. If this value is not provided, your project’s default login redirect URL will be used. If you have not set a default login redirect URL, an error will be returned.
reset_password_expiration_minutes
number
Sets a time limit after which the email link to reset the member’s password will no longer be valid. The minimum allowed expiration is 5 minutes and the maximum is 10080 minutes (7 days). By default, the expiration is 30 minutes.
reset_password_template_id
string
Use a custom template for reset password emails. By default, it will use your default email template. Templates can be added in the Stytch dashboard using our built-in customization options or custom HTML templates with type “Passwords - Reset Password”.

Response

member_id
string
The ID of the Member.
member_email_id
string
The ID of the Member Email.
member
object
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.