send

abstract suspend fun send(request: IMagicLinksEmailSendSecondaryParameters): MagicLinksEmailSendSecondaryResponse

Sends a magic link email to an existing user's email address. Routes to POST /sdk/v1/magic_links/email/send/primary if no session is active, or POST /sdk/v1/magic_links/email/send/secondary if a session exists (to add an additional auth factor). Generates and stores a PKCE code pair for use in the subsequent MagicLinksClient.authenticate call.

Kotlin:

StytchConsumer.magicLinks.email.send(
MagicLinksEmailSendSecondaryParameters(
email = "user@example.com",
)
)

iOS:

let params = MagicLinksEmailSendSecondaryParameters(email: "user@example.com")
let response = try await StytchConsumer.magicLinks.email.send(params)

React Native:

StytchConsumer.magicLinks.email.send({ email: "user@example.com" })

Return

MagicLinksEmailSendSecondaryResponse confirming the email was sent.

Parameters

request
  • IMagicLinksEmailSendSecondaryParameters

  • email — The email address to send the magic link to.

  • loginMagicLinkUrl? — The URL to redirect existing users to after clicking the link.

  • signupMagicLinkUrl? — The URL to redirect new users to after clicking the link.

  • loginExpirationMinutes? — Expiration for the login magic link, in minutes.

  • signupExpirationMinutes? — Expiration for the signup magic link, in minutes.

  • loginTemplateId? — Custom email template ID to use for login emails.

  • signupTemplateId? — Custom email template ID to use for signup emails.

  • locale? — Locale for the email content (e.g. "en").

Throws

StytchError

if the request fails.

if the coroutine is cancelled.