Skip to main content
POST
https://api.respan.ai
/
api
/
traces
/
bulk-delete
Bulk delete traces
curl --request POST \
  --url https://api.respan.ai/api/traces/bulk-delete/ \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "filters": {}
}'
{
  "deleted_count": 42,
  "message": "Successfully deleted 42 traces"
}
Deletes multiple traces matching the given filters. Uses the same filter format as the List Traces endpoint. Removes data from both raw span storage and the aggregated trace table.
The request body must contain a non-empty filters object. This prevents accidental deletion of all traces. Maximum 1,000 traces per request — if the filter matches more, narrow your filters or use time-range pagination to delete in batches.

Query Parameters

start_time
string
ISO 8601 start of time range. Defaults to end_time minus 1 hour.
"start_time": "2024-01-15T00:00:00Z"
end_time
string
ISO 8601 end of time range. Defaults to current time.
"end_time": "2024-01-15T23:59:59Z"
environment
string
Filter by environment (e.g., production, staging).

Request Body

filters
object
required
Filter object to select traces for deletion. Must be non-empty. Uses the same format as the List Traces endpoint.Available filter fields:
  • trace_unique_id, customer_identifier, environment
  • span_count, llm_call_count, error_count
  • total_cost, total_tokens, total_prompt_tokens, total_completion_tokens
  • Custom metadata: metadata__your_field
See the Filters API Reference for complete operators and format documentation.
{
  "filters": {
    "customer_identifier": {
      "operator": "=",
      "value": ["user@example.com"]
    }
  }
}

Examples

import requests

url = "https://api.respan.ai/api/traces/bulk-delete/"
headers = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
params = {
    "start_time": "2024-01-15T00:00:00Z",
    "end_time": "2024-01-15T23:59:59Z"
}

# Delete all traces for a specific customer
body = {
    "filters": {
        "customer_identifier": {
            "operator": "=",
            "value": ["user@example.com"]
        }
    }
}

response = requests.post(url, headers=headers, params=params, json=body)
print(response.json())

Delete specific traces by ID

curl -X POST "https://api.respan.ai/api/traces/bulk-delete/" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filters": {
      "trace_unique_id": {
        "operator": "IN",
        "value": ["trace_abc123", "trace_def456", "trace_ghi789"]
      }
    }
  }'

Delete traces with errors in a specific environment

curl -X POST "https://api.respan.ai/api/traces/bulk-delete/?environment=staging" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filters": {
      "error_count": {
        "operator": "gt",
        "value": [0]
      }
    }
  }'

Response

{
  "deleted_count": 42,
  "message": "Successfully deleted 42 traces"
}

Error Responses

401 Unauthorized
{ "detail": "Your API key is invalid or expired, please check your API key at https://platform.respan.ai/platform/api/api-keys" }