Skip to main content

Anonymous Chat

Once a build is ready, visitors chat with the agent using its public slug. This is the existing anonymous public surfaceno API key, slug-based, with anonymousId sessions and optional SSE streaming. Because no secret is involved, the browser calls these endpoints directly (no backend proxy needed for chat).
anonymousId MUST be a UUID (e.g. crypto.randomUUID()). Generate one per visitor, persist it (e.g. localStorage), and reuse it across the conversation.

Create Conversation

Start a conversation and (if configured) receive a welcome message.

Path Parameters

string
required
The agent’s public slug — the agentSlug from the ready event.

Request Body

string
required
A UUID identifying the anonymous visitor session.

Response (200)

boolean
Request status.
object
Response (200):

Send Message

Send a message in a conversation. Returns a full response, or an SSE token stream when stream: true.

Path Parameters

string
required
The agent’s public slug.

Request Body

string
required
The visitor’s message.
string
required
The UUID returned by create-conversation.
string
required
The same UUID used to create the conversation.
boolean
default:"false"
Set true to receive an SSE token stream instead of a single JSON response.
array
Up to 5 files to attach to this message. Each item is { id, accessToken } returned by Upload Attachment. Only available when the agent has file uploads enabled.

Response (200) — non-streaming

string
The agent’s reply.
string
The conversation UUID.
object
Token usage and cost info.

Streaming (SSE)

Add "stream": true to receive a token stream. The browser can read it directly with a fetch body reader:
Browser — streaming

Upload Attachment

Upload a file from the browser to attach to a chat message. Anonymous and slug-scoped — no API key. Only works when the agent has file uploads enabled; otherwise returns 403. Send the file as multipart/form-data under the field name file, with the visitor’s anonymousId in the query string.

Path Parameters

string
required
The agent’s public slug.

Query Parameters

string
required
The visitor’s UUID (the same one used for conversations).

Request

multipart/form-data with a single file part. Limits: max 5 files per message, size + type enforced server-side (images, PDF, text, audio, video). Content is magic-byte sniffed, so a file whose bytes don’t match its declared type is rejected (415).

Response (200)

object
{ id, accessToken, fileType, originalFilename, fileSizeBytes, contentType, processingStatus, createdAt }. Pass { id, accessToken } in the chat message’s attachments array.
Uploads are rate-limited per IP and per anonymousId. The accessToken is a per-upload secret returned only to the uploader — it’s the ownership proof when you reference the attachment in a message, so don’t expose it elsewhere.

List Conversations

List the conversations belonging to an anonymous visitor for this agent.

Path Parameters

string
required
The agent’s public slug.

Query Parameters

string
required
The visitor’s UUID (the same one used to create the conversations).
number
default:"20"
Maximum results.
number
default:"0"
Pagination offset.

Response (200)

object[]
Array of the visitor’s conversations.
object

Get Messages

Retrieve the messages in one of the visitor’s conversations.

Path Parameters

string
required
The agent’s public slug.
string
required
The conversation UUID.

Query Parameters

string
required
The visitor’s UUID (the same one used to create the conversation).
number
default:"50"
Maximum results.
number
default:"0"
Pagination offset.

Response (200)

object[]
Array of message objects in the conversation.

Rename Conversation

Rename one of the visitor’s conversations.

Path Parameters

string
required
The agent’s public slug.
string
required
The conversation UUID.

Request Body

string
required
The visitor’s UUID (the same one used to create the conversation).
string
required
The new conversation title. 1–80 characters.

Response (200)

object
The updated conversation object.

Delete Conversation

Delete one of the visitor’s conversations. This is how a visitor clears one conversation from their history.

Path Parameters

string
required
The agent’s public slug.
string
required
The conversation UUID.

Query Parameters

string
required
The visitor’s UUID (the same one used to create the conversation).

Response (200)

boolean
true on success.

Operator Presence (SSE)

Subscribe to real-time operator-presence / human-in-the-loop events for a conversation — operator messages, takeover/join, and resolution. Use EventSource (the anonymousId rides in the query string since EventSource can’t set headers); the server validates that the visitor owns the conversation.

Query Parameters

string
required
The visitor’s UUID (must own the conversation).

Stream

text/event-stream. The first event is {"type":"connected"}; subsequent data: events carry operator/HITL payloads (e.g. {"type":"operator_message", ...}, {"type":"operator_joined", ...}, {"type":"hitl_resolved", ...}).
Browser / TypeScript
This is the visitor side. The chat-core PublicTransport.subscribeEvents wires it automatically. The operator side (sending messages, taking over) runs through the authenticated HITL operator dashboard.

Notes

  • The browser calls these endpoints directly — no brs_live_ key, no backend proxy. Only provisioning is gated.
  • Any per-visitor message cap (e.g. an email gate after N messages) is a client UX concern, not an API limit.
  • Seed the chat UI with the starterQuestions from the ready ProvisioningEvent.