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

> Learn how to implement automatic token refresh for the Suki Web SDK

<div className="quick-summary-wrapper">
  <div className="quick-summary-header">
    <span className="quick-summary-icon" aria-hidden="true" />

    <span className="quick-summary-title">Quick summary</span>
  </div>

  <div className="quick-summary-content">
    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.

    <br />

    <br />

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

  <div className="quick-summary-footer">
    <span className="quick-summary-footer-icon" aria-hidden="true" />

    <span className="quick-summary-footer-text">Last updated:</span>
    <span className="quick-summary-footer-date">June 2026</span>
  </div>
</div>

This guide explains how to implement automatic token refresh for the Suki Web SDK.

## 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](/documentation/partner-authentication) guide for more information.

When you initialize the SDK, you must provide a `partnerToken` (which you receive from the EHR system). 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.
</Warning>

## Example

Here's how to update the token at runtime:

<View title="JavaScript" icon="js">
  ```js JavaScript theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
  // whenever the access token is refreshed, call `setPartnerToken` with the new token
  sdkClient.setPartnerToken("new-partner-token");
  ```
</View>

<View title="React" icon="react">
  ```jsx React theme={"theme":{"light":"github-dark","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>;
  };
  ```
</View>

## Next steps

<Icon icon="file-lines" iconType="solid" /> Refer to [Telehealth](/web-sdk/guides/telehealth) guide to learn more about how Suki manages telehealth sessions.
