Skip to main content
import { useState } from 'react';
import { useStytchB2BClient } from '@stytch/react/b2b';

export const StartSelfEmailUpdate = () => {
  const stytch = useStytchB2BClient();
  const [newEmail, setNewEmail] = useState('');

  const handleStart = async () => {
    await stytch.self.startEmailUpdate({
      new_email_address: newEmail
    });
  };

  return (
    <div>
      <input
        value={newEmail}
        onChange={(e) => setNewEmail(e.target.value)}
        placeholder="Enter new email address"
      />
      <button onClick={handleStart}>Start Email Update</button>
    </div>
  );
};
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "member": {...},
  "organization": {...}
}
self.startEmailUpdate wraps the start member email update endpoint. Use it to start the process of updating the current logged-in own email address.
RBAC Enforced MethodThis method requires a valid Session for a member with permission to perform the Action on the Resource.Before using this method, enable Member actions & organization modifications in the Frontend SDK page. To learn more, see our RBAC guide.
If you need to start an email update for a Member other than the currently logged-in Member, use the start member email update method.

Parameters

email_address
string
required
The new email address for the Member.
login_redirect_url
string
The URL that the Member clicks from the login Email Magic Link. This URL should be an endpoint in the backend server that verifies the request by querying Stytch’s authenticate endpoint and finishes the login.If this value is not passed, the default login redirect URL that you set in your Dashboard is used. If you have not set a default login redirect URL, an error is returned.
login_template_id
string
The id of the template to use for the login Email Magic Link.By default, it will use your default email template. The template must be from Stytch’s built-in customizations or a custom HTML email for Magic Links - Login.
locale
string
default:"en"
Used to determine which language to use when sending the user this delivery method. Parameter is an IETF BCP 47 language tag, e.g. "en".Supported languages are English ("en"), Spanish ("es"), French ("fr") and Brazilian Portuguese ("pt-br"); if no value is provided, the copy defaults to English.

Response

member_id
object
The id of the Member whose email address will be updated.
member
object
The Member whose email address will be updated.
organization
object
The Organization of the Member whose email address will be updated.
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.