user_id key in the metadata of the trace’s root run, the same way it groups traces into threads with thread_id. Recording users lets you find every trace for a person who reports a problem, and review each user’s activity, cost, and errors.
The user features on this page are in beta and available on LangSmith Cloud. They are not available on self-hosted LangSmith or BYOC deployments, where
user_id is stored as ordinary metadata.user_id identifies an end user of your application. It is different from ls_user_id, which identifies the LangSmith user the run is attributed to.Record the user on a trace
To record the user, add auser_id key to the metadata of the root run of each trace. The value can be any string that identifies the user in your application. Use the same value for the same user across traces so filtering by user returns all their traces.
The LangSmith SDK copies a run’s metadata to the child runs it creates. When you set user_id on the root run, the SDK records it on every run in the trace. A user_id set on a child run overrides the copied value for that run. If you set user_id only on a child run, the trace top bar does not show a user, and the search bar does not suggest that user ID.
Create an agent once before sending traces. Use agent addressing to select its identifier and environment. If an integration requires
project_name, use the selected environment’s tracer_session_name.tracing_context or a wrapped client, see Add metadata and tags to traces. With LangChain or LangGraph, pass user_id in the metadata field of the run config when you invoke the agent. See Trace LangChain agents.
View the user on a trace
LangSmith shows the user ID in four places:- Tracing table: Turn on the User column from Columns to show each run’s user ID. The LangSmith User column is different: it shows the LangSmith user the run is attributed to.
- Trace top bar: When you open a trace that is not part of a thread, the top bar shows a User chip with the user ID.
- Run header: When a trace belongs to a thread, the header of the selected run shows the user ID recorded on that run. This applies in a thread’s Details view and when you open the trace from the tracing table.
- Trajectory view: Hover over a user message in a thread’s Trajectory view to show the user ID below it. AI messages and tool responses do not show a user.
Filter traces by user
Tracing projects have two filtering experiences. Check the top of your project to see which one applies to you:
- A single search bar with a scope selector to its left: Refer to Filter traces.
- An Add filter button that builds filter chips: Refer to Filter traces (ClickHouse).
user_id shorthand works in the search bar experience. In the Add filter experience, filter on the user_id metadata key.
To find the runs, traces, or threads for one user, enter a user_id clause in the tracing search bar:
user_id is shorthand for metadata.user_id and supports the same operators:
-user_id:user_123matches runs from every other user, including runs with nouser_id.user_id:*matches runs that have auser_idkey.-user_id:*matches runs with nouser_idkey, such as traces you have not instrumented yet.metadata.user_id:user_123matches the same runs asuser_id:user_123.
Review user activity
The Users tab on an agent’s Monitoring page lists the users of one environment, ordered by most recent activity. Use it to see who is using your agent and which users have high cost or error rates. To review users:- Select your agent, then select Monitoring in the sidebar.
- Select the Users tab.
- Choose the environment and time range.
user_id on the root run. See Record the user on a trace.
To find one user, enter their exact user ID in the search box. Click a row to open the Tracing page filtered to that user’s traces.
Group charts by user
Grouping by user splits each dashboard chart into one series per user. LangSmith groups runs by theiruser_id metadata value, so you do not need to enter the metadata path.
- Prebuilt dashboards: Select User in the dashboard’s group by setting.
- Custom charts: When you configure a chart, select User as the group-by attribute. To start from a chart that already groups by user, use the Traces by user or Cost by user template.
user_id, and users outside the most frequent ones, count toward the Other group where the chart shows one. The Metadata key list does not offer user_id, because User replaces it.
Add traits to a user
Traits are key-value attributes, such as a name or an email address, that you store for a user through the LangSmith REST API. Use traits to keep the details your team needs about each user, such as who they are and how to reach them, under the sameuser_id that your traces record. LangSmith stores traits separately from traces, so trace retention does not apply to them. Traits stay until you remove them with an update, or until the agent environment or workspace is deleted.
Traits belong to one agent environment. The same user_id in two environments has two separate sets of traits. The {session_id} path parameter is the agent environment’s ID. To get it, resolve the agent environment, which returns the ID as session_id.
Set permissions
Each operation requires a permission. For the roles that include each permission, see Organization and workspace operations:- Create a user:
runs:create, the same permission that sending traces requires. - Update traits:
runs:createandruns:read. - Get or list users:
runs:read.
403 for those requests.
Create and update users
The API provides these operations:- Create a user:
POST /api/v1/platform/sessions/{session_id}/userswith auser_idand optionaltraits. Returns201with the new user, or409if the user already exists. To create a user or update an existing user, send a create request, then send an update request when the create request returns409. - Update traits:
PATCH /api/v1/platform/sessions/{session_id}/users/{user_id}with atraitsobject. LangSmith merges thetraitsobject into the stored traits: keys you send overwrite existing values, keys you omit are kept, and anullvalue removes a key. Returns200with the stored user, or404if the user does not exist. - Get a user:
GET /api/v1/platform/sessions/{session_id}/users/{user_id}. Returns404if the user does not exist. - List users:
GET /api/v1/platform/sessions/{session_id}/users, ordered by most recently updated. The optionalpage_sizeparameter defaults to 20, with a maximum of 100. Pass thenext_cursorvalue from a response ascursorto get the next page. On the last page,next_cursorisnull. Useuser_id_prefixfor a case-sensitive prefix match on the user ID.
user_id, traits, created_at, and updated_at.
This update request body changes the name and removes the email, keeping any other traits:
Stay within request limits
Each request must stay within the following limits:- User ID: A user ID has 1 to 512 characters. In a path, URL-encode the user ID but keep each
/as is, because LangSmith rejects%2Fin a path. You cannot get or update a user whose ID has a.or..segment,//, or a leading/, because the ID cannot be used in a path. - Trait values:
traitsmust be a JSON object with at most 50 keys. Thenameandemailkeys must be strings, ornullin an update. A create request cannot containnullvalues. - Size: A user’s stored traits are limited to 16,384 bytes, and a request body to 65,536 bytes. An update that would exceed the stored limit fails, and the stored traits stay unchanged.
- Rate limit: LangSmith limits how many users a workspace can create per minute. A request over the limit returns
429with aRetry-Afterheader.
400: LangSmith cannot read the request, such as invalid JSON, an unknown field, or a body over the size limit.422: A user ID or trait value breaks a request limit. The response names the field.501: The user features are not enabled for your workspace.
See also
- Configure threads: group a user’s traces into conversations with
thread_id. - View traces: the Trajectory and Details views that show the user ID.
- Add metadata and tags to traces: set
user_idand other metadata keys. - Filter traces: combine
user_idwith other fields in a query. - Dashboards: build prebuilt and custom charts, including charts grouped by user.
- Log user feedback using the SDK: attach feedback from your users to their runs.
Connect these docs to your agent of choice via MCP for real-time answers.

