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

# Config Updates

> Update SDK behaviour and styled config at runtime.

| Function                                 | Description                                  |
| ---------------------------------------- | -------------------------------------------- |
| `updateSidenetConfig(options)`           | Update SDK behaviour / layout / credential   |
| `updateSidenetStyledConfig(styleConfig)` | Update greeting / suggestions / theme tokens |
| `refreshSidenetConfig()`                 | Re-fetch config from backend (async)         |
| `refreshSidenetStyles()`                 | Re-apply container styles                    |
| `getRuntimeConfig()`                     | Get current merged config                    |

Two update functions, separated by what they change:

* **`updateSidenetConfig(options)`** — SDK behaviour and chrome. Accepts every init option **except** `copilotId` (see below), the callbacks (`onOpen` / `onClose` / `onResize` / `onReady`), and the one-shot init-only fields (`customCSS`, `customStyles`, `sdkUi`, `defaultOpen`). Concretely: `auth`, `width`, `height`, `position`, `layout`, `offset`, `zIndex`, `theme` (`'light' | 'dark'`), `agentId`, `agentVersionId`, `showAgentDropdown`, `keyboardShortcut`, `threadId`, `read_only`, `use_routing`, `groupName`, `groupId`, `firstMessage`, `context`, `variables`, `lastThread`, `debug`, `showClose`, `closeOnOutsideClick`. Three `null` sentinels: `keyboardShortcut: null` disables the shortcut, `threadId: null` clears the pinned thread, `agentVersionId: null` clears the pinned agent version.
* **`updateSidenetStyledConfig(styleConfig)`** — visual content. Accepts `Partial<SidebarSDKConfig>` — the same shape the backend returns as `sdk_ui`. Use it to override `text` (greeting / placeholder / suggestions) and `theme` design tokens. Partial calls merge into the current config, so passing only `text.suggestions` keeps `text.greeting` and the loaded `theme` intact.
* **`getRuntimeConfig()`** — synchronous read of the current merged `{ text, theme }`. Useful for snapshotting the resolved config (defaults + backend `sdk_ui` + your overrides) without subscribing via `useSidebarConfig`.

<Tip>
  Rule of thumb: "where the sidebar is and how it behaves" → `updateSidenetConfig`. "what the sidebar looks like and what copy it shows" → `updateSidenetStyledConfig`.
</Tip>

`context` and `variables` are updatable here too — each call **replaces** the whole value rather than merging into it, and applies to the next send. See [Prompt Variables](/docs/sdk/api/prompt-variables) for both.

## `copilotId` is init-only

It binds the whole session to a set of backend resources — the thread list, the agent list, the copilot's `sdk_ui` config, and the id of every thread created since init. Swapping it in place would leave all of that pointing at the previous copilot, so `updateSidenetConfig()` **ignores a changed value and warns**:

```
⚠️ SideNetAI SDK: copilotId is init-only and was ignored (still "copilot-456").
   Call destroySidenet() then initSidenet() to change it.
```

To switch, tear down and start again:

```javascript theme={null}
await destroySidenet();
await initSidenet({ ...config, copilotId: 'copilot-789' });
```

<Note>
  Re-passing the *current* value is a silent no-op, so handing the SDK your whole config object on every update is safe — only an actual change warns.
</Note>

## Swapping the session

Everything else about identity — **who the user is**, which billing group they belong to, which [tool credentials](/docs/sdk/api/tool-credentials) their tools use — lives in the session token. So none of it needs a teardown. Mint a new session and pass it as a unit:

```javascript theme={null}
updateSidenetConfig({ auth: { ...newTokens, onRefresh, onError } });
```

The open conversation is preserved: messages stay on screen, the thread stays selected, and any in-flight response keeps streaming on the old credential. The new one applies to the next outgoing request — chat sends as well as thread-list, message-history, and vote calls.

<Note>
  You rarely need this for expiry alone. While a `refresh_token` is present the SDK [refreshes on its own](/docs/sdk/authentication#automatic-refresh). Reach for this when you mint a *different* session — a new user, or updated tool credentials — or after a fatal `onError`.
</Note>

<Warning>
  `auth` is replaced wholesale, with no validation. Pass the complete object, including `onRefresh` / `onError` if you want them to keep firing — omitting the field entirely is what leaves the current session untouched.
</Warning>
