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

> Retrieve session tokens using the Stytch Vanilla JS SDK

Returns the `session_token` and `session_jwt` values associated with the logged-in user's active session.

Session tokens are only available if:

* There is an active session, and
* The session is *not* managed via HttpOnly cookies.

If either of these conditions is not met, `session.getTokens` will return `null`.

> [!NOTE]
>
> The Stytch SDK stores the `session_token` and `session_jwt` values as session cookies in the user's browser.
>
> Those cookies will be automatically included in any request that your frontend makes to a service (such as your backend) that shares the domain set on the cookies, so in most cases, you will not need to explicitly retrieve the `session_token` and `session_jwt` values using the `getTokens()` method.

## Response

**session\_token** `string | null`

The session token for the active session, or `null` if there is no active session or if the session is managed via HttpOnly cookies.

**session\_jwt** `string | null`

The session JWT for the active session, or `null` if there is no active session or if the session is managed via HttpOnly cookies.

```jsx theme={null}
import { StytchB2BClient } from '@stytch/vanilla-js/b2b';

const stytch = new StytchB2BClient('public-token-test-b8c84de4-7d58-4ffc-9341-432b56596862');

export const getTokens = () => {
  if (stytch.session.getSync()) {
    stytch.session.getTokens();
  }
};

// Do something with the tokens, like sending them to another service
const tokens = getTokens();
```
