---
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

## Changes

> 359 revisions in range; 4 could not be searched.

- **2026-05-19** `a7f9a6823230` — 2 warning
  - removed the optional property `support_id` from the response with the `200` status
  - removed the optional property `support_ts` from the response with the `200` status
- **2026-05-08** `4c92d005b4cf` — 3 info
  - api tag `Legacy` added
  - api tag `Deprecated` removed
  - endpoint reactivated
- **2026-05-08** `bb630edffa27` — 3 info
  - api tag `Deprecated` added
  - api tag `Traces` removed
  - endpoint deprecated
- **2026-05-02** `6e37373d45fe` — 2 info
  - api tag `Traces` added
  - api tag `Observability` removed
- **2026-04-23** `925e8b901a26` — 2 info
  - added the optional property `support_id` to the response with the `200` status
  - added the optional property `support_ts` to the response with the `200` status

[Full history](https://skmtc.dev/agenta-ai/apis/agenta-api/changes/tracing/spans/analytics/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/713e4f3b7519/schema)
