Skip to content

Commit 1bdaf91

Browse files
data compliance docs (#945)
Co-authored-by: Kathryn May <[email protected]>
1 parent 339a7b7 commit 1bdaf91

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed

docs/administration/how_to_guides/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ See the following guides to set up your LangSmith account.
2727
- [Assign a tag to a resource](./how_to_guides/organization_management/set_up_resource_tags#assign-a-tag-to-a-resource)
2828
- [Delete a tag](./how_to_guides/organization_management/set_up_resource_tags#delete-a-tag)
2929
- [Filter resources by tags](./how_to_guides/organization_management/set_up_resource_tags#filter-resources-by-tags)
30+
- [Data purging for compliance](./how_to_guides/organization_management/data_purging_compliance)
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
sidebar_position: 10
3+
---
4+
5+
# Data Purging for Compliance
6+
7+
This guide covers the various features available after data reaches LangSmith Cloud servers to help you achieve your privacy goals.
8+
9+
## Data Retention
10+
11+
LangSmith provides automatic data retention capabilities to help with compliance and storage management. Data retention policies can be configured at the organization and project levels.
12+
13+
For detailed information about data retention configuration and management, please refer to the [Data Retention concepts](/administration/concepts#data-retention) documentation.
14+
15+
## Trace Deletes
16+
17+
You can use the API to complete trace deletes. The API supports two methods for deleting traces:
18+
19+
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)
20+
2. **By metadata**: Delete traces across a workspace that match any of the specified metadata key-value pairs
21+
22+
For more details, refer to the [API spec](https://api.smith.langchain.com/redoc#tag/run/operation/delete_runs_api_v1_runs_delete_post).
23+
24+
:::warning Trace Deletes
25+
All trace deletions will delete related entities like feedbacks, aggregations, and stats across all data storages.
26+
:::
27+
28+
### Deletion Timeline
29+
30+
Trace deletions are processed during non-peak usage times and are not instant, usually within a few hours. There is no confirmation of deletion - you'll need to query the data again to verify it has been removed.
31+
32+
### Delete Specific Traces
33+
34+
To delete specific traces by their trace IDs from a single session:
35+
36+
```bash
37+
curl -X POST "https://api.smith.langchain.com/api/v1/runs/delete" \
38+
-H "Authorization: Bearer YOUR_API_KEY" \
39+
-H "Content-Type: application/json" \
40+
-d '{
41+
"run_ids": ["trace-id-1", "trace-id-2", "trace-id-3"],
42+
"session_id": "session-id-1"
43+
}'
44+
```
45+
46+
### Delete by Metadata
47+
48+
When deleting by metadata:
49+
50+
- Accepts a `metadata` object of key/value pairs. KV pair matching uses an **or** condition. A trace will match if it has **any** of the key-value pairs specified in metadata (not all)
51+
- You don't need to specify a session id when deleting by metadata. Deletes will apply across the workspace.
52+
53+
To delete traces based on metadata across a workspace (matches **any** of the metadata key-value pairs):
54+
55+
```bash
56+
curl -X POST "https://api.smith.langchain.com/api/v1/runs/delete" \
57+
-H "Authorization: Bearer YOUR_API_KEY" \
58+
-H "Content-Type: application/json" \
59+
-d '{
60+
"metadata": {
61+
"user_id": "user123",
62+
"environment": "staging"
63+
}
64+
}'
65+
```
66+
67+
This will delete traces that have either `user_id: "user123"` **or** `environment: "staging"` in their metadata.
68+
69+
:::warning Rate Limits
70+
Remember that you can only schedule up to 1000 traces per session per request. For larger deletions, you'll need to make multiple requests.
71+
:::
72+
73+
## Example Deletes
74+
75+
You can delete dataset examples self-serve via our API, which supports both soft and hard deletion methods depending on your data retention needs.
76+
77+
:::warning Example Deletes
78+
Hard deletes will permanently remove inputs, outputs, and metadata from ALL versions of the specified examples across the entire dataset history.
79+
:::
80+
81+
### Deleting Examples is a Two-Step Process
82+
83+
For bulk operations, example deletion follows a two-step process:
84+
85+
#### 1. Search for Examples by Metadata
86+
87+
Find all examples with matching metadata across all datasets in a workspace.
88+
89+
[GET /examples](https://api.smith.langchain.com/redoc#tag/examples/operation/read_examples_api_v1_examples_get)
90+
91+
- `as_of` must be explicitly specified as a timestamp. Only examples created before the `as_of` date will be returned
92+
93+
```bash
94+
curl -X GET "https://api.smith.langchain.com/api/v1/examples?as_of=2024-01-01T00:00:00Z" \
95+
-H "Authorization: Bearer YOUR_API_KEY" \
96+
-H "Content-Type: application/json" \
97+
-d '{
98+
"metadata": {
99+
"user_id": "user123",
100+
"environment": "staging"
101+
}
102+
}'
103+
```
104+
105+
This will return examples that have either `user_id: "user123"` **or** `environment: "staging"` in their metadata across all datasets in your workspace.
106+
107+
#### 2. Hard Delete Examples
108+
109+
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.
110+
111+
[DELETE /examples](https://api.smith.langchain.com/redoc#tag/examples/operation/delete_examples_api_v1_examples_delete)
112+
113+
- Specify example IDs and add `"hard_delete": true` to the query params of the request
114+
115+
```bash
116+
curl -X DELETE "https://api.smith.langchain.com/api/v1/examples?hard_delete=true" \
117+
-H "Authorization: Bearer YOUR_API_KEY" \
118+
-H "Content-Type: application/json" \
119+
-d '{
120+
"example_ids": ["example-id-1", "example-id-2", "example-id-3"]
121+
}'
122+
```
123+
124+
### Deletion Types
125+
126+
#### Soft Delete (Default)
127+
128+
- Creates tombstoned entries with NULL inputs/outputs in the dataset
129+
- Preserves historical data and maintains dataset versioning
130+
- Only affects the current version of the dataset
131+
132+
#### Hard Delete
133+
134+
- Permanently removes inputs, outputs, and metadata from ALL dataset versions
135+
- Complete data removal when compliance requires zero-out across all versions
136+
- Add `"hard_delete": true` to the query parameters
137+
138+
For more details, refer to the [API spec](https://api.smith.langchain.com/redoc#tag/examples/operation/delete_examples_api_v1_examples_delete).

0 commit comments

Comments
 (0)