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:
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

Query Parameters

Response

Response Fields

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.
Get a conversation also only returns conversations created through the API. If you request a conversation that exists but came from another source, its 404 response names the source and points you to the export endpoint below instead.

Key differences from list endpoints

Fetching a single conversation

Pass conversationId as a query parameter to fetch one conversation instead of paging through the full export. This works for a conversation from any source, including ones created through the widget, WhatsApp, or other integrations, not just the API.
The response keeps the normal paginated shape, with a single item in data:
If no conversation matches the ID, the response is a normal empty page (data: [], total: 0), not a 404.

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.

Embed origin

Conversations started on your website, such as from the chat bubble, iframe, or Center Stage, include embedOrigin, the URL of the page the AI agent was embedded on when the conversation started, without its query string, for example https://www.example.com/pricing. It contains only the origin, for example https://www.example.com, when the browser didn’t report the page path. It is null for other sources, for conversations started before this field existed, and when the browser didn’t report the site.

Message format

Each conversation includes a messages array. Messages contain parts, which can be:

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:

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.