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

# updateAuthToken()

Replaces the current JWT authentication token with a new one for continued secure communication. This is commonly used when tokens expire or are refreshed during a session.

## Syntax

```javascript theme={null}
instance.updateAuthToken(token);
```

## Parameters

**token** `string` *required*

The new JWT token to be set in the chat configuration.

## Returns

**void**

Returns a `void` operator.

## Examples

The following examples show different ways to update the authentication token:

```javascript theme={null}
// Update token when it expires
instance.on('authTokenNeeded', async (event, instance) => {
    const newToken = await fetchNewAuthToken();
    instance.updateAuthToken(newToken);
});

// Proactively refresh token
const refreshToken = async () => {
    const newToken = await getRefreshedToken();
    instance.updateAuthToken(newToken);
};
```

> [card] [Do you need practical examples?](https://www.ibm.com/docs/SSAVQO/deploy/web_chat_agent/tutorials/tutorials_lp.html)
>
> Learn how to apply the features available for embedded chat into your implementation with guidance and examples.
