When a user deletes their account I want to delete all the user data on langsmith.
I have run ids stored in my db. How do I delete all traces/runs of that user based on these run ids?
When a user deletes their account I want to delete all the user data on langsmith.
I have run ids stored in my db. How do I delete all traces/runs of that user based on these run ids?
LangSmith doesn’t have a direct bulk delete API for runs. You’ll need to delete runs individually using the LangSmith SDK:
from langsmith import Client
client = Client()
for run_id in user_run_ids:
try:
client.delete_run(run_id)
except Exception as e:
# Handle errors (run might not exist)
continue
For large datasets, batch this operation and add rate limiting to avoid API limits. Alternatively, contact LangSmith support for bulk deletion assistance if you have thousands of runs. Note that deleted runs may still appear in aggregated metrics but individual trace data will be removed.
There is a batch delete endpoint that you can access through the API here
Thanks!