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

# Token Refresh

> Rely on automatic access token refresh in SukiAuthManager, or wire custom refresh logic before tokens expire

Quick summary

The SDK automatically handles access token refreshes to ensure uninterrupted access to Suki services. It monitors the token's expiration time and refreshes it in the background before it expires using the `partnerToken` you provided during initialization.

Update the `partnerToken` at runtime by calling the `setPartnerToken` method without requiring re-authentication.

Last updated:
November 2026

Keep Headed Web SDK sessions authenticated with automatic Suki access token refresh, and rotate the Partner Token at runtime when your IdP issues a new JWT.

## Common patterns and use cases

Design authentication around the `partnerToken` exchange. The SDK refreshes the Suki access token automatically while your `partnerToken` remains valid. When your identity provider issues a new `partnerToken`, update it at runtime with `setPartnerToken`.

The following patterns show common ways to keep Web SDK sessions authenticated:

> [card] Rely on Automatic Suki Token Refresh
>
> Initialize the SDK with a valid `partnerToken`. The SDK monitors expiration and refreshes the Suki access token in the background before it expires.

> [card] Rotate the Partner Token at Runtime
>
> When your identity provider issues a new Partner Token JWT, call `setPartnerToken` with the new value. No re-authentication flow is required.

> [card] Keep the Partner Token Valid for Refresh
>
> Ensure the current `partnerToken` is still valid when the SDK refreshes. If the partner token has expired, automatic Suki token refresh fails and API calls fail.

> [card] Sync Token Updates in React
>
> Use `useSuki().setPartnerToken` in a `useEffect` that depends on your latest partner token so React apps stay in sync when the token changes.

## Authentication & token exchange

The Suki Platform uses a **token exchange mechanism** to securely authenticate and authorize your access to the SDK. Refer to [Partner authentication](https://developer.suki.ai/documentation/how-to/partner-authentication.md) guide for more information.

When you initialize the SDK, you must provide a `partnerToken` (JWT from your identity provider). The SDK exchanges this `partnerToken` with the Suki Platform to get a **Suki access token**. All subsequent API calls use this Suki access token for authorization.

### Automatic token refresh

The SDK automatically handles access token refreshes to ensure you have uninterrupted access to Suki services. It monitors the token's expiration time and refreshes it in the background before it expires.

This process is fully automatic and uses the `partnerToken` you provided during initialization.

### Constraints

> [!WARNING]
>
> **Important:**
>
> * For the automatic refresh to succeed, the `partnerToken` you provided must still be **valid** at the time of the refresh. If your `partnerToken` expires, the SDK cannot get a new Suki access token, and API calls will fail.
> * Update the `partnerToken` at runtime by calling the `setPartnerToken` method; no re-authentication is required.

## Example

Here's how to update the token at runtime:

> [tab] JavaScript
>
> ```js JavaScript theme={"theme":{"light":"one-light","dark":"material-theme-darker"}}
> // whenever the access token is refreshed, call `setPartnerToken` with the new token
> sdkClient.setPartnerToken("new-partner-token");
> ```

> [tab] React
>
> ```jsx React theme={"theme":{"light":"one-light","dark":"material-theme-darker"}}
> import { useSuki } from "@suki-sdk/react";
> import { useEffect } from "react";
>
> const MyComponent = ({ token }) => {
>   const { setPartnerToken } = useSuki();
>
>   useEffect(() => {
>     // whenever the access token is refreshed, call `setPartnerToken` with the new token
>     setPartnerToken(token);
>   }, [setPartnerToken, token]); // token is the new partner token you want to set
>
>   return <div>App Content</div>;
> };
> ```

## Next steps

&#x20;**[Telehealth](https://developer.suki.ai/web-sdk/guides/telehealth.md)** - Guide to learn more about how Suki manages telehealth sessions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.