Skip to main content

Overview

The SDK supports two layers of identity: The SDK works anonymously out of the box. Call identify() to associate conversations with a specific user.

Device ID

Every SDK instance has a stable device ID, generated automatically on creation:
The device ID uses Android’s Settings.Secure.ANDROID_ID when available. On emulators or when restricted, it falls back to a UUID persisted in SharedPreferences (chatbase_sdk_prefs). The ID remains stable across app launches.

identify

interface ChatbaseClientPackage: com.chatbase.sdk
Verify a JWT token with the Chatbase server and identify the current user. Subsequent requests are associated with this user. identify() is equivalent to verify() — it verifies the token server-side and triggers the anonymous-conversation merge.
String
required
A JWT generated by your backend and signed with your agent’s identity verification secret. The payload must include a user_id (or sub) claim.
1

Generate a JWT on your backend

Create a signed JWT token on your server containing the user ID in its payload.
2

Pass the token to the SDK

Conversations are now scoped to this user.
3

Check identity status

Identity Properties

Auto-generated device ID. Always available.
true if a JWT token has been set via identify().
User ID confirmed by the server when the token was verified. null if not identified.

verify

Verify a JWT token with the Chatbase server. On success, the server also merges any conversations created anonymously (with the device ID) into the verified user’s account. identify() is an alias for this method.
String
required
The JWT token to verify.
When verify() succeeds, the server automatically merges previously anonymous (device-scoped) conversations into the verified user’s account. Conversations started before identification are preserved and accessible under the user’s identity.The merge runs asynchronously on the server — a listConversations() call issued immediately after verify() returns may not reflect it yet.

How Identity Affects Conversations

When identified, conversations are scoped to the user — listConversations() returns only that user’s conversations. Without identity, conversations are scoped to the device.

logout

Clear the JWT token and return to anonymous (device-scoped) mode. Also clears the current conversation ID so the next message starts a fresh anonymous conversation.
identify() and verify() are equivalent — both verify the token with the server and trigger the merge of prior anonymous (device-scoped) conversations into the user’s account. You never need to call both.

Conversations & History

List conversations and load message history

Overview

SDK setup and configuration