Skip to main content

Overview

Tag conversations with a userId to track per-user chat history. Once a conversation is associated with a user, you can list all of that user’s conversations and continue any of them by passing the conversationId.

Setting a User ID

Pass userId when creating a new conversation. The ID must follow these constraints:
ConstraintValue
Max length128 characters
Allowed charactersa-z, A-Z, 0-9, ., _, -
When appliedOnly on conversation creation (no conversationId in request)
MutabilityImmutable — cannot be changed or removed after creation
A conversation’s userId is set once at creation and cannot be changed. If you send userId with a conversationId, the userId field is ignored.
The response metadata includes the userId:

Continuing a Conversation

To send follow-up messages in the same conversation, pass the conversationId from a previous response:
The conversationId is returned in the streaming finish event’s metadata or in the non-streaming response’s metadata object. See Streaming for details.
If the conversation has ended (e.g. after a human takeover), the API returns a CHAT_CONVERSATION_NOT_ONGOING error. Start a new conversation instead.

Listing a User’s Conversations

Retrieve all conversations for a specific user with GET /api/v2/agents/{agentId}/users/{userId}/conversations.

Path Parameters

ParameterTypeDescription
agentIdstringThe agent ID.
userIdstringThe user ID to list conversations for.

Query Parameters

ParameterTypeDefaultDescription
cursorstringOpaque cursor from a previous response. Omit to start from the beginning.
limitinteger20Number of items per page. Range: 1–100.

Response

Response Fields

FieldTypeDescription
idstringConversation ID.
titlestring | nullConversation title.
createdAtnumberUnix epoch timestamp (seconds).
updatedAtnumberUnix epoch timestamp (seconds) of last activity.
userIdstring | nullThe user ID associated with this conversation.
statusstringConversation status: ongoing, ended, or taken_over.

Pagination Examples

Full Example

1

Start a conversation with a user ID

Send the first message with a userId to associate the conversation:
Save the conversationId from the finish event.
2

Send a follow-up message

Continue the conversation by passing the conversationId:
3

List the user's conversations

Retrieve all conversations for the user:

Exporting All Conversations

The Export conversations endpoint returns all conversations with full message history, regardless of source. This is different from the list endpoints above, which only return API-created conversations.

Key differences from list endpoints

List conversationsExport conversations
SourcesAPI-onlyAll (Widget, WhatsApp, Messenger, API, etc.)
MessagesNot included (metadata only)Full message history included
Tool resultsNot included (metadata only)Sanitized — internal data stripped
Tool call inputNot included (metadata only)Omitted (not useful for export consumers)

Conversation sources

Exported conversations include a source field indicating where the conversation originated: API, WhatsApp, Messenger, Instagram, Slack, Salesforce, Zendesk, Zendesk Messaging, Widget or Iframe, Iframe, Email, Agent page, Phone, Android SDK, iOS SDK, Chatbase site, Playground, and others.

Message format

Each conversation includes a messages array. Messages contain parts, which can be:
Part typeFieldsDescription
texttype, textText content from the user or assistant
tool-calltype, toolCallId, toolNameA tool invocation by the agent (input is omitted in exports)
tool-resulttype, toolCallId, toolName, outputThe sanitized result of a tool invocation

Tool result output shape

All tool results in the export follow a unified shape, so you can handle them with a single switch on status:
StatusShapeDescription
success{ status: "success", data?: <T> }Tool completed successfully. data is present when there is a meaningful payload.
error{ status: "error", error?: string }Tool encountered an error.
pending{ status: "pending" }Tool execution is still in progress.
ignored{ status: "ignored" }Tool was skipped by the user.

Example response

Paginating through all exports

The export endpoint can return large amounts of data. Use a smaller limit (e.g., 20) if you’re processing messages as they arrive rather than collecting everything in memory.

Streaming

Learn about streaming responses and event types.

Pagination

How cursor-based pagination works across all list endpoints.

Export Conversations

Full API reference for the export endpoint.

Client Actions

How tool calls and tool results work in conversations.