How conversations work
Persistence is automatic. You don’t need to send identifiers. If you omit them, Agent Studio generates a conversation ID and message IDs. It returns the conversation ID in theX-Conversation-Id response header.
You can also supply your own IDs.
This sets the storage key upfront, so you can reference it without reading the header.
Agent Studio automatically:
- Saves every completion request that includes messages, even when you don’t supply IDs.
- Returns the stored conversation ID in the
X-Conversation-Idresponse header. - Generates conversation titles from the first user message (60-character maximum).
- Respects your app’s retention policies (0, 30, 60, or 90 days).
- Supports unauthenticated access, which needs an API key with the
logsACL. - Supports authenticated access, which is user-scoped with a secure JWT.
Control the conversation ID
To set the storage key, add a conversation ID and message IDs to your completion request:Both properties are optional:
id: the conversation identifier (prefix withalg_cnv_for consistency).messages[].id: unique identifier for each message (prefix withalg_msg_).
X-Conversation-Id response header.Unauthenticated conversations
Unauthenticated conversations offer basic persistence without user authentication. Conversations aren’t associated with a user identity: retrieve them with their conversation ID. This approach works well for testing and internal admin tools. It also suits single-tenant apps without user accounts.When to use
- Apps without a backend for authentication: when your app doesn’t have a backend to create secure user tokens.
- Single-tenant apps: all users share the same data, so you don’t need to isolate them.
- Internal admin tools: where all users have full access to all conversations.
- Development and testing: for testing without setting up authentication.
- Prototypes and demos: for proof-of-concept work.
How authenticated scoping works
Include the conversation and message IDs in your request. You don’t need any extra authentication:logs ACL:
Limitations
- No user-specific retrieval: can’t get conversations for one user. You get every conversation for the agent, or none.
- Requires the
logsACL which grants admin-level access. - Not suitable for multi-tenant apps: can’t isolate conversations by user.
- Not recommended for multi-user apps: use authenticated conversations to manage them per user.
Security limitations
Since unauthenticated conversations aren’t associated with user identities, Agent Studio can’t determine which user created them. To associate conversations with users, use authenticated conversations with theX-Algolia-Secure-User-Token header.
The only way to associate a conversation with a user is with the X-Algolia-Secure-User-Token header.
Conversations aren’t tied to any user.Anyone with a conversation ID and proper API key can access it.For multi-tenant SaaS apps, use authenticated conversations to enforce user-scoped data isolation.
Authenticated conversations with secure user tokens
Authentication links each conversation to a specific user. This enables user-scoped retrieval and management. For production apps, use authenticated conversations.Benefits
- User scope: the JWT links conversations to authenticated users.
- User-specific retrieval: users can retrieve only their own conversations. The system filters by user ID.
- Multi-user support: each user in your app gets their own conversation history.
- Memory integration: the same user tokens work for both conversations and memory features.
How to set up
Authenticated conversations need secure user tokens. These tokens link conversations to specific users. For more information, see User authentication.Send authenticated requests
Once you have set up user authentication, include theX-Algolia-Secure-User-Token header in your completion requests:
Retrieve user’s conversations
With a secure user token, users can retrieve only their own conversations (requiressearch ACL):
How user filtering works
When you provide theX-Algolia-Secure-User-Token header:
- Token validation: Agent Studio validates the JWT signature using your secret key (HS256 algorithm).
- User extraction: Agent Studio extracts the user ID from the token’s
sub(subject) claim. - User scope:
- For creation: the backend links the conversation to the authenticated user from the JWT.
- For retrieval: queries return only conversations linked to that user ID.
- Automatic scoping: the server scopes every conversation operation to the authenticated user. This relies on the signed token.
- User identity comes only from the
X-Algolia-Secure-User-Tokenheader. - There’s no way to provide a user ID in the request body or query parameters.
- Clients can’t provide an arbitrary user ID. It must come from a signed JWT that only your backend can create.
ACL requirements by mode
Use authenticated mode with the
search ACL for production apps.
This lets you scope retrieval by user and avoid exposing admin-level API keys.Retrieve conversation history
Agent Studio provides several endpoints to retrieve and manage conversation history.List conversations
Retrieve a paginated list of conversations with optional date filtering:Response structure
JSON
Get single conversation
Retrieve a complete conversation including all messages:- Conversation metadata (title, timestamps, token counts).
- All messages with roles, content, and tool calls.
- Message IDs and timestamps.
- Token usage per message.
Manage retention and exports
Control retention and manage conversations in bulk with filtering, export, and deletion.Retention policies
Conversations respect your app’s retention setting: 0, 30, 60, or 90 days. Agent Studio deletes conversations when the retention period expires. Export conversations you need to keep before then. With a retention of 0 days, Agent Studio processes conversations as normal but doesn’t store them. Use this for apps that need real-time processing without persistence.Filtering and export
Filter conversations by date range and export in bulk:Auto-generated titles
Agent Studio automatically generates conversation titles from the first user message:- Maximum length: 60 characters.
- Generation timing: Agent Studio generates titles after the first user message.
- Fallback: if generation fails, the title falls back to the conversation ID.
Integration with memory
Secure user tokens enable both conversations and memory features:- Same authentication: one token works for both features.
- User isolation: Agent Studio scopes both conversations and memories to the authenticated user.
- Unified experience: users get custom agents with both conversation history and memory.
See also
- How memory works and when to use it, see Memory overview
- Add Agent Studio to your app, see Integration
- Recommended security configuration, see Security