---
title: "Search spans"
method: POST
path: "/v1/private/spans/search"
tags: ["Spans"]
---

# Search spans

`POST /v1/private/spans/search`

Search spans

## Request body

- SpanSearchStreamRequestPublic
  - `trace_id` string, uuid
  - `project_name` string
  - `project_id` string, uuid
  - `type` 'general' | 'tool' | 'llm' | 'guardrail'
  - `filters` SpanFilterPublic[]
    - `field` string
    - `operator` 'contains' | 'not_contains' | 'starts_with' | 'ends_with' | '=' | '!=' | '>' | '>=' | '<' | '<=' | 'is_empty' | 'is_not_empty' | 'in' | 'not_in'
    - `key` string
    - `value` string
  - `limit` integer — Max number of spans to be streamed
  - `last_retrieved_id` string, uuid
  - `truncate` boolean — Truncate image included in either input, output or metadata
  - `exclude` string[] — Fields to exclude from the response
  - `from_time` string, date-time — Filter spans created from this time (ISO-8601 format).
  - `to_time` string, date-time — Filter spans created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.

## Other responses

- `400` — Bad Request

---

[API](https://skmtc.net/comet-ml/apis/opik-rest-api.md) · [All operations](https://skmtc.net/comet-ml/apis/opik-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/comet-ml/opik-rest-api/versions/4ed2fbc97cc3/schema)
