Skip to main content
Chat authentication is handled by the underlying Pub/Sub SDK. You authenticate an Ably Realtime client, then pass that authenticated client into ChatClient.

Authentication Flow

  1. Your auth server authenticates the user
  2. Your auth server issues an Ably-compatible token (JWT format is recommended for most apps)
  3. The client SDK fetches tokens with authCallback and refreshes them automatically before expiry
  4. The authenticated Pub/Sub client is passed into ChatClient

Server Setup

Create an endpoint that validates user-provided credentials and returns JWTs with the appropriate Chat capabilities:

Client Setup

Chat Capabilities

Capabilities are permissions that control what operations a client can perform:
FeatureRequired Capabilities
Send messagespublish
Receive messagessubscribe
Update messagesmessage-update-any or message-update-own
Delete messagesmessage-delete-any or message-delete-own
Message historysubscribe, history
Message reactionsannotation-publish, optionally annotation-subscribe
Presencesubscribe, presence
Typing indicatorspublish, subscribe
Room reactionspublish, subscribe
Occupancysubscribe, channel-metadata

Room-scoped Capabilities

You can scope capabilities to specific rooms, a namespace of rooms, or all rooms:
  • my-chat-room - a specific room
  • dms:* - all rooms in the dms: namespace
  • * - all chat rooms

Next Steps

Build docs developers (and LLMs) love