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

---

[API](https://skmtc.net/comet-ml/apis/opik-rest-api.md) · [All operations](https://skmtc.net/comet-ml/apis/opik-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/comet-ml/opik-rest-api/versions/4ed2fbc97cc3/schema)
