---
title: "Fetch Spans"
method: GET
path: "/spans/"
tags: ["Traces"]
---

# Fetch Spans

`GET /spans/`

Fetch spans by known IDs.

Point lookup endpoint. At least one of `trace_id` or `span_id`
must be present. Both accept either repeated query params
(`?trace_id=a&trace_id=b`) or a comma-separated single param
(`?trace_ids=a,b`); results are deduplicated.

Returns `400` when neither IDs nor trace IDs are supplied.
For filter-based retrieval, use `POST /spans/query`.

## Query parameters

- `trace_id` string[], nullable
- `trace_ids` string, nullable
- `span_id` string[], nullable
- `span_ids` string, nullable

## Response `200`

Successful Response

- SpansResponse
  - `count` integer — Total number of matching spans in the window.
  - `spans` SpanOutput[], nullable — Flat list of matching spans.
    - `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
    - `session_id` string, nullable
    - `user_id` string, nullable
    - `agent_id` 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

---

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