> ## 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.

# Get Session

> Retrieve session details using the Stytch React SDK

> [!NOTE]
>
> In React, use the [`useStytchMemberSession`](../../hooks/use-stytch-member-session) hook to easily access the current session and react to changes.

The Stytch SDK caches the Session of the logged-in Member (Represents an individual end user's account within a given Organization, uniquely identified within that Organization by their email address.). `sessions.getSync` is a synchronous method that fetches the cached session object.

If there is no cached data, this method will return `null`.

## Response

**member\_session\_id** `string`

Globally unique UUID that identifies the Session.

**member\_id** `string`

Globally unique UUID that identifies a specific Member.

**authentication\_factors** `array[objects]`

An array of authentication factors that comprise a Session.

**properties**

**type** `string`

The type of authentication factor. The possible values are: `email_otp`, `impersonated`, `imported`, `magic_link`, `oauth`, `otp`, `password`, `recovery_codes`, `sso`, `trusted_auth_token`, or `totp`.

**delivery\_method** `string`

The method that was used to deliver the authentication factor. The possible values depend on the type:

* `email_otp`: Only `email`.
* `impersonated`: Only `impersonation`.
* `imported`:  Only `imported_auth0`.
* `magic_link`: Only `email`.
* `oauth`: `oauth_google`, `oauth_microsoft`, `oauth_hubspot`, `oauth_slack`, or `oauth_github`.
  You may see an 'exchange' delivery method when a non-email-verifying OAuth factor originally authenticated in one organization is exchanged for a factor in another organization. This can happen during authentication flows such as [session exchange](https://stytch.com/docs/api-reference/b2b/api/sessions/exchange-session.md). The non-email-verifying OAuth providers are Hubspot, Slack, and Github. Google is also considered non-email-verifying when the HD claim is empty. The possible exchange values are `oauth_exchange_google`, `oauth_exchange_hubspot`, `oauth_exchange_slack`, or `oauth_exchange_github`. The final possible value is `oauth_access_token_exchange`, if this factor came from an [access token exchange flow](https://stytch.com/docs/api-reference/b2b/api/sessions/exchange-access-token.md).
  * `otp`: Only `sms`.
  * `password`: Only `knowledge`.
  * `recovery_codes`: Only `recovery_code`.
  * `sso`: `sso_saml` or `sso_oidc`.
  * `trusted_auth_token`: Only `trusted_token_exchange`.
  * `totp`: Only `authenticator_app`.

**created\_at** `string`

The timestamp when the factor was initially authenticated.

**last\_authenticated\_at** `string`

The timestamp when the factor was last authenticated.

**updated\_at** `string`

The timestamp when the factor was last updated.

**sequence\_order** `string`

Either `PRIMARY` or `SECONDARY`. Secondary factor types include `otp`, `totp`, and `recovery_codes`. All other factors are primary.

**email\_factor** `object`

Information about the email factor, if one is present.

**properties**

**email\_address** `string`

The email address of the Member.

**email\_id** `string`

The globally unique UUID of the Member's email.

**phone\_number\_factor** `object`

Information about the phone number factor, if one is present.

**properties**

**phone\_number** `string`

The phone number.

**phone\_id** `string`

The globally unique UUID of the phone number.

**google\_oauth\_factor** `object`

Information about the Google OAuth factor, if one is present.

**properties**

**id** `string`

The unique ID of the OAuth registration.

**email\_id** `string`

The globally unique UUID of the Member's email.

**provider\_subject** `string`

The unique identifier for the User within the OAuth provider. Also commonly called the sub or "Subject field" in OAuth protocols.

**microsoft\_oauth\_factor** `object`

Information about the Microsoft OAuth factor, if one is present.

**properties**

**id** `string`

The unique ID of the OAuth registration.

**email\_id** `string`

The globally unique UUID of the Member's email.

**provider\_subject** `string`

The unique identifier for the User within the OAuth provider. Also commonly called the sub or "Subject field" in OAuth protocols.

**hubspot\_oauth\_factor** `object`

Information about the Hubspot OAuth factor, if one is present.

**properties**

**id** `string`

The unique ID of the OAuth registration.

**email\_id** `string`

The globally unique UUID of the Member's email.

**provider\_subject** `string`

The unique identifier for the User within the OAuth provider. Also commonly called the sub or "Subject field" in OAuth protocols.

**github\_oauth\_factor** `object`

Information about the Github OAuth factor, if one is present.

**properties**

**id** `string`

The unique ID of the OAuth registration.

**email\_id** `string`

The globally unique UUID of the Member's email.

**provider\_subject** `string`

The unique identifier for the User within the OAuth provider. Also commonly called the sub or "Subject field" in OAuth protocols.

**slack\_oauth\_factor** `object`

Information about the Slack OAuth factor, if one is present.

**properties**

**id** `string`

The unique ID of the OAuth registration.

**email\_id** `string`

The globally unique UUID of the Member's email.

**provider\_subject** `string`

The unique identifier for the User within the OAuth provider. Also commonly called the sub or "Subject field" in OAuth protocols.

**google\_oauth\_exchange\_factor** `object`

Information about the Google OAuth Exchange factor, if one is present.

**properties**

**email\_id** `string`

The globally unique UUID of the email address.

**hubspot\_oauth\_exchange\_factor** `object`

Information about the Hubspot OAuth Exchange factor, if one is present.

**properties**

**email\_id** `string`

The globally unique UUID of the email address.

**github\_oauth\_exchange\_factor** `object`

Information about the Github OAuth Exchange factor, if one is present.

**properties**

**email\_id** `string`

The globally unique UUID of the email address.

**slack\_oauth\_exchange\_factor** `object`

Information about the Slack OAuth Exchange factor, if one is present.

**properties**

**email\_id** `string`

The globally unique UUID of the email address.

**saml\_sso\_factor** `object`

Information about the SAML SSO factor, if one is present.

**properties**

**id** `string`

The unique ID of an SSO Registration.

**provider\_id** `string`

Globally unique UUID that identifies a specific SAML Connection.

**external\_id** `string`

The ID of the member given by the identity provider.

**oidc\_sso\_factor** `object`

Information about the OIDC SSO factor, if one is present.

**properties**

**id** `string`

The unique ID of an SSO Registration.

**provider\_id** `string`

Globally unique UUID that identifies a specific OIDC Connection.

**external\_id** `string`

The ID of the member given by the identity provider.

**authenticator\_app\_factor** `object`

Information about the TOTP-backed Authenticator App factor, if one is present.

**properties**

**totp\_id** `string`

Globally unique UUID that identifies the TOTP instance.

**impersonated\_factor** `object`

Information about the impersonated factor, if one is present.

**properties**

**impersonator\_id** `string`

For impersonated sessions initiated via the Stytch Dashboard, the impersonator's Stytch Dashboard `member_id`.

**impersonator\_email\_address** `string`

The email address of the impersonator.

**trusted\_auth\_token\_factor** `object`

Information about the trusted auth token factor, if one is present.

**properties**

**token\_id** `string`

The ID of the trusted auth token.

**oauth\_access\_token\_exchange\_factor** `object`

Information about the access token exchange factor, if one is present.

**properties**

**client\_id** `string`

The ID of the Connected App client.

**organization\_id**

The globally unique UUID that identifies the Organization associated with the Session.

**organization\_slug**

The unique URL slug of the Organization associated with the Session.

**roles** `array[string]`

A list of the roles associated with the Session.
Members may inherit certain roles depending on the factors in their Session.
For example, some roles may only be active if the member logged in from a specific SAML IDP.

**started\_at** `string`

The timestamp when the Session was created. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.

**last\_accessed\_at** `string`

The timestamp when the Session was last accessed. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.

**expires\_at** `string`

The timestamp when the Session expires. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.

**custom\_claims** `map\<string, any\>`

The custom claims map for a Session. Claims can be added to a Session during a Sessions authenticate call.

```jsx theme={null}
import { useStytchB2BClient } from '@stytch/react/b2b';

export const SessionDisplay = () => {
  const stytch = useStytchB2BClient();

  // Get cached session data synchronously
  const session = stytch.session.getSync();

  return (
    <div>
      {session ? (
        <p>Session ID: {session.member_session_id}</p>
      ) : (
        <p>No active session</p>
      )}
    </div>
  );
};
```
