exchange

abstract suspend fun exchange(request: IB2BSessionsExchangeParameters): B2BSessionsExchangeResponse

Exchanges the current member session for a session in a different organization. Calls the POST /sdk/v1/b2b/sessions/exchange endpoint. The member must belong to the target organization.

Kotlin:

StytchB2B.sessions.exchange(
B2BSessionsExchangeParameters(
organizationId = "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
sessionDurationMinutes = 30,
)
)

iOS:

let params = B2BSessionsExchangeParameters(
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
sessionDurationMinutes: 30
)
let response = try await StytchB2B.sessions.exchange(params)

React Native:

StytchB2B.sessions.exchange({
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
sessionDurationMinutes: 30,
})

Return

B2BSessionsExchangeResponse containing the new member session for the target organization.

Parameters

request
  • IB2BSessionsExchangeParameters

  • organizationId — The ID of the organization to exchange into.

  • sessionDurationMinutes — Duration of the new session, in minutes.

  • locale? — Locale for any follow-up communications.

Throws

StytchError

if the current session is invalid or the member is not in the target organization.

if the coroutine is cancelled.