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

export const InviteMember = () => {
  const stytch = useStytchB2BClient();

  const inviteMember = () => {
    stytch.magicLinks.email.invite({
      email_address: 'new-member@example.com',
      name: 'Jane Doe',
    });
  };

  return <button onClick={inviteMember}>Invite a Member</button>;
};
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "member": {...},
  "organization": {...}
}
magicLinks.email.invite wraps the Send Invite Email endpoint. Use this method to invite a new to an via email.
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.
The organization_id will be automatically inferred from the logged-in Member’s session. To revoke an existing invite, use the Delete Member method. This will both delete the invited Member from the target Organization and revoke all existing invite emails.

Parameters

email_address
string
required
The email address of the user that the currently logged-in Member would like to invite to their Organization.
invite_redirect_url
string
The URL that the Member clicks from the invite 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 invite flow.If this value is not passed, the default invite_redirect_url that you set in your Dashboard is used. If you have not set a default invite_redirect_url, an error is returned.
invite_template_id
string
Use a custom template for invite 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 “Magic Links - Invite”.
name
string
The name of the Member.
roles
string[]
Roles to explicitly assign to this Member.
untrusted_metadata
object
An arbitrary JSON object of application-specific data. These fields can be edited directly by the frontend SDK, and should not be used to store critical information. See the Metadata resource for complete field behavior details.
locale
string
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
string
The ID of the invited Member.
member
object
The invited Member.
organization
object
The Organization that the Member was invited to.
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.