Chat SDK quickstart

In-app messaging for your app with no backend needed: add your App Key, connect, and get 1:1 and group chat, live-stream rooms, media and voice notes, receipts, push and call invites. The first 1,000 monthly active users are free.

Chat is self-serve. Turn it on in the console under Chat; you start on the Free plan (1,000 monthly active users, no charge). Product overview and pricing: Chat SDK.

Set in your dashboard vs. set in code

SettingWhere
App Key, its bindings (package name, bundle ID, website, signing certificate) and Quick-mode capsDashboard: Console → Projects → Quick mode
Chat push credentials (FCM, APNs), profanity filter and word list, recall window, webhook eventsDashboard: Console → Chat
Chat plan (Free, Pay as you go)Dashboard: Console → Chat
Chat token lifetimeCode: Quick mode handles it for you; with server tokens, ttl_seconds (60 to 604800 seconds)
Live-room slow mode and freezeCode: your server (PATCH /v1/chat/rooms/{room_id})
Who the user is (user id, display name)Code: init / setUser in the app

0. Turn chat on

Console → Chat → Turn on chat. To go past 1,000 MAU, switch to Pay as you go on the same page; chat is then billed per MAU from your prepaid balance.

Quick mode: add your App Key, chat in 5 minutes

No backend needed: add your App Key in the app and start calling. A server is optional, for production hardening.

  1. Get your App Key. In the console, open Projects → Quick mode and add your app's website address, package name or bundle ID. Your App Key is shown there.
  2. Install the package.
    terminal
    # the chat package from your console (SDK downloads or a Support ticket)
    npm install ./vendor/titli/titli-chat-0.1.0.tgz
  3. Init with the App Key, then start or join a conversation. That is all: no server, no tokens.
    chat.js
    import { TitliChat } from '@titli/chat';  // the chat package from your console
    
    // Your App Key and your own user id. connect() needs no token:
    // the SDK fetches the chat token itself and refreshes it before it expires.
    const chat = TitliChat.init({ appKey: 'tak_…', userId: 'user-42' });
    await chat.connect();

The App Key is publishable, not a secret: it can only reach the app-facing routes, it is bound to your package name, bundle ID or website, and spend and usage caps fence it. The binding is a deterrent, not a lock (a determined attacker can copy an app's identity), so the caps are what limit the damage. For strict control, add server tokens (production hardening below). Quick mode: bindings, caps and error codes · Read the Client API (Quick mode).

Behind connect() the SDK asks for the chat token with your App Key (POST /v1/chat/client/tokens), refreshes it before it expires and whenever the server asks, and saves the user's own profile with PUT /v1/chat/client/users/{user_id}. Both are documented in the Client API (Quick mode). userId is your own id for the person: 1 to 128 characters from A-Z a-z 0-9 _ . : @ -.

The same two lines in the other SDKs:

lib/chat.dart
final chat = await TitliChat.init(appKey: 'tak_…', userId: 'user-42');
await chat.connect(); // no token: the SDK fetches and refreshes it

2a. Web and React Native: the JavaScript core

Package @titli/chat. TypeScript types are included. It is not on npm yet: ask support for the package file and install it by path (npm install ./titli-chat-0.1.0.tgz); the same file is inside the React Native archive under SDK downloads in the console. The import name below is the name it installs under.

chat.js
import { TitliChat } from '@titli/chat';

// Quick mode: your App Key and your own user id. No backend needed.
const chat = TitliChat.init({ appKey: 'tak_…', userId: 'u_42', userName: 'Asha' });
await chat.connect();                             // no token: the SDK fetches and refreshes it

const conv = await chat.openDirect('u_99');      // or chat.createGroup({ name, members })
chat.sendText(conv.id, 'Hello!');                 // optimistic; queued offline, retried, deduped
chat.on('message.new', (m) => console.log(m.sender, m.text));
await chat.loadMessages(conv.id);                 // newest 30; { before_seq } for older pages
chat.markRead(conv.id);                           // read receipts + unread reset
chat.sendImage(conv.id, file, { width, height }); // uploads, then sends
chat.typing(conv.id);                             // throttled for you
chat.js
await chat.conversations.refresh();                 // chat.conversations.list() with unread_count
chat.sendVoice(conv.id, blob, { duration_ms, waveform });
await chat.subscribePresence(['u_99']);              // 'presence' events
chat.setUser('u_43', 'Ravi');                         // another person signs in on this device

React Native: pass storage: AsyncStorage to init so the offline queue survives restarts, and platform plus app (your package name or bundle ID, as bound to the App Key). File inputs may be { uri, type, name }. The React UI kit is DOM-based, so on React Native you build the screens with your own views.

chat.ts
import AsyncStorage from '@react-native-async-storage/async-storage';
import { TitliChat } from '@titli/chat';

// Same JS core; AsyncStorage keeps the offline queue across restarts.
// platform + app: the X-Titli-Platform and package name / bundle ID your App Key is bound to.
const chat = TitliChat.init({ appKey: 'tak_…', userId: 'u_42', platform: 'android', app: 'com.example.app', storage: AsyncStorage });
await chat.connect();
chat.sendImage(conv.id, { uri, type: 'image/jpeg', name: 'photo.jpg' });

2b. React chat UI kit

Package @titli/chat-react. One component renders the whole inbox: conversation list, chat window (bubbles, images, files, voice notes with record and play, reactions, replies, edit and recall, receipts, typing, date separators), call-invite buttons and the incoming-call banner. <ChatProvider appKey userId> also makes a Quick-mode client for you.

Inbox.jsx
import '@titli/chat-react/dist/titli-chat.css';
import { TitliChatUI } from '@titli/chat-react';

// chat = TitliChat.init({ appKey, userId }) and connect(), as above
// The whole inbox: conversation list, chat window, call-invite buttons, incoming-call banner
<TitliChatUI client={chat} theme="auto" onCall={({ type, accepted }) => startTitliCall(type)} />

It is responsive (split view on desktop, stacked on phones) with light, dark and auto themes. Theme it with CSS variables on .tc-root (--tc-accent, --tc-mine, --tc-radius, --tc-font) or accent="#0ea5e9". Building blocks: ConversationList, ChatWindow, CallInviteButton, IncomingCallBanner, Avatar, and the hooks useConversations, useMessages, useTyping, usePresence, useIncomingCall.

2c. Flutter chat SDK

Package titli_chat. Core only: import 'package:titli_chat/titli_chat.dart';. Widgets and core: package:titli_chat/titli_chat_ui.dart.

lib/chat.dart
import 'package:titli_chat/titli_chat_ui.dart';

// Quick mode: your App Key and your own user id. No backend needed.
final chat = await TitliChat.init(appKey: 'tak_…', userId: 'u_42');
await chat.connect(); // no token: the SDK fetches and refreshes it

// Prebuilt screens
TitliConversationsScreen(
  onOpen: (c) => Navigator.push(context,
    MaterialPageRoute(builder: (_) => TitliChatScreen(conversation: c))),
);

Theme with TitliChatTheme.light() or .dark() and .copyWith(...). The package README covers voice notes, attachment pickers and push.

2d. Native iOS, Android and React Native: beta, request access

Beta 0.1.0, on request. The native chat SDKs are not on a public Git host or package registry. To get one, open SDK downloads in the console and press Request access; after approval you download the versioned archive there, with its checksum, changelog and install steps for your App ID. You can also ask for access on WhatsApp or hello@titliapp.com. Testing so far was on emulators and on macOS; push notifications on real devices are not verified yet.

PlatformWhat you getQuickstart
iOS (Swift, SwiftUI)TitliChat, TitliChatUI, TitliChatCallsiOS chat quickstart
Android (Kotlin, Jetpack Compose)titli-chat, titli-chat-ui, titli-chat-callsAndroid chat quickstart
React Native (UI kit)@titli/chat-react-native on top of the JS coreReact Native chat quickstart

Each has a core, a UI kit, push registration and a bridge that opens the Titli Video SDK call screen from a chat call invite. All of them take the App Key the same way (Quick mode).

3. Push notifications for offline users

Console → Chat → Push: upload your Firebase service-account JSON (Android and web) and your APNs .p8 key (iOS). They are stored encrypted. Then register the device token in the app:

push.js
// Register the device token after connect
chat.registerPush('fcm', fcmToken);                    // JS: Android, web ('apns' for an iOS device token)
// Flutter (Dart): named arguments
// await chat.registerPush(platform: 'apns', token: token);

// Payload your app receives (all values are strings)
// message: { titli_chat: "1", kind: "message", cid, seq, sender, title, body }
// call:    { titli_chat: "1", kind: "call_invite", invitation_id, sender, cid, title, body }

chat.unregisterPush(fcmToken);                         // on sign-out

A push is sent only when the user has no live connection, the conversation is not muted and the sender is not blocked. Pushes for one conversation within 3 seconds collapse into one.

4. Calls with the Titli Video SDK

Chat carries the invitation; the Video SDK carries the media. With both in Quick mode there is no backend at all: the caller starts the call with TitliVideo.startCall, sends its callId in the invite's data, and the callee joins with TitliVideo.joinCall.

call-invite.js
// Chat carries the invitation; the Titli Video SDK carries the media.
// Quick mode on both: TitliVideo.init({ appKey, userId }) once, like the chat.
// caller: start the call (you are the caller and the payer), then ring
const call = await TitliVideo.startCall({ type: 'video', container: '#stage' });
const inv = await chat.inviteCall('u_99', { timeout_s: 30, data: { type: 'video', call_id: call.callId } });
// chat.cancelCall(inv.invitation_id) stops the ringing; 'call.rejected' and
// 'call.timeout' (after timeout_s) tell you nobody picked up: then TitliVideo.calls.end(call.callId)

// callee: gets 'call.invite' (and a push if the app has no live connection)
chat.on('call.invite', (invite) => {
  showRinging(invite.inviter_name || invite.inviter, invite.data.type);
  // Accept:  await chat.acceptCall(invite.invitation_id);
  //          await TitliVideo.joinCall(invite.data.call_id, { container: '#stage' });
  // Decline: await chat.rejectCall(invite.invitation_id, 'busy');
});

Video SDK Quick mode setup: video quickstart. The native call bridges (iOS, Android, React Native) do this for you when the chat was made with an App Key.

5. Live-stream rooms

Joining and sending work from the app with the App Key. Slow mode, freeze and host messages are server-only (they need the API key secret), so add them when you add a server.

live-room.js
await chat.joinRoom('live_123');                 // the last 50 messages for late joiners
await chat.sendRoomMessage('live_123', 'hi!');   // rate limited per user
chat.on('message.new', (m) => render(m));        // room messages arrive like any other

Production hardening (optional): server tokens

You do not need a server to start: Quick mode works with the App Key alone. Add a server when you want strict control over every call (who joins which call, for how long, in which role): keep the project key on your server and mint a short-lived join token per person there. The app uses the same SDK and hands it a token instead of the App Key. Both ways can run side by side.

For chat this means: your server mints the chat token with HTTP Basic auth (key_id:key_secret), and the app connects with that token instead of the App Key. The call also creates or updates the user's profile.

terminal
# Optional (production hardening): your server mints a short-lived chat token for one of your users
curl -u "$KEY_ID:$KEY_SECRET" https://api-videosdk.titliapp.com/v1/chat/tokens \
  -H 'Content-Type: application/json' \
  -d '{"user_id":"u_42","name":"Asha","avatar_url":"https://cdn.example.com/a.jpg","ttl_seconds":3600}'
# -> {"token":"eyJ...","user_id":"u_42","expires_at":"...","ws_url":"wss://.../chat/ws","api_url":"https://..."}

ttl_seconds can be 60 to 604800 (default 3600). When a token expires the server closes the connection with code 4001; the SDK then calls your tokenProvider and reconnects. A token works only on the environment that minted it.

chat.js
// Production hardening: same SDK, but the token comes from YOUR server (step above)
const fetchChatToken = () =>
  fetch('/chat-token', { method: 'POST' }).then((r) => r.json()).then((j) => j.token);

const chat = TitliChat.init({ apiUrl: 'https://api-videosdk.titliapp.com' });
// tokenProvider runs again whenever the token expires
await chat.connect(await fetchChatToken(), { tokenProvider: fetchChatToken });

Calls: with server tokens, your server creates the call and the join tokens exactly as in the video quickstart (production hardening there), and the apps join with them.

Common errors and what to do

You seeWhyFix
APP_KEY_INVALID (AK-401)App Key missing, wrong, rotated away or disabledCopy the current key from Console → Projects → Quick mode
APP_NOT_ALLOWED (AB-403)Your package name, bundle ID or website is not on the key's listAdd it under Console → Projects → Quick mode
QUICK_MODE_OFF (QM-403)Quick mode is off for the projectTurn it on under Console → Projects → Quick mode, or use server tokens
403 chat_disabledChat is not on for the accountConsole → Chat → Turn on chat
401 invalid_api_key or unauthorized (server tokens)Wrong key, or no Basic auth headerSend key_id:key_secret of the same project as HTTP Basic auth
400 invalid_request: user_id must be…No Content-Type: application/json, or an id with other charactersSend JSON; ids use A-Z a-z 0-9 _ . : @ -
connect() fails with unauthorized (close code 4001)The token expired, or it was minted on another environmentQuick mode refreshes by itself; with server tokens pass tokenProvider and mint and connect against the same API URL
connect() fails with banned, chat_disabled, cap_reached or payment_required (close code 4003)User banned, chat off, the Free plan's 1,000 MAU reached, or the balance is empty for a new userNot retryable from the app; fix it in the console
Close code 4029More than 10 connections for one user, or the plan's concurrent-connection capCall disconnect() on sign-out; upgrade the plan
not_memberThe user is not in that conversation, or a room send before joinRoomopenDirect, add the member, or joinRoom first
rate_limited, slow_modeSending too fastWait retry_after_ms; queued sends retry by themselves
No push arrivesNo FCM or APNs credentials in the console, the user still has a live connection, the conversation is muted, or the token was not registered after connectCheck each; a connected user never gets a push

Every code: errors in the API reference and the Client API for the Quick-mode codes.

Next

Start free