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
| Setting | Where |
|---|---|
| App Key, its bindings (package name, bundle ID, website, signing certificate) and Quick-mode caps | Dashboard: Console → Projects → Quick mode |
| Chat push credentials (FCM, APNs), profanity filter and word list, recall window, webhook events | Dashboard: Console → Chat |
| Chat plan (Free, Pay as you go) | Dashboard: Console → Chat |
| Chat token lifetime | Code: Quick mode handles it for you; with server tokens, ttl_seconds (60 to 604800 seconds) |
| Live-room slow mode and freeze | Code: 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.
- 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.
- 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 - 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:
final chat = await TitliChat.init(appKey: 'tak_…', userId: 'user-42');
await chat.connect(); // no token: the SDK fetches and refreshes itconst chat = createTitliChat({ appKey: 'tak_…', userId: 'user-42', appId: 'com.example.app' }); // appId: your bundle ID / package name
await chat.connect(); // no token: the SDK fetches and refreshes itval chat = TitliChat.init(applicationContext, appKey = "tak_…", userId = "user-42")
chat.connect() // no token: the SDK fetches and refreshes itlet chat = TitliChat(appKey: "tak_…", userId: "user-42")
try await chat.connect() // no token: the SDK fetches and refreshes it2a. 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.
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 youawait 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 deviceReact 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.
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.
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.
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.
| Platform | What you get | Quickstart |
|---|---|---|
| iOS (Swift, SwiftUI) | TitliChat, TitliChatUI, TitliChatCalls | iOS chat quickstart |
| Android (Kotlin, Jetpack Compose) | titli-chat, titli-chat-ui, titli-chat-calls | Android chat quickstart |
| React Native (UI kit) | @titli/chat-react-native on top of the JS core | React 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:
// 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-outA 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.
// 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.
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# Optional, from your server (server-only: needs the API key secret)
# Slow mode or freeze a room
curl -u "$KEY_ID:$KEY_SECRET" -X PATCH https://api-videosdk.titliapp.com/v1/chat/rooms/live_123 \
-H 'Content-Type: application/json' -d '{"slow_mode_s": 10, "frozen": false}'
# A host or system message (no rate limit)
curl -u "$KEY_ID:$KEY_SECRET" https://api-videosdk.titliapp.com/v1/chat/rooms/live_123/messages \
-H 'Content-Type: application/json' -d '{"sender":"host_1","sender_name":"Host","type":"text","text":"Welcome!"}'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.
# 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://..."}// server.js (optional, production hardening): the API key secret never ships in an app
app.post('/chat-token', auth, async (req, res) => {
const r = await fetch('https://api-videosdk.titliapp.com/v1/chat/tokens', {
method: 'POST',
headers: {
Authorization: 'Basic ' + Buffer.from(`${KEY_ID}:${KEY_SECRET}`).toString('base64'),
'Content-Type': 'application/json',
},
// req.user comes from YOUR login (the auth middleware), never from the request body
body: JSON.stringify({ user_id: req.user.id, name: req.user.name }),
});
const j = await r.json();
if (!r.ok) return res.status(502).json({ error: j.error?.code }); // e.g. chat_disabled, invalid_api_key
res.json({ token: j.token, expires_at: j.expires_at });
});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.
// 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 });// Production hardening: the token comes from your server
await TitliChat.init(apiUrl: 'https://api-videosdk.titliapp.com');
await TitliChat.instance.connect(token, 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 see | Why | Fix |
|---|---|---|
APP_KEY_INVALID (AK-401) | App Key missing, wrong, rotated away or disabled | Copy 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 list | Add it under Console → Projects → Quick mode |
QUICK_MODE_OFF (QM-403) | Quick mode is off for the project | Turn it on under Console → Projects → Quick mode, or use server tokens |
403 chat_disabled | Chat is not on for the account | Console → Chat → Turn on chat |
401 invalid_api_key or unauthorized (server tokens) | Wrong key, or no Basic auth header | Send 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 characters | Send 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 environment | Quick 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 user | Not retryable from the app; fix it in the console |
| Close code 4029 | More than 10 connections for one user, or the plan's concurrent-connection cap | Call disconnect() on sign-out; upgrade the plan |
not_member | The user is not in that conversation, or a room send before joinRoom | openDirect, add the member, or joinRoom first |
rate_limited, slow_mode | Sending too fast | Wait retry_after_ms; queued sends retry by themselves |
| No push arrives | No 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 connect | Check 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
- Chat API reference: every REST endpoint, the WebSocket operations, events, errors and webhooks.
- Client API (Quick mode): what the SDK calls with your App Key.
- Native beta quickstarts (on request): iOS, Android, React Native.
- Chat pricing: the MAU bands and worked examples.