User IDs
TheX-External-User-Id header identifies the specific user making a request. This enables per-user features like conversation history and usage tracking.
What is a User ID?
A user ID is a string you provide that uniquely identifies a user within an organization. Each user gets:- Personal conversation history - Their chat sessions are preserved
- Individual usage tracking - Analytics and billing per user
- Separate context - Conversations don’t mix between users
How It Works
Each user has their own set of conversations. When Alice asks a follow-up question, she sees her previous messages. Bob sees only his own history.Choosing User IDs
Use identifiers that are:- Unique within each org - Two users in the same org need different IDs
- Stable - Don’t change after creation
- Tied to your user system - Easy to map to your users
Good Examples
| Your System | User ID |
|---|---|
| Database ID | user_12345 |
| UUID | 550e8400-e29b-41d4-a716-446655440000 |
[email protected] | |
| Username | alice.smith |
Same User ID, Different Orgs
The same user ID in different organizations are separate users:Per-User Conversation History
Users automatically get persistent conversation history:Per-User Usage Tracking
Track usage at the individual user level:- Per-seat billing - Charge based on active users
- Usage analytics - Understand adoption patterns
- Audit trails - Track who accessed what
User Lifecycle
User Creation
Users are created implicitly on first request:Mapping to Your Users
A common pattern is to use your authentication system to populate the header:Best Practices
Use your existing user identifiers
Use your existing user identifiers
Map to your authentication system’s user IDs for easy correlation.
Keep user IDs stable
Keep user IDs stable
Changing a user’s ID would orphan their conversation history.
Don't use PII as user IDs
Don't use PII as user IDs
While emails work, consider using opaque IDs for privacy.
Validate user-org relationships
Validate user-org relationships
Ensure users can only access organizations they belong to in your system.