import { StytchB2BClient } from '@stytch/vanilla-js/b2b';const stytch = new StytchB2BClient('public-token-test-b8c84de4-7d58-4ffc-9341-432b56596862');const session = stytch.session.getSync();
import { StytchB2BClient } from '@stytch/vanilla-js/b2b';const stytch = new StytchB2BClient('public-token-test-b8c84de4-7d58-4ffc-9341-432b56596862');const session = stytch.session.getSync();
Sessions
Get Session
Retrieve session details using the Stytch Vanilla JS SDK
import { StytchB2BClient } from '@stytch/vanilla-js/b2b';const stytch = new StytchB2BClient('public-token-test-b8c84de4-7d58-4ffc-9341-432b56596862');const session = stytch.session.getSync();
import { StytchB2BClient } from '@stytch/vanilla-js/b2b';const stytch = new StytchB2BClient('public-token-test-b8c84de4-7d58-4ffc-9341-432b56596862');const session = stytch.session.getSync();
The Stytch SDK caches the Session of the logged-in . sessions.getSync is a synchronous method that fetches the cached session object.If there is no cached data, this method will return null.
Response
string
Globally unique UUID that identifies the Session.
string
Globally unique UUID that identifies a specific Member.
array[objects]
An array of authentication factors that comprise a Session.
Show properties
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.
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. 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.
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.
string
The timestamp when the factor was initially authenticated.
string
The timestamp when the factor was last authenticated.
string
The timestamp when the factor was last updated.
string
Either PRIMARY or SECONDARY. Secondary factor types include otp, totp, and recovery_codes. All other factors are primary.
object
Information about the email factor, if one is present.
Show properties
string
The email address of the Member.
string
The globally unique UUID of the Member’s email.
object
Information about the phone number factor, if one is present.
Show properties
string
The phone number.
string
The globally unique UUID of the phone number.
object
Information about the Google OAuth factor, if one is present.
Show properties
string
The unique ID of the OAuth registration.
string
The globally unique UUID of the Member’s email.
string
The unique identifier for the User within the OAuth provider. Also commonly called the sub or “Subject field” in OAuth protocols.
object
Information about the Microsoft OAuth factor, if one is present.
Show properties
string
The unique ID of the OAuth registration.
string
The globally unique UUID of the Member’s email.
string
The unique identifier for the User within the OAuth provider. Also commonly called the sub or “Subject field” in OAuth protocols.
object
Information about the Hubspot OAuth factor, if one is present.
Show properties
string
The unique ID of the OAuth registration.
string
The globally unique UUID of the Member’s email.
string
The unique identifier for the User within the OAuth provider. Also commonly called the sub or “Subject field” in OAuth protocols.
object
Information about the Github OAuth factor, if one is present.
Show properties
string
The unique ID of the OAuth registration.
string
The globally unique UUID of the Member’s email.
string
The unique identifier for the User within the OAuth provider. Also commonly called the sub or “Subject field” in OAuth protocols.
object
Information about the Slack OAuth factor, if one is present.
Show properties
string
The unique ID of the OAuth registration.
string
The globally unique UUID of the Member’s email.
string
The unique identifier for the User within the OAuth provider. Also commonly called the sub or “Subject field” in OAuth protocols.
object
Information about the Google OAuth Exchange factor, if one is present.
Show properties
string
The globally unique UUID of the email address.
object
Information about the Hubspot OAuth Exchange factor, if one is present.
Show properties
string
The globally unique UUID of the email address.
object
Information about the Github OAuth Exchange factor, if one is present.
Show properties
string
The globally unique UUID of the email address.
object
Information about the Slack OAuth Exchange factor, if one is present.
Show properties
string
The globally unique UUID of the email address.
object
Information about the SAML SSO factor, if one is present.
Show properties
string
The unique ID of an SSO Registration.
string
Globally unique UUID that identifies a specific SAML Connection.
string
The ID of the member given by the identity provider.
object
Information about the OIDC SSO factor, if one is present.
Show properties
string
The unique ID of an SSO Registration.
string
Globally unique UUID that identifies a specific OIDC Connection.
string
The ID of the member given by the identity provider.
object
Information about the TOTP-backed Authenticator App factor, if one is present.
Show properties
string
Globally unique UUID that identifies the TOTP instance.
object
Information about the impersonated factor, if one is present.
Show properties
string
For impersonated sessions initiated via the Stytch Dashboard, the impersonator’s Stytch Dashboard member_id.
string
The email address of the impersonator.
object
Information about the trusted auth token factor, if one is present.
Show properties
string
The ID of the trusted auth token.
object
Information about the access token exchange factor, if one is present.
Show properties
string
The ID of the Connected App client.
The globally unique UUID that identifies the Organization associated with the Session.
The unique URL slug of the Organization associated with the Session.
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.
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.
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.
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.
map<string, any>
The custom claims map for a Session. Claims can be added to a Session during a Sessions authenticate call.
Assistant
Responses are generated using AI and may contain mistakes.