---
title: "Get workspace span metric"
method: POST
path: "/v1/private/workspaces/metrics/spans"
tags: ["Workspaces"]
---

# Get workspace span metric

`POST /v1/private/workspaces/metrics/spans`

Gets a span metric time series aggregated across the workspace. When project_ids is empty, all projects in the workspace are included; otherwise only the given projects.

## Request body

- WorkspaceSpanMetricRequest
  - `project_ids` string[]
  - `metric_type` 'FEEDBACK_SCORES' | 'TRACE_COUNT' | 'TOKEN_USAGE' | 'DURATION' | 'COST' | 'GUARDRAILS_FAILED_COUNT' | 'THREAD_COUNT' | 'THREAD_DURATION' | 'THREAD_FEEDBACK_SCORES' | 'SPAN_FEEDBACK_SCORES' | 'SPAN_COUNT' | 'SPAN_DURATION' | 'SPAN_TOKEN_USAGE' | 'TRACE_AVERAGE_DURATION' | 'TRACE_ERROR_RATE' | 'SPAN_AVERAGE_DURATION' | 'SPAN_COST' | 'SPAN_ERROR_RATE' | 'THREAD_AVERAGE_DURATION' | 'THREAD_COST'
  - `interval` 'HOURLY' | 'DAILY' | 'WEEKLY' | 'TOTAL'
  - `breakdown` BreakdownConfig
    - `field` 'none' | 'tags' | 'metadata' | 'name' | 'error_info' | 'error_type' | 'model' | 'provider' | 'type' | 'guardrail_name'
    - `metadata_key` string
    - `sub_metric` string
  - `filters` SpanFilter[]
    - `field` string
    - `operator` 'contains' | 'not_contains' | 'starts_with' | 'ends_with' | '=' | '!=' | '>' | '>=' | '<' | '<=' | 'is_empty' | 'is_not_empty' | 'in' | 'not_in'
    - `key` string
    - `value` string
  - `interval_start` string, date-time, required
  - `interval_end` string, date-time
  - `start_before_end` boolean

## Response `200`

Workspace span metric

- WorkspaceMetricResponse
  - `results` Result[]
    - `name` string
    - `current` number, double
    - `previous` number, double

## Other responses

- `400` — Bad Request

## Changes

- **2026-07-24** `b9b9c770fc73` — 1 info
  - added the new `guardrail_name` enum value to the request property `breakdown/field`
- **2026-07-14** `1f79c4b7b94c` — 1 info
  - endpoint added
- **2026-05-04** `d606e84c75e4` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/comet-ml/apis/opik-rest-api/changes/v1/private/workspaces/metrics/spans/post.md)

---

[API](https://skmtc.dev/comet-ml/apis/opik-rest-api.md) · [All operations](https://skmtc.dev/comet-ml/apis/opik-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/comet-ml/opik-rest-api/revisions/1a1bcfd67f99/schema)
