---
title: "Fetch Legacy Analytics"
method: POST
path: "/tracing/spans/analytics"
tags: ["Legacy"]
---

# Fetch Legacy Analytics

`POST /tracing/spans/analytics`

Aggregate span metrics using the fixed legacy schema.

Returns time-bucketed aggregates with a fixed set of fields
(`count`, `duration`, `costs`, `tokens`) split into `total` and
`errors`. The shape predates `specs`-driven analytics and is kept
for the existing observability dashboards that consume it.

New integrations should prefer `POST /tracing/analytics/query`,
which accepts `specs` and can summarize arbitrary span attributes,
not just the four fixed metrics.

## Query parameters

- `focus` 'trace' | 'span'
- `format` 'agenta' | 'opentelemetry'
- `oldest` union
  - string
  - integer
- `newest` union
  - string
  - integer
- `limit` integer, nullable
- `interval` integer, nullable
- `rate` number, nullable
- `filter` unknown

## Response `200`

Successful Response

- OldAnalyticsResponse — Legacy analytics response with a fixed metric schema.
  - `count` integer — Number of time buckets returned.
  - `buckets` Bucket[] — Time-bucketed aggregates with fixed fields (`total`, `errors`) holding `count`, `duration`, `costs`, and `tokens`, ordered oldest to newest.
    - `timestamp` string, date-time, required
    - `interval` integer, required
    - `total` Analytics, required
      - `count` integer, nullable
      - `duration` number, nullable
      - `costs` number, nullable
      - `tokens` number, nullable
    - `errors` Analytics, required
      - `count` integer, nullable
      - `duration` number, nullable
      - `costs` number, nullable
      - `tokens` number, 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)
