Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Chat history

Load past messages for a conversation thread with fetchChatHistory. On WebSocket clients, the response arrives via onMessage — not as the return value of the method call.


When to fetch

Moment
Action

User opens a thread

fetchChatHistory for the peer ID(s)

App returns from background

Refetch or merge with live messages since last seen

After reconnect

Refetch to fill gaps from offline period


API contract

Field
Description

senderId

The requesting user (must match connected userId)

receiverIds

Array of peer user IDs defining the thread

await notifier.fetchChatHistory({
  senderId: "user-alice",
  receiverIds: ["user-bob"],
});
// Response delivered to onMessage

For 1:1 chat, pass a single peer ID in receiverIds. The server returns messages exchanged between the participants.


Handling the response

History payloads arrive in onMessage. Shape is app-dependent but commonly includes a messages array:

Distinguish history responses from live messages by checking for the messages array or a metadata hint your app recognizes.


HTTP transport note

With transport: "http", fetchChatHistory may return the response directly from the async call instead of routing through onMessage. For chat UIs, prefer ws for unified live + history handling.


Language guides

Language
Guide

JavaScript / TypeScript

Dart / Flutter


Last updated