Skip to main content
This guide covers retention and deletion controls for data stored in LangSmith.

Data retention

LangSmith provides automatic data retention capabilities to help with compliance and storage management. Data retention policies can be configured at two levels: For the retention period of each tier on Cloud, BYOC, and self-hosted, see Retention periods.

Customize extended retention policy

This feature is available for Enterprise plan customers. For self-hosted Enterprise customers, refer to the workspace-level configuration section.
Enterprise customers can customize the extended data retention period for traces at the workspace level to meet specific compliance requirements. The durations you can choose depend on your hosting option. See Retention periods.
Changes to the retention period apply to new traces only. Existing traces are not affected.

Configure extended retention

Organization Admins and Operators (organization:manage) can configure retention for any workspace. Workspace Admins can configure their own workspace (workspaces:manage). For a full permissions reference, see Organization and workspace operations.
In the LangSmith UI:
  1. Navigate to Settings at the bottom of the page.
  2. Select Usage configuration from the left-hand menu.
  3. Find the workspace in the list that you would like to configure.
  4. Click on the value under the Data retention policy column for that workspace.
  5. On the workspace usage configurations modal, customize the extended policy using the dropdown for Extended - All traces are retained for option. The dropdown lists the durations available for your hosting option.
  6. Select Save.

Workspace-level extended retention for self-hosted

Self-hosted Enterprise customers can also use workspace-level extended retention configuration instead of system-wide TTL settings. This provides more granular control over data retention for different workspaces without requiring environment variable changes.
If you use blob storage, you must add a lifecycle rule for each custom retention period you configure. For example, setting a workspace to 90-day retention means blob data is written to the ttl_90d/ prefix, which requires a matching lifecycle rule to be cleaned up automatically. See blob storage TTL configuration for details and examples.
To configure this for self-hosted deployments, refer to the self-hosted TTL documentation for the legacy system-wide approach or contact support. On self-hosted, your administrator chooses the periods users can pick. See Choose the extended retention periods users can pick.

Project-level extended retention for self-hosted

Per-environment extended retention requires LangSmith v0.18.0 or later and is disabled by default. To enable it, see Requirements.
Self-hosted customers can also set extended retention per agent environment, from the same periods as workspaces. An environment without its own period uses the workspace period. When a workspace disables extended trace retention, new traces in its agent environments use base retention, even if an environment has its own extended period. To set it, select your agent, go to Tracing, and select the environment. Click Retention in the top bar, select Extended, and pick a period, or Workspace default to follow the workspace. Through the API, set longlived_ttl_days with PATCH /api/v1/sessions/<tracer-session-id>, using the environment’s tracer_session_id, or set it to null to follow the workspace again. Lengthening an environment’s period requires the projects:increase-trace-tier permission. Shortening it requires projects:decrease-trace-tier. Resetting an environment to the workspace default can require either, depending on whether the workspace period is longer or shorter. See RBAC permissions. A new period applies only to traces ingested after the change. Existing traces keep the period they were written with. In a Base project, traces upgraded to extended retention, for example after feedback, use the workspace period. The UI does not set a period on Base projects, but the API can. A Base project with its own longlived_ttl_days applies that period to its upgraded traces instead. If an administrator turns per-project retention off after projects have saved their own periods, those projects use the workspace period again.

Disable extended trace retention

The workspace retention restriction blocks extended retention for new traces and new upgrade requests. Use it to keep new traces at base retention without disabling feedback or evaluations. The switch is off by default.
This feature is available for Enterprise plan customers. For self-hosted deployments, this feature is available in the LangSmith 0.18.29rc1 release candidate, packaged with Helm chart version 0.18.0-rc.78. Older data planes might not show the switch.
Changing this setting requires organization:retention:manage, granted to Organization Admins and Operators. A Workspace Admin role alone does not grant this permission. To disable extended retention for a workspace:
  1. In the LangSmith UI, go to Settings > Usage configuration.
  2. Select the workspace’s Data retention policy.
  3. Turn on Disable Extended Trace Retention.
  4. Select Save.
While the restriction is active:
  • New traces: Use base retention, even if the environment’s saved default is extended.
  • Retention upgrades: New requests do not extend traces, including existing base-retention traces. Feedback, evaluations, and other automation actions continue without extending retention.
  • Environment defaults: You cannot set new environment defaults to extended or change base defaults to extended. Existing extended defaults remain saved but do not apply to new traces.
  • Existing extended traces: Keep their expiration dates. The restriction does not shorten their retention or delete them.
  • Saved preferences: Environment defaults and retention preferences for rules and evaluators stay unchanged. Turning the switch off again allows those settings to apply.
Changes take time to propagate through cached settings. Previously accepted upgrades, including queued or retried work, can still finish after you save. This setting is not an immediate or retroactive deletion control.
This restriction is separate from retention durations, environment defaults, and individual rule or evaluator opt-outs. Unlike an extended-retention usage limit, it lets feedback and evaluations continue without extending retention. Self-hosted deployments do not track long-lived trace usage in version 0.16.0 and later. The Long-lived only filter always shows zero results, so it does not verify this restriction.

Trace deletes

You can use the API to complete trace deletes. The API supports two methods for deleting traces:
  1. By trace IDs and session ID: Delete specific traces by providing a list of trace IDs and their corresponding session ID (up to 1000 traces per request)
  2. By metadata: Delete traces across a workspace that match any of the specified metadata key-value pairs
For more details, refer to the API spec.
All trace deletions will delete related entities like feedbacks, aggregations, and stats across all data storages.

Deletion timeline

Trace deletions are processed during non-peak usage times and are not instant. SmithDB may make traces unqueryable right away. Most deletes are hardened within 6 hours or sooner. To confirm deletion, query the data again to verify it has been removed.

Delete specific traces

To delete specific traces by their trace IDs from a single session:
The session_id is the tracer_session_id of the agent environment that holds the trace you are trying to delete. Select your agent, go to Tracing, and select the environment. Click the ID badge next to the environment name and copy the Tracing Project ID.

Example deletes

You can delete dataset examples self-serve via our API, which supports both soft and hard deletion methods depending on your data retention needs.
Hard deletes will permanently remove inputs, outputs, and metadata from ALL versions of the specified examples across the entire dataset history.

Deleting examples is a two-step process

For bulk operations, example deletion follows a two-step process:

1. Search for examples by metadata

Find all examples with matching metadata across all datasets in a workspace. GET /examples
  • as_of must be explicitly specified as a timestamp. Only examples created before the as_of date will be returned
This will return examples that have either user_id: "user123" or environment: "staging" in their metadata across all datasets in your workspace.

2. Hard delete examples

Once you have the example IDs, send a delete request. This will zero-out the inputs, outputs, and metadata from all versions of the dataset for that example. POST /v1/platform/datasets/examples/delete/
  • Specify example_ids (list of example IDs) and hard_delete (boolean) in the request body

Deletion types

Soft delete (default)

  • Creates tombstoned entries with NULL inputs/outputs in the dataset
  • Preserves historical data and maintains dataset versioning
  • Only affects the current version of the dataset

Hard delete

  • Permanently removes inputs, outputs, and metadata from ALL dataset versions
  • Complete data removal when compliance requires zero-out across all versions
  • Set "hard_delete": true in the request body