Invite Member via Email Magic Link - Stytch Docs
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
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>;
};
Error Responses
200
{
"status_code": 200,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
"member": {...},
"organization": {...}
}
401
{
"status_code": 401,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "unauthorized_credentials",
"error_message": "Unauthorized credentials.",
"error_url": "https://stytch.com/docs/api/errors/401"
}
403
{
"status_code": 403,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "session_authorization_error",
"error_message": "The Member is not authorized to perform the requested action on that resource.",
"error_url": "https://stytch.com/docs/api/errors/403"
}
429
{
"status_code": 429,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "too_many_requests",
"error_message": "Too many requests have been made.",
"error_url": "https://stytch.com/docs/api/errors/429"
}
500
{
"status_code": 500,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "internal_server_error",
"error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
"error_url": "https://stytch.com/docs/api/errors/500"
}
magicLinks.email.invite wraps the Send Invite Email endpoint. Use this method to invite a new Member to an Organization via email.
RBAC Enforced Method
This method requires a valid Session for a member with permission to perform the create Action on the stytch.member 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”.
invite_expiration_minutes
number
The expiration of the Magic Link sent in the invite email, in minutes. Defaults to 7 days. The minimum expiration is 5 minutes and the maximum is 10080 mins (7 days).
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_id
string
Globally unique UUID that identifies a specific Organization.
member_id
string
Globally unique UUID that identifies a specific Member.
external_id
string
The ID of the Member given by the identity provider.
email_address
string
The email address of the Member.
email_address_verified
boolean
Whether or not the Member’s email address is verified.
status
string
The status of the Member. The possible values are: pending, invited, active, or deleted.
name
string
The name of the Member.
sso_registration
object[]
An array of registered SAML Connection or OIDC Connection objects the Member has authenticated with.
organization
object
The Organization that the Member was invited to.
created_at
string
The date and time the Member was created.
updated_at
string
The date and time the Member was last updated.