---
title: "Query Spans"
method: POST
path: "/spans/query"
tags: ["Observability"]
---

# Query Spans

`POST /spans/query`

## Request body

- SpansQueryRequest
  - `filtering` FilteringInput
    - `operator` 'and' | 'or' | 'not' | 'nand' | 'nor'
    - `conditions` union[]
      - union
        - Condition
          - `field` string, required
          - `key` string, nullable
          - `value` union
            - string
            - integer
            - number
            - boolean
            - unknown[]
              - …
            - object
          - `operator` union
            - 'is' | 'is_not'
            - 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte' | 'btwn'
            - 'startswith' | 'endswith' | 'contains' | 'matches' | 'like'
            - 'in' | 'not_in'
            - 'has' | 'has_not'
            - 'exists' | 'not_exists'
          - `options` union
            - TextOptions
              - …
            - ListOptions
              - …
        - FilteringInput — recursive
  - `windowing` Windowing
    - `newest` string, date-time, nullable
    - `oldest` string, date-time, nullable
    - `next` string, uuid, nullable
    - `limit` integer, nullable
    - `order` 'ascending' | 'descending', nullable
    - `interval` integer, nullable
    - `rate` number, nullable
  - `query_ref` AgentaSdkModelsSharedReference
    - `version` string, nullable
    - `slug` string, nullable
    - `id` string, uuid, nullable
  - `query_variant_ref` AgentaSdkModelsSharedReference
    - `version` string, nullable
    - `slug` string, nullable
    - `id` string, uuid, nullable
  - `query_revision_ref` AgentaSdkModelsSharedReference
    - `version` string, nullable
    - `slug` string, nullable
    - `id` string, uuid, nullable

## Response `200`

Successful Response

- SpansResponse
  - `count` integer
  - `spans` SpanOutput[], nullable
    - `created_at` string, date-time, nullable
    - `updated_at` string, date-time, nullable
    - `deleted_at` string, date-time, nullable
    - `created_by_id` string, uuid, nullable
    - `updated_by_id` string, uuid, nullable
    - `deleted_by_id` string, uuid, nullable
    - `trace_id` string, required
    - `span_id` string, required
    - `parent_id` string, nullable
    - `trace_type` 'invocation' | 'annotation' | 'unknown'
    - `span_type` 'agent' | 'chain' | 'workflow' | 'task' | 'tool' | 'embedding' | 'query' | 'llm' | 'completion' | 'chat' | 'rerank' | 'unknown'
    - `span_kind` 'SPAN_KIND_UNSPECIFIED' | 'SPAN_KIND_INTERNAL' | 'SPAN_KIND_SERVER' | 'SPAN_KIND_CLIENT' | 'SPAN_KIND_PRODUCER' | 'SPAN_KIND_CONSUMER'
    - `span_name` string, nullable
    - `start_time` union
      - string, date-time
      - integer
    - `end_time` union
      - string, date-time
      - integer
    - `status_code` 'STATUS_CODE_UNSET' | 'STATUS_CODE_OK' | 'STATUS_CODE_ERROR'
    - `status_message` string, nullable
    - `attributes` object, nullable
    - `references` OTelReferenceOutput[], nullable
      - `version` string, nullable
      - `slug` string, nullable
      - `id` string, uuid, nullable
      - `attributes` object, nullable
    - `links` OTelLinkOutput[], nullable
      - `span_id` string, nullable
      - `trace_id` string, nullable
      - `attributes` object, nullable
    - `hashes` OTelHashOutput[], nullable
      - `id` string, uuid, nullable
      - `attributes` object, nullable
    - `exception` object, nullable
    - `events` OTelEventOutput[], nullable
      - `name` string, required
      - `timestamp` union, required
        - string, date-time
        - integer
      - `attributes` object, nullable

## Other responses

- `422` — Validation Error

## Changes

- **2026-04-18** `c469c2f6cdba` — 1 info
  - endpoint added
- **2025-06-27** `e3e84db47198` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/agenta-ai/apis/agenta-api/changes/spans/query/post.md)

---

[API](https://skmtc.dev/agenta-ai/apis/agenta-api.md) · [All operations](https://skmtc.dev/agenta-ai/apis/agenta-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/agenta-ai/agenta-api/revisions/c469c2f6cdba/schema)
