Overview

The SDK can list EXTERNAL conversations and fetch paginated message history for the current user. These use the REST API under the hood. You need to configure apiUrl and one of: Bearer token (same as WebSocket), API keys, or getRestHeaders() from your backend.
Preferred URLs: The SDK calls GET /api/v1/sdk/conversations and GET /api/v1/sdk/conversations/:id/messages. These paths avoid route conflicts and work with Bearer token or API keys.

When to use

  • Inbox UI: Show “My conversations” and let the user pick one.
  • Message history: Load past messages when opening a conversation, with pagination (cursor + limit).

Configuration

Set apiUrl and one of the following so the SDK can authenticate REST calls: See Installation for full examples.

List conversations

client.conversations.list() returns paginated EXTERNAL conversations for the current user.

Response shape

  • conversations: Array of ConversationListItem (id, type, external_id, participants, updated_at, etc.).
  • pagination: { has_next_page, next_cursor, limit }.

Example: build an inbox list

Fetch message history

After joining a conversation, use conversation.fetchMessages() to load past messages (newest first, paginated).

Response shape

  • messages: Array of MessageHistoryItem (id, conversation_id, sender_id, sender_type, content, message_type, created_at, etc.).
  • pagination: { has_next_page, next_cursor, limit }.

Example: load history when opening a chat

Endpoints used

Query params: limit, cursor, and (when using API keys) external_user_id. When using Bearer token, the backend derives the user from the token; you do not need to pass external_user_id.

Full integration flow

  1. Backend: Issue SDK token via POST /api/v1/apps/:appId/tokens (API key or JWT). Return token to the frontend.
  2. Frontend: Create client with wsUrl, apiUrl, and token (or getRestHeaders).
  3. Connect: await client.connect().
  4. Inbox: await client.conversations.list({ limit: 50 }) and render the list.
  5. Open chat: User selects a conversation → await client.conversations.join(conversationId).
  6. History: await conversation.fetchMessages({ limit: 50 }) and render messages.
  7. Realtime: Subscribe to conversation.on('message', ...), conversation.on('receipt', ...), and send with conversation.sendMessage(content).

Errors

  • If you see “REST not configured”, set apiUrl and one of: token (for Bearer), apiKey+apiSecret, or getRestHeaders.
  • If you get 401 on list or messages, ensure the token is valid and not expired, or that API keys / getRestHeaders are correct.

Next steps

Conversations

Join, leave, sendMessage

Messaging

Real-time messaging

List EXTERNAL (API)

API reference: list conversations

Get messages (API)

API reference: message history