loginOrSignup

abstract suspend fun loginOrSignup(request: IB2BMagicLinksLoginOrSignupParameters): B2BMagicLinksLoginOrSignupResponse

Sends a magic link email to the provided address for login or signup within an organization. Calls the POST /sdk/v1/b2b/magic_links/email/login_or_signup endpoint. Generates and stores a PKCE code pair for use in the subsequent B2BMagicLinksClient.authenticate call.

Kotlin:

StytchB2B.magicLinks.email.loginOrSignup(
B2BMagicLinksLoginOrSignupParameters(
emailAddress = "user@example.com",
organizationId = "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
)
)

iOS:

let params = B2BMagicLinksLoginOrSignupParameters(
emailAddress: "user@example.com",
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0"
)
let response = try await StytchB2B.magicLinks.email.loginOrSignup(params)

React Native:

StytchB2B.magicLinks.email.loginOrSignup({
emailAddress: "user@example.com",
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
})

Return

B2BMagicLinksLoginOrSignupResponse confirming the magic link email was sent.

Parameters

request
  • IB2BMagicLinksLoginOrSignupParameters

  • emailAddress — The email address of the member.

  • organizationId — The ID of the organization the member belongs to.

  • loginRedirectUrl? — URL to redirect to after a successful login magic link click.

  • signupRedirectUrl? — URL to redirect to after a successful signup magic link click.

  • loginTemplateId? — Custom email template ID for the login email.

  • signupTemplateId? — Custom email template ID for the signup email.

  • locale? — Locale used for the email content.

Throws

StytchError

if the request fails.

if the coroutine is cancelled.