> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Exchange organization sessions

> Seamlessly switch a member's session between organizations.

## Overview

Session tokens are valid for one organization at a time, but you can exchange a member's active session for a session with another organization using the Session exchange endpoint:

> [card] [session.exchange()](https://stytch.com/docs/api-reference/b2b/frontend-sdks/react/methods/sessions/exchange-session.md)
>
> Exchange the member's current session for a session in a specified organization.

***

## Build an organization switcher

> [!TIP]
>
> See our [example apps](https://github.com/stytchauth/stytch-all-examples/) for a code example of an organization switcher component.

**1. List organizations the user has access to**

Use the `discovery.organizations.list()` [method](https://stytch.com/docs/api-reference/b2b/frontend-sdks/react/methods/discovery/list-discovered-organizations.md) to retrieve a list of organizations the user has access to:

```jsx theme={null}
export const listOrganizations = async () => {
    const { discovered_organizations } = await stytch.discovery.organizations.list();
    return discovered_organizations;
};
```

**2. Exchange the active session**

Once the user selects an organization, exchange their active session for a session in the selected organization using the `session.exchange()` [method](https://stytch.com/docs/api-reference/b2b/frontend-sdks/react/methods/sessions/exchange-session.md):

```jsx theme={null}
export const exchange = (target_organization_id) => {
    stytch.session.exchange({
        organization_id: target_organization_id,
        session_duration_minutes: DESIRED_SESSION_LENGTH,
    });
};
```

**3. Notes**

* If additional authentication is required for the selected organization, the Exchange session method returns an `intermediate_session_token` instead of a fully minted session.
