# Web SDK types

> The public values and TypeScript types @runbear-io/react exports — the client, the chat instance, session types, event payloads, messages and response components.

Source: https://docs.runbear.io/api/web-sdk/types

Last updated: 2026-09-30

`@runbear-io/react` ships its TypeScript declarations. This page lists the package's supported
public exports, grouped by what you use it for. Exports used only by the SDK's own internals, such as
`ChatRequestOptions`, are left out and may change without notice. "Since" is the first release that exports the name. The current release is 0.4.0; names marked 0.5.0 are not exported until 0.5.0 is released.

```ts
import Runbear, {
  SessionDeclinedError,
  type SessionCredentials,
} from "@runbear-io/react"
```

## Values

| Export                            | Since | What it is                                                                                                                                                        |
| --------------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Runbear`                         | 0.0.1 | The client class, also the **default export**. `new Runbear(options)` takes [`ClientOptions`](#client-options); `createChat(threadId?)` returns a [`Chat`](#chat) |
| `RunBear`                         | 0.0.1 | An alias of `Runbear`, kept for older code                                                                                                                        |
| `SessionDeclinedError`            | 0.2.0 | Throw it from `fetchSessionToken` to end a session at once. See [Declining a session](/api/web-sdk/authentication.md#declining-a-session)                         |
| `SessionCredentialError`          | 0.2.0 | Marks a session endpoint response the SDK can't use. The SDK throws it itself; a session that hits it fails with `reason: "misconfigured"`                        |
| `isSessionDeclined(error)`        | 0.2.0 | `true` when `error`, or an error in its `cause` chain, is a `SessionDeclinedError`, including one from a second copy of the package                               |
| `isSessionCredentialError(error)` | 0.2.0 | The same test for `SessionCredentialError`                                                                                                                        |
| `RunbearApiError`                 | 0.2.0 | The error for a non-2xx API response, with `status`, `code`, `body` and `retryAfterSeconds`. See [Errors](/api/web-sdk/errors.md#runbearapierror)                 |

A `Runbear` client also has an `api` property. It is the widget's internal API client and isn't a
supported public surface.

## Client options

| Type            | Since | What it is                                                                                                                                                                                                       |
| --------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ClientOptions` | 0.0.1 | The constructor's argument: `assistantId` (required), `auth`, `config`, and the deprecated `apiKey` and `baseUrl`. See [Configuration](/api/web-sdk/configuration.md) for `config`                               |
| `RunbearAuth`   | 0.2.0 | The `auth` option: `{ mode: "session", fetchSessionToken, storage?, sessionKey? }`, `{ mode: "proxy", baseUrl }` or `{ mode: "direct", apiKey, baseUrl? }`. See [Authentication](/api/web-sdk/authentication.md) |

## Chat

| Type   | Since | What it is                                                                                                                                                                                                       |
| ------ | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Chat` | 0.5.0 | The widget instance `createChat()` returns, for keeping one in a variable or a ref. Create it with `createChat()`; it has no public constructor. Its methods are on [Chat API](/api/web-sdk/chat-api.md#methods) |

## Session

| Type                    | Since | What it is                                                                                                                                                        |
| ----------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FetchSessionToken`     | 0.2.0 | `(args: FetchSessionTokenArgs) => Promise<SessionCredentials>`, the type of `auth.fetchSessionToken`                                                              |
| `FetchSessionTokenArgs` | 0.2.0 | `{ resumeToken?, assistantId, threadId?, signal }`. See [What fetchSessionToken receives](/api/web-sdk/authentication.md#what-fetchsessiontoken-receives)         |
| `SessionCredentials`    | 0.2.0 | `{ pass, threadId, sessionId, expiresIn, resumeToken? }`, what your endpoint returns. See [SessionCredentials](/api/web-sdk/authentication.md#sessioncredentials) |
| `SessionStorageMode`    | 0.2.0 | `"session" \| "local" \| "memory"`, the type of `auth.storage`                                                                                                    |
| `SessionFailureReason`  | 0.2.0 | `"declined" \| "expired" \| "network" \| "misconfigured"`                                                                                                         |

## Events

| Type                          | Since | What it is                                                                                                                                                                                   |
| ----------------------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ChatEventType`               | 0.2.0 | The event names `on()` and `off()` accept: `chatCreated`, `chatStarted`, `rendered`, `containerReady`, `messagesLoaded`, `sessionReady`, `sessionRenewed`, `sessionChanged`, `sessionFailed` |
| `ChatEventCreatedData`        | 0.5.0 | `chatCreated` payload: `{ threadId }`                                                                                                                                                        |
| `ChatEventContainerReadyData` | 0.5.0 | `containerReady` payload: `{ threadId }`                                                                                                                                                     |
| `ChatEventMessagesLoadedData` | 0.5.0 | `messagesLoaded` payload: `{ threadId, messageCount }`                                                                                                                                       |
| `ChatEventSessionReadyData`   | 0.2.0 | `sessionReady` payload: `{ sessionId, threadId }`                                                                                                                                            |
| `ChatEventSessionRenewedData` | 0.2.0 | `sessionRenewed` payload: `{ sessionId }`                                                                                                                                                    |
| `ChatEventSessionChangedData` | 0.2.0 | `sessionChanged` payload: `{ sessionId, threadId }`                                                                                                                                          |
| `ChatEventSessionFailedData`  | 0.2.0 | `sessionFailed` payload: `{ reason: SessionFailureReason }`                                                                                                                                  |

`chatStarted` and `rendered` carry no payload. Before 0.5.0, the `chatCreated`, `containerReady` and
`messagesLoaded` payloads had the same shapes but no exported names.

## Messages

| Type             | Since | What it is                                                                                                                                                                 |
| ---------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ChatMessage`    | 0.0.1 | One message in the widget: `{ id?, role, content, thinking?, toolCalls?, suggestions?, attachments?, components? }`, where `role` is `"user"`, `"assistant"` or `"system"` |
| `Message`        | 0.0.1 | An alias of `ChatMessage`                                                                                                                                                  |
| `ToolCallStatus` | 0.0.1 | A tool call's progress: `{ toolUseId, toolName, toolDisplayName, status, message }`, where `status` is `"preparing"`, `"running"`, `"completed"` or `"failed"`             |
| `Suggestions`    | 0.0.1 | Suggested follow-up questions: `{ title, options }`                                                                                                                        |
| `Attachment`     | 0.0.1 | An uploaded file attached to a message: `{ url, name, contentType }`                                                                                                       |

## Response components

| Type                  | Since | What it is                                                                                                                                                                                                                                                    |
| --------------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ChatComponent`       | 0.3.0 | A component on a message: `{ componentId, name, props, fallbackText }`. `name` is an open string and `props` an open object; narrow `props` by `name` before reading it. See [Response components](/api/web-sdk/response-components.md#components-on-the-api) |
| `ChatComponentOption` | 0.3.0 | One option of a `confirm` or `select`: `{ label, value, style? }`, where `style` is `"default"`, `"primary"` or `"danger"`                                                                                                                                    |
| `ConfirmProps`        | 0.3.0 | `props` of a `confirm`: `{ options: ChatComponentOption[] }`                                                                                                                                                                                                  |
| `SelectProps`         | 0.3.0 | `props` of a `select`: `{ options: ChatComponentOption[] }`                                                                                                                                                                                                   |
| `CardProps`           | 0.5.0 | `props` of a `card`: `{ title, subtitle?, fields? }`, where `fields` is an array of `{ label, value }`                                                                                                                                                        |

## API responses

These describe what the widget reads from the REST API. They are exported for code that inspects the
same data; the REST reference has the full shapes.

| Type                      | Since | What it is                                                                                                                                                                                                                                                                                                                        |
| ------------------------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Thread`                  | 0.0.1 | `{ id, createdAt, title }`                                                                                                                                                                                                                                                                                                        |
| `ListThreadsResponse`     | 0.0.1 | `{ threads: Thread[] }`                                                                                                                                                                                                                                                                                                           |
| `MessagesResponse`        | 0.0.1 | A thread's messages: `{ messages }`, each `{ id, role, content, components? }` (`components` from 0.3.0). See [Chat](/api/chat.md)                                                                                                                                                                                                |
| `CreateRunResponse`       | 0.0.1 | A non-streaming run's reply: `{ message: { id, content } }`                                                                                                                                                                                                                                                                       |
| `CreateRunStreamResponse` | 0.0.1 | One line of a streaming run: the `thread.message.delta`, `thread.message.thinking_delta`, `thread.message.completed`, `thread.message.component`, `thread.tool_call.progress`, `error` and `done` events. See [Streaming](/api/streaming.md). 0.5.0 (not yet released) removes `thread.message.created`, which the API never sent |
| `Assistant`               | 0.0.1 | `{ id, created_at }`                                                                                                                                                                                                                                                                                                              |
| `GetAssistantResponse`    | 0.0.1 | `{ assistant: Assistant }`                                                                                                                                                                                                                                                                                                        |

## Related

- [Chat API](/api/web-sdk/chat-api.md): methods and events
- [Authentication](/api/web-sdk/authentication.md): the session types in use
- [Changelog](/api/web-sdk/changelog.md)
