class Stytch::MagicLinks::Email
def send(
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.
status_code::
The type of this field is +String+.
The unique ID of a specific email address.
email_id::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +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.
request_id::
An object with the following fields:
== Returns:
The type of this field is nilable +String+.
Use a custom template for sign-up emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Magic links - Sign-up.
signup_template_id::
The type of this field is nilable +SendRequestLocale+ (string enum).
Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
locale::
The type of this field is nilable +String+.
The `session_jwt` of the user to associate the email with.
session_jwt::
The type of this field is nilable +String+.
The `session_token` of the user to associate the email with.
session_token::
The type of this field is nilable +String+.
The unique ID of a specific User.
user_id::
The type of this field is nilable +String+.
A base64url encoded SHA256 hash of a one time secret used to validate that the request starts and ends on the same device.
code_challenge::
The type of this field is nilable +Integer+.
Set the expiration for the sign-up email magic link, in minutes. By default, it expires in 1 week. The minimum expiration is 5 minutes and the maximum is 7 days (10080 mins).
signup_expiration_minutes::
The type of this field is nilable +Integer+.
Set the expiration for the login email magic link, in minutes. By default, it expires in 1 hour. The minimum expiration is 5 minutes and the maximum is 7 days (10080 mins).
login_expiration_minutes::
The type of this field is nilable +String+.
The URL the end user clicks from the sign-up Email Magic Link. This should be a URL that your app receives and parses and subsequently send an API request to authenticate the Magic Link and sign-up the User. If this value is not passed, the default sign-up redirect URL that you set in your Dashboard is used. If you have not set a default sign-up redirect URL, an error is returned.
signup_magic_link_url::
The type of this field is nilable +String+.
The URL the end user clicks from the login Email Magic Link. This should be a URL that your app receives and parses and subsequently send an API request to authenticate the Magic Link and log in the User. 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_magic_link_url::
The type of this field is nilable +Attributes+ (+object+).
Provided attributes help with fraud detection.
attributes::
The type of this field is nilable +String+.
Use a custom template for login emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Magic links - Login.
login_template_id::
The type of this field is +String+.
The email address of the User to send the Magic Link to.
email::
== Parameters:
The user is emailed a magic link which redirects them to the provided [redirect URL](https://stytch.com/docs/guides/magic-links/email-magic-links/redirect-routing). Collect the `token` from the URL query parameters, and call [Authenticate magic link](https://stytch.com/docs/api/authenticate-magic-link) to complete authentication.
### Next steps
This endpoint also allows you to add a new email address to an existing Stytch User. Including a `user_id`, `session_token`, or `session_jwt` in your Send Magic Link by email request will add the new, unverified email address to the existing Stytch User. If the user successfully authenticates within 5 minutes, the new email address will be marked as verified and remain permanently on the existing Stytch User. Otherwise, it will be removed from the User object, and any subsequent login requests using that email address will create a new User.
### Add an email to an existing user
Send a magic link to an existing Stytch user using their email address. If you'd like to create a user and send them a magic link by email with one request, use our [log in or create endpoint](https://stytch.com/docs/api/log-in-or-create-user-by-email).
def send( email:, login_template_id: nil, attributes: nil, login_magic_link_url: nil, signup_magic_link_url: nil, login_expiration_minutes: nil, signup_expiration_minutes: nil, code_challenge: nil, user_id: nil, session_token: nil, session_jwt: nil, locale: nil, signup_template_id: nil ) headers = {} request = { email: email } request[:login_template_id] = login_template_id unless login_template_id.nil? request[:attributes] = attributes unless attributes.nil? request[:login_magic_link_url] = login_magic_link_url unless login_magic_link_url.nil? request[:signup_magic_link_url] = signup_magic_link_url unless signup_magic_link_url.nil? request[:login_expiration_minutes] = login_expiration_minutes unless login_expiration_minutes.nil? request[:signup_expiration_minutes] = signup_expiration_minutes unless signup_expiration_minutes.nil? request[:code_challenge] = code_challenge unless code_challenge.nil? request[:user_id] = user_id unless user_id.nil? request[:session_token] = session_token unless session_token.nil? request[:session_jwt] = session_jwt unless session_jwt.nil? request[:locale] = locale unless locale.nil? request[:signup_template_id] = signup_template_id unless signup_template_id.nil? post_request('/v1/magic_links/email/send', request, headers) end