---
title: "Genai Spans Query"
method: POST
path: "/agents/spans/query"
tags: ["Agents"]
---

# Genai Spans Query

`POST /agents/spans/query`

## Request

- Base URL: `https://trace.wandb.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://trace.wandb.ai/agents/spans/query`
- Auth: none declared

Query agent spans, either as raw rows or grouped aggregates.

## Request body

- AgentSpansQueryReq: Request to query agent spans for a project. When `group_by` is empty (or omitted), returns raw span rows in the response's `spans` field. When `group_by` is non-empty, returns aggregate group rows in the response's `groups` field.
  - `project_id` string, required
  - `query` Query
    - `$expr` union, required
      - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
        - `$and` union[], required
          - union
            - LiteralOperation: Represents a constant value in the query language. This can be any standard JSON-serializable value. Example: ``` {"$literal": "predict"} ```
              - …
            - GetFieldOperator: Access a field on the traced call. Supports dot notation for nested access, e.g. `summary.usage.tokens`. Only works on fields present in the `CallSchema`, including: - Top-level fields like `op_name`, `trace_id`, `started_at` - Nested fields like `inputs.input_name`, `summary.usage.tokens`, etc. Example: ``` {"$getField": "op_name"} ```
              - …
            - ConvertOperation: Convert the input value to a specific type (e.g., `int`, `bool`, `string`). Example: ``` { "$convert": { "input": {"$getField": "inputs.value"}, "to": "int" } } ```
              - …
            - SizeOperation: Return the number of elements in a collection or characters in a string. Example: ``` {"$size": {"$getField": "scorer_tags"}} ```
              - …
            - AndOperation (recursive)
            - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
              - …
            - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
              - …
            - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
              - …
            - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
              - …
            - ContainsOperation: Case-insensitive substring match. Not part of MongoDB. Weave-specific addition. Example: ``` { "$contains": { "input": {"$getField": "display_name"}, "substr": {"$literal": "llm"}, "case_insensitive": true } } ```
              - …
      - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
        - `$or` union[], required
          - union
            - LiteralOperation: Represents a constant value in the query language. This can be any standard JSON-serializable value. Example: ``` {"$literal": "predict"} ```
              - …
            - GetFieldOperator: Access a field on the traced call. Supports dot notation for nested access, e.g. `summary.usage.tokens`. Only works on fields present in the `CallSchema`, including: - Top-level fields like `op_name`, `trace_id`, `started_at` - Nested fields like `inputs.input_name`, `summary.usage.tokens`, etc. Example: ``` {"$getField": "op_name"} ```
              - …
            - ConvertOperation: Convert the input value to a specific type (e.g., `int`, `bool`, `string`). Example: ``` { "$convert": { "input": {"$getField": "inputs.value"}, "to": "int" } } ```
              - …
            - SizeOperation: Return the number of elements in a collection or characters in a string. Example: ``` {"$size": {"$getField": "scorer_tags"}} ```
              - …
            - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
              - …
            - OrOperation (recursive)
            - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
              - …
            - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
              - …
            - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
              - …
            - ContainsOperation: Case-insensitive substring match. Not part of MongoDB. Weave-specific addition. Example: ``` { "$contains": { "input": {"$getField": "display_name"}, "substr": {"$literal": "llm"}, "case_insensitive": true } } ```
              - …
      - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
        - `$not` unknown[], required
          - unknown
      - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
        - `$eq` unknown[], required
          - unknown
      - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
        - `$gt` unknown[], required
          - unknown
      - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
        - `$lt` unknown[], required
          - unknown
      - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
        - `$gte` unknown[], required
          - unknown
      - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
        - `$lte` unknown[], required
          - unknown
      - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
        - `$in` unknown[], required
          - unknown
      - ContainsOperation: Case-insensitive substring match. Not part of MongoDB. Weave-specific addition. Example: ``` { "$contains": { "input": {"$getField": "display_name"}, "substr": {"$literal": "llm"}, "case_insensitive": true } } ```
        - `$contains` ContainsSpec, required: Specification for the `$contains` operation. - `input`: The string to search. - `substr`: The substring to search for. - `case_insensitive`: If true, match is case-insensitive.
          - `input` union, required
            - LiteralOperation: Represents a constant value in the query language. This can be any standard JSON-serializable value. Example: ``` {"$literal": "predict"} ```
              - …
            - GetFieldOperator: Access a field on the traced call. Supports dot notation for nested access, e.g. `summary.usage.tokens`. Only works on fields present in the `CallSchema`, including: - Top-level fields like `op_name`, `trace_id`, `started_at` - Nested fields like `inputs.input_name`, `summary.usage.tokens`, etc. Example: ``` {"$getField": "op_name"} ```
              - …
            - ConvertOperation: Convert the input value to a specific type (e.g., `int`, `bool`, `string`). Example: ``` { "$convert": { "input": {"$getField": "inputs.value"}, "to": "int" } } ```
              - …
            - SizeOperation: Return the number of elements in a collection or characters in a string. Example: ``` {"$size": {"$getField": "scorer_tags"}} ```
              - …
            - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
              - …
            - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
              - …
            - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
              - …
            - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
              - …
            - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
              - …
            - ContainsOperation (recursive)
          - `substr` union, required
            - LiteralOperation: Represents a constant value in the query language. This can be any standard JSON-serializable value. Example: ``` {"$literal": "predict"} ```
              - …
            - GetFieldOperator: Access a field on the traced call. Supports dot notation for nested access, e.g. `summary.usage.tokens`. Only works on fields present in the `CallSchema`, including: - Top-level fields like `op_name`, `trace_id`, `started_at` - Nested fields like `inputs.input_name`, `summary.usage.tokens`, etc. Example: ``` {"$getField": "op_name"} ```
              - …
            - ConvertOperation: Convert the input value to a specific type (e.g., `int`, `bool`, `string`). Example: ``` { "$convert": { "input": {"$getField": "inputs.value"}, "to": "int" } } ```
              - …
            - SizeOperation: Return the number of elements in a collection or characters in a string. Example: ``` {"$size": {"$getField": "scorer_tags"}} ```
              - …
            - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
              - …
            - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
              - …
            - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
              - …
            - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
              - …
            - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
              - …
            - ContainsOperation (recursive)
          - `case_insensitive` boolean, nullable
  - `group_by` AgentGroupByRef[], nullable
    - `source` 'field' | 'column' | 'custom_attrs_string' | 'custom_attrs_int' | 'custom_attrs_float' | 'custom_attrs_bool'
    - `key` string, required
    - `alias` string, nullable
  - `measures` AgentSpanMeasureSpec[]
    - `alias` string, required
    - `aggregation` 'sum' | 'avg' | 'min' | 'max' | 'count' | 'count_distinct' | 'count_true' | 'count_false', required
    - `value` AgentSpanValueRef: Reference to a span field or typed custom attribute map value.
      - `source` 'field' | 'derived' | 'custom_attrs_string' | 'custom_attrs_int' | 'custom_attrs_float' | 'custom_attrs_bool'
      - `key` string, required
    - `value_type` 'datetime' | 'number' | 'boolean' | 'string', nullable
    - `filter` Query
      - `$expr` union, required
        - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
          - `$and` union[], required
            - union
              - …
        - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
          - `$or` union[], required
            - union
              - …
        - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
          - `$not` unknown[], required
            - unknown
        - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
          - `$eq` unknown[], required
            - unknown
        - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
          - `$gt` unknown[], required
            - unknown
        - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
          - `$lt` unknown[], required
            - unknown
        - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
          - `$gte` unknown[], required
            - unknown
        - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
          - `$lte` unknown[], required
            - unknown
        - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
          - `$in` unknown[], required
            - unknown
        - ContainsOperation: Case-insensitive substring match. Not part of MongoDB. Weave-specific addition. Example: ``` { "$contains": { "input": {"$getField": "display_name"}, "substr": {"$literal": "llm"}, "case_insensitive": true } } ```
          - `$contains` ContainsSpec, required: Specification for the `$contains` operation. - `input`: The string to search. - `substr`: The substring to search for. - `case_insensitive`: If true, match is case-insensitive.
            - `input` union, required
              - …
            - `substr` union, required
              - …
            - `case_insensitive` boolean, nullable
  - `group_filters` AgentSpanGroupFilter[]
    - `group_by` AgentGroupByRef[]
      - `source` 'field' | 'column' | 'custom_attrs_string' | 'custom_attrs_int' | 'custom_attrs_float' | 'custom_attrs_bool'
      - `key` string, required
      - `alias` string, nullable
    - `measure` AgentSpanMeasureSpec, required: One aggregate measure computed over spans in a group or bucket.
      - `alias` string, required
      - `aggregation` 'sum' | 'avg' | 'min' | 'max' | 'count' | 'count_distinct' | 'count_true' | 'count_false', required
      - `value` AgentSpanValueRef: Reference to a span field or typed custom attribute map value.
        - `source` 'field' | 'derived' | 'custom_attrs_string' | 'custom_attrs_int' | 'custom_attrs_float' | 'custom_attrs_bool'
        - `key` string, required
      - `value_type` 'datetime' | 'number' | 'boolean' | 'string', nullable
      - `filter` Query
        - `$expr` union, required
          - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
            - `$and` union[], required
              - …
          - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
            - `$or` union[], required
              - …
          - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
            - `$not` unknown[], required
              - …
          - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
            - `$eq` unknown[], required
              - …
          - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
            - `$gt` unknown[], required
              - …
          - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
            - `$lt` unknown[], required
              - …
          - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
            - `$gte` unknown[], required
              - …
          - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
            - `$lte` unknown[], required
              - …
          - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
            - `$in` unknown[], required
              - …
          - ContainsOperation: Case-insensitive substring match. Not part of MongoDB. Weave-specific addition. Example: ``` { "$contains": { "input": {"$getField": "display_name"}, "substr": {"$literal": "llm"}, "case_insensitive": true } } ```
            - `$contains` ContainsSpec, required: Specification for the `$contains` operation. - `input`: The string to search. - `substr`: The substring to search for. - `case_insensitive`: If true, match is case-insensitive.
              - …
    - `min` union
      - number
      - string, date-time
    - `max` union
      - number
      - string, date-time
  - `group_distributions` AgentSpanGroupDistributionSpec[]
    - `alias` string, required
    - `value` AgentSpanValueRef, required: Reference to a span field or typed custom attribute map value.
      - `source` 'field' | 'derived' | 'custom_attrs_string' | 'custom_attrs_int' | 'custom_attrs_float' | 'custom_attrs_bool'
      - `key` string, required
    - `bins` integer
    - `top_n` integer
  - `custom_attr_columns` AgentSpanValueRef[]
    - `source` 'field' | 'derived' | 'custom_attrs_string' | 'custom_attrs_int' | 'custom_attrs_float' | 'custom_attrs_bool'
    - `key` string, required
  - `include_details` boolean
  - `include_costs` boolean
  - `sort_by` AgentSortBy[], nullable
    - `field` string, required
    - `direction` 'asc' | 'desc'
  - `limit` integer
  - `offset` integer
  - `started_after` string, date-time, nullable
  - `started_before` string, date-time, nullable
  - `signal_filters` AgentSignalFilter
    - `tags` string[]
    - `ratings` RatingCondition[]
      - `scorer_key` string, required
      - `op` 'gte' | 'gt' | 'lte' | 'lt' | 'eq', required
      - `value` number, required
  - `insight_filters` AgentInsightFilter[]
    - `field` 'intent_category' | 'intent_sentiment' | 'failure_category' | 'failure_severity' | 'intent_topic_id' | 'failure_topic_id', required
    - `values` string[], required: Values to match. intent_sentiment accepts only frustrated, dissatisfied, neutral, satisfied, delighted; failure_severity accepts only info, major, or minor.
    - `exclude` boolean: Exclude conversations matching any value in this filter.

## Response `200`

Successful Response

- AgentSpansQueryRes: Response from a spans query. Exactly one of `spans` or `groups` will be populated, based on whether the request specified `group_by`.
  - `spans` AgentSpanSchema[], required
    - `project_id` string, required
    - `trace_id` string, required
    - `span_id` string, required
    - `parent_span_id` string, nullable, required
    - `span_name` string, nullable, required
    - `span_kind` 'UNSPECIFIED' | 'INTERNAL' | 'SERVER' | 'CLIENT' | 'PRODUCER' | 'CONSUMER', nullable, required
    - `started_at` string, date-time, nullable, required
    - `ended_at` string, date-time, nullable, required
    - `status_code` 'UNSET' | 'OK' | 'ERROR', nullable, required
    - `status_message` string, nullable, required
    - `operation_name` string, nullable, required
    - `provider_name` string, nullable, required
    - `agent_name` string, nullable, required
    - `agent_id` string, nullable, required
    - `agent_description` string, nullable, required
    - `agent_version` string, nullable, required
    - `main_agent_id` string, nullable, required
    - `main_agent_name` string, nullable, required
    - `workflow_name` string, nullable, required
    - `eval_run_id` string, nullable, required
    - `eval_predict_and_score_call_id` string, nullable, required
    - `eval_kind` string, nullable, required
    - `eval_row_digest` string, nullable, required
    - `eval_example_id` string, nullable, required
    - `eval_trial_index` integer, nullable, required
    - `eval_evaluation_name` string, nullable, required
    - `parent_call_id` string, nullable, required
    - `parent_call_trace_id` string, nullable, required
    - `request_model` string, nullable, required
    - `response_model` string, nullable, required
    - `response_id` string, nullable, required
    - `response_time_to_first_chunk` number, nullable, required
    - `input_tokens` integer, nullable, required
    - `output_tokens` integer, nullable, required
    - `reasoning_tokens` integer, nullable, required
    - `cache_creation_input_tokens` integer, nullable, required
    - `cache_read_input_tokens` integer, nullable, required
    - `input_cost_usd` number, nullable, required
    - `output_cost_usd` number, nullable, required
    - `cache_read_cost_usd` number, nullable, required
    - `cache_creation_cost_usd` number, nullable, required
    - `total_cost_usd` number, nullable, required
    - `reasoning_content` string, nullable, required
    - `conversation_id` string, nullable, required
    - `conversation_name` string, nullable, required
    - `tool_name` string, nullable, required
    - `tool_type` string, nullable, required
    - `tool_call_id` string, nullable, required
    - `tool_description` string, nullable, required
    - `tool_definitions` string, nullable, required
    - `finish_reasons` string[], required
    - `error_type` string, nullable, required
    - `request_temperature` number, nullable, required
    - `request_max_tokens` integer, nullable, required
    - `request_top_p` number, nullable, required
    - `request_frequency_penalty` number, nullable, required
    - `request_presence_penalty` number, nullable, required
    - `request_seed` integer, nullable, required
    - `request_stop_sequences` string[], required
    - `request_choice_count` integer, nullable, required
    - `output_type` string, nullable, required
    - `input_messages` NormalizedMessage[], required
      - `role` string, required
      - `content` string, required
      - `finish_reason` string, required
    - `output_messages` NormalizedMessage[], required
      - `role` string, required
      - `content` string, required
      - `finish_reason` string, required
    - `system_instructions` string[], required
    - `tool_call_arguments` string, nullable, required
    - `tool_call_result` string, nullable, required
    - `compaction_summary` string, nullable, required
    - `compaction_items_before` integer, nullable, required
    - `compaction_items_after` integer, nullable, required
    - `content_refs` string[], required
    - `artifact_refs` string[], required
    - `object_refs` string[], required
    - `custom_attrs_string` object, required
    - `custom_attrs_int` object, required
    - `custom_attrs_float` object, required
    - `custom_attrs_bool` object, required
    - `server_address` string, nullable, required
    - `server_port` integer, nullable, required
    - `wb_user_id` string, nullable, required
    - `wb_run_id` string, nullable, required
    - `wb_run_step` integer, nullable, required
    - `wb_run_step_end` integer, nullable, required
    - `raw_span_dump` string, nullable, required
  - `groups` AgentSpanGroupRow[], required
    - `group_keys` object, required
    - `span_count` integer, required
    - `invocation_count` integer, required
    - `conversation_count` integer, required
    - `total_input_tokens` integer, required
    - `total_cache_creation_input_tokens` integer, required
    - `total_cache_read_input_tokens` integer, required
    - `total_output_tokens` integer, required
    - `total_reasoning_tokens` integer, required
    - `total_duration_ms` integer, required
    - `error_count` integer, required
    - `total_cost_usd` number, nullable, required
    - `total_input_cost_usd` number, nullable, required
    - `total_output_cost_usd` number, nullable, required
    - `agent_names` string[], required
    - `agent_versions` string[], required
    - `provider_names` string[], required
    - `request_models` string[], required
    - `conversation_names` string[], required
    - `first_seen` string, date-time, nullable, required
    - `last_seen` string, date-time, nullable, required
    - `first_message` AgentConversationMessagePreview, required: A truncated first/last message snippet for a grouped conversation row. `role` is the chat-timeline message type (e.g. "user_message", "assistant_message") so clients can style it consistently with the full chat view; `text` is the trimmed, length-capped preview content.
      - `role` 'user_message' | 'assistant_message', required
      - `text` string, required
    - `last_message` AgentConversationMessagePreview, required: A truncated first/last message snippet for a grouped conversation row. `role` is the chat-timeline message type (e.g. "user_message", "assistant_message") so clients can style it consistently with the full chat view; `text` is the trimmed, length-capped preview content.
      - `role` 'user_message' | 'assistant_message', required
      - `text` string, required
    - `metrics` object, required
    - `distributions` object, required
  - `total_count` integer, required

## Other responses

- `422`: Validation Error

## Changes

- **2026-10-22** `f7643c49bf2e`: 4 info
  - added the required property `spans/items/main_agent_id` to the response with the `200` status
  - added the required property `spans/items/main_agent_name` to the response with the `200` status
  - added the required property `spans/items/response_time_to_first_chunk` to the response with the `200` status
  - added the required property `spans/items/workflow_name` to the response with the `200` status
- **2026-10-16** `dd89fadfe4e4`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/wandb/apis/fastapi/changes/agents/spans/query/post.md)

---

[API](https://skmtc.dev/wandb/apis/fastapi.md) - [All operations](https://skmtc.dev/wandb/apis/fastapi/llms.txt) - [OpenAPI document](https://skmtc.dev/wandb/apis/fastapi/revisions/f7643c49bf2e?raw)
