SupaKnock
Menu
Browse topics Chat for signed-in users
← Developer reference

Connect your app

Chat for signed-in users

Connect your app’s login to customer conversations.

Enable chat for the project first. Your backend then exchanges its participate credential and verified user ID for short-lived customer access.

POST /api/v1/chat/projects/your-project/customer-sessions
Authorization: Bearer <project-secret>
Content-Type: application/json

{
  "external_user_id": "your-verified-user-id",
  "client_type": "browser",
  "origin": "https://www.example.com"
}

Make this exchange on your server, without an Origin header. The JSON origin must match an enabled website. For a native customer app, use "client_type":"native" and omit the JSON origin.

  1. Return only the resulting cc_ token and expiry to the client. Subsequent calls use X-Chat-Token; browser fetches use credentials: 'omit'.
  2. GET /api/v1/chat/conversations lists that customer's history. To start one, POST there with client_conversation_id, a UUID retained across retries.
  3. POST to /api/v1/chat/conversations/{id}/messages with a UUID client_message_id and body. Retry an unacknowledged send with the same ID and body; conflicting reuse returns 409.
  4. Read messages with ?after=0&limit=25; pass the returned next_sequence as the next after. POST {"sequence":…} to the conversation's /read path after viewing them.

Tokens last one hour. Renew through your authenticated backend; history and message retry identity survive renewal. DELETE /api/v1/chat/session revokes the current customer token. Your app's logout must explicitly end its chat access.

Live updates

POST the conversation ID to /api/v1/chat/tickets, then connect to /api/v1/chat/ws. Send the one-use ticket in the first frame, never in the URL. Tickets last 60 seconds. The OpenAPI document's x-websockets section describes frames and reconnect cursors; HTTP history can also catch up after disconnection.

The supplied widget below uses anonymous visitor sessions. It does not automatically use your app's login or merge an anonymous chat into an account. Build your own customer UI for authenticated history; the repository's docs/chat.md includes the complete flow.

These docs describe the current source. Check your server’s /api/v1/openapi.json for the version you run.