> For the complete documentation index, see [llms.txt](https://docs.concurrence.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.concurrence.com/api-reference/readme/platform/metrics.md).

# Metrics

## Search metric definitions

> Search the workspace's metric definitions, built-ins included unless \`\`include\_builtin\`\` is false.\
> \
> Permissions: authenticated (any role).

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"SearchString":{"type":"string","maxLength":200,"minLength":1},"MetricDefinitionListResponse":{"properties":{"items":{"items":{"$ref":"#/components/schemas/MetricDefinitionItem"},"type":"array","title":"Items"},"has_more":{"type":"boolean","title":"Has More"},"continuation_token":{"title":"Continuation Token"}},"type":"object","required":["items","has_more"],"title":"MetricDefinitionListResponse"},"MetricDefinitionItem":{"properties":{"definition":{"$ref":"#/components/schemas/MetricDefinition"},"revision":{"type":"integer","title":"Revision","description":"The latest revision of the key; 0 when it has none."},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Updated At","description":"When the latest revision was made; null when the key has none."},"transform_kind":{"type":"string","enum":["scalar","non_scalar"],"title":"Transform Kind","description":"Read-only: ``scalar`` for a per-entity metric, ``non_scalar`` for an aggregate one.","readOnly":true}},"type":"object","required":["definition","revision","updated_at","transform_kind"],"title":"MetricDefinitionItem"},"MetricDefinition":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"key":{"type":"string","maxLength":64,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$","title":"Key","description":"Lowercase slug used as metric key (e.g. 'voice_quality_score')"},"name":{"$ref":"#/components/schemas/NameString"},"description":{"anyOf":[{"$ref":"#/components/schemas/DescriptionString"},{"type":"null"}]},"metric_type":{"type":"string","enum":["numerical","categorical","boolean"],"title":"Metric Type"},"latency_tier":{"type":"string","enum":["streaming","near_realtime","batch"],"title":"Latency Tier","description":"'streaming': seconds of latency, fed continuously as events arrive. 'near_realtime': minutes of latency, refreshed on a trigger. 'batch': refreshed hourly or daily on a schedule (default, cheapest).","default":"batch"},"period_granularity":{"type":"string","enum":["hourly","daily"],"title":"Period Granularity","description":"'hourly' — one row per workspace per hour. Use for near_realtime metrics where shift-level visibility matters (voice quality, latency). 'daily' — one row per workspace per day (default, cheapest).","default":"daily"},"source":{"type":"string","enum":["call_intelligence","world_events","surface_events","connector_events","zerobus_events","voice_judge_results","custom"],"title":"Source","description":"Source key for the producer that supplies this metric. Built-ins include 'call_intelligence', 'world_events', and 'surface_events'. Use 'custom' with custom_source_key for extension producers."},"custom_source_key":{"anyOf":[{"type":"string","maxLength":128,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$"},{"type":"null"}],"title":"Custom Source Key","description":"Extension source key used only when source='custom'."},"event_types":{"items":{"type":"string"},"type":"array","maxItems":100,"minItems":1,"title":"Event Types","description":"Event types to scan (e.g. 'call.outcome', 'surface.submitted'). For call_intelligence source, use pseudo-types: 'call_intelligence.row'."},"source_filter":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Filter","description":"Optional SQL WHERE fragment for additional filtering (e.g. \"source = 'voice_agent'\"). Applied after event_type filter."},"extraction_mode":{"type":"string","enum":["static","ai_classify","ai_extract","ai_query","sql_expr"],"title":"Extraction Mode","description":"'static' — JSONB path extraction (fast, free). 'ai_classify' — AI classification into user-defined labels (free). 'ai_extract' — AI field extraction from text (free). 'ai_query' — LLM-powered extraction with custom prompt (uses model_tier). 'sql_expr' — Raw SQL expression for computed metrics.","default":"static"},"extract_path":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Extract Path","description":"JSON path for static extraction (e.g. `$.quality_score`, `$.risk_level`). For `call_intelligence` and `world_events`, single-segment paths resolve to typed columns when available and fall back to JSONB extraction otherwise. Used when `extraction_mode='static'`."},"ai_labels":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":500},{"type":"null"}],"title":"Ai Labels","description":"Labels for ai_classify, the allowed answers of a categorical ai_query metric, or field names for ai_extract. Required when extraction_mode='ai_classify' or 'ai_extract'. Examples: ['positive', 'negative', 'neutral'] or ['diagnosis', 'medication']."},"ai_schema":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Ai Schema","description":"Extraction schema for ai_extract. Required when extraction_mode='ai_extract'."},"ai_query_endpoint":{"anyOf":[{"type":"string","maxLength":256},{"type":"null"}],"title":"Ai Query Endpoint","description":"Model serving endpoint for ai_query. Optional — if omitted, platform resolves from model_tier automatically. Override for custom endpoints."},"ai_query_prompt":{"anyOf":[{"type":"string","maxLength":8000},{"type":"null"}],"title":"Ai Query Prompt","description":"Prompt template for ai_query. Use {data} placeholder for event data. Example: 'Classify this call transcript into one of: {labels}. Transcript: {data}'. Budgeted at 8KB to hold the full rubric + output spec for standard quality judges (longest authored rubric — conversational_naturalness — is ~5KB)."},"sql_expression":{"anyOf":[{"type":"string","maxLength":1000},{"type":"null"}],"title":"Sql Expression","description":"Raw SQL expression evaluated in pipeline context. Has access to all columns in the source table. Example: 'CASE WHEN duration_seconds > 120 THEN 1.0 ELSE 0.0 END'. Required when extraction_mode='sql_expr'."},"aggregation":{"type":"string","enum":["count","sum","avg","min","max","count_distinct","ratio","rate"],"title":"Aggregation","description":"How to aggregate extracted values per workspace per period. 'ratio' requires ratio_numerator_event and ratio_denominator_event. 'rate' computes count(true) / count(all) for boolean metrics.","default":"count"},"ratio_numerator_event":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ratio Numerator Event","description":"Event type for numerator when aggregation='ratio'."},"ratio_denominator_event":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ratio Denominator Event","description":"Event type for denominator when aggregation='ratio'."},"valid_range_min":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Valid Range Min","description":"Minimum valid value for numerical metrics. Pipeline drops values outside range."},"valid_range_max":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Valid Range Max","description":"Maximum valid value for numerical metrics."},"freshness_sla_minutes":{"type":"integer","maximum":1440,"minimum":5,"title":"Freshness Sla Minutes","description":"Max acceptable staleness in minutes before alerting. Default: 60 (1 hour).","default":60},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit","description":"Display unit (e.g. 'score', 'minutes', '%', 'count')."},"categories":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":100},{"type":"null"}],"title":"Categories","description":"Allowed values for categorical metrics. Pipeline drops values not in this list when set. An ai_query metric reads ai_labels instead, and falls back to categories only when ai_labels is empty."},"model_tier":{"type":"string","enum":["free","fast","balanced","max","custom"],"title":"Model Tier","description":"AI model tier for extraction quality/cost tradeoff. 'free' — platform managed models (ai_classify, ai_extract). 'fast' — optimized for simple classification, low latency. 'balanced' — quality scoring, moderate reasoning. 'max' — complex analysis, multi-step reasoning. 'custom' — use ai_query_endpoint directly. When extraction_mode='ai_query' and ai_query_endpoint is not set, platform resolves model_tier to the optimal model automatically.","default":"free"},"channel_scope":{"type":"string","enum":["all","voice","text","surface","inbound","outbound"],"title":"Channel Scope","description":"Business-logic channel filter. 'voice' — voice calls only. 'text' — SMS/text sessions. 'surface' — form submissions. 'inbound'/'outbound' — by direction. 'all' — no channel filter (default). Pipeline translates to appropriate source + event_type filters.","default":"all"},"applies_to_product_types":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Applies To Product Types","description":"Product types this metric applies to (matches service tags, e.g. 'scheduling', 'outbound', 'coaching', 'intake', 'triage', 'support'). When set, the metric only computes for calls belonging to services whose config.tags include one of these keys. When None (default), the metric applies to every service regardless of product type."},"prompt":{"anyOf":[{"type":"string","maxLength":4000},{"type":"null"}],"title":"Prompt","description":"Rubric prompt for LLM judge evaluation with {$.path} context variables. Each {$.path} reference is extracted from the entity's projected state and substituted before sending to ai_query. The prompt is both the evaluation criteria and the context specification."},"granularity":{"type":"string","enum":["aggregate","per_entity"],"title":"Granularity","description":"'aggregate' groups by (workspace, period) — one value per time bucket. 'per_entity' keeps entity_id — one value per entity (call, encounter). Judge metrics are typically per_entity. Computed metrics are typically aggregate.","default":"aggregate"},"tags":{"anyOf":[{"items":{"type":"string","maxLength":64,"minLength":1},"type":"array","maxItems":20},{"type":"null"}],"title":"Tags","description":"Up to 20 slugs (lowercase letters, digits, '-' and '_', at most 64 characters each)."},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Notes","description":"Free-text notes about the definition."},"active":{"type":"boolean","title":"Active","default":true},"builtin":{"type":"boolean","title":"Builtin","description":"True for platform-provided metrics (read-only key).","default":false}},"type":"object","required":["key","name","metric_type","source","event_types"],"title":"MetricDefinition","description":"A metric the platform computes for a workspace: what to extract from events, and how to aggregate it.\n\nBuilt-in metrics ship with every workspace. Custom metrics are defined per workspace through the settings\nAPI, and they extract with AI functions or with static paths into the event data."},"NameString":{"maxLength":256,"minLength":1,"type":"string"},"DescriptionString":{"type":"string","maxLength":2000},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/metric-definitions":{"get":{"tags":["Metrics"],"summary":"Search metric definitions","description":"Search the workspace's metric definitions, built-ins included unless ``include_builtin`` is false.\n\nPermissions: authenticated (any role).","operationId":"list-metric-definitions","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"sort_by","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"},"default":[],"title":"Sort By"}},{"name":"query","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/SearchString"},{"type":"null"}],"description":"Case-insensitive substring of the key, name or description.","title":"Query"},"description":"Case-insensitive substring of the key, name or description."},{"name":"tag","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/SearchString"},{"type":"null"}],"title":"Tag"}},{"name":"service_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Keep the definitions that apply to this service's product types (its tag keys), or to every service.","title":"Service Id"},"description":"Keep the definitions that apply to this service's product types (its tag keys), or to every service."},{"name":"include_builtin","in":"query","required":false,"schema":{"type":"boolean","default":true,"title":"Include Builtin"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"exclusiveMinimum":0,"default":50,"title":"Limit"}},{"name":"continuation_token","in":"query","required":false,"schema":{"title":"Continuation Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricDefinitionListResponse"}}}},"404":{"description":"Service not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"429":{"description":"Rate limited"}}}}}}
```

## Get a metric definition

> Get one metric definition with its latest revision.\
> \
> Permissions: authenticated (any role).

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"MetricDefinitionItem":{"properties":{"definition":{"$ref":"#/components/schemas/MetricDefinition"},"revision":{"type":"integer","title":"Revision","description":"The latest revision of the key; 0 when it has none."},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Updated At","description":"When the latest revision was made; null when the key has none."},"transform_kind":{"type":"string","enum":["scalar","non_scalar"],"title":"Transform Kind","description":"Read-only: ``scalar`` for a per-entity metric, ``non_scalar`` for an aggregate one.","readOnly":true}},"type":"object","required":["definition","revision","updated_at","transform_kind"],"title":"MetricDefinitionItem"},"MetricDefinition":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"key":{"type":"string","maxLength":64,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$","title":"Key","description":"Lowercase slug used as metric key (e.g. 'voice_quality_score')"},"name":{"$ref":"#/components/schemas/NameString"},"description":{"anyOf":[{"$ref":"#/components/schemas/DescriptionString"},{"type":"null"}]},"metric_type":{"type":"string","enum":["numerical","categorical","boolean"],"title":"Metric Type"},"latency_tier":{"type":"string","enum":["streaming","near_realtime","batch"],"title":"Latency Tier","description":"'streaming': seconds of latency, fed continuously as events arrive. 'near_realtime': minutes of latency, refreshed on a trigger. 'batch': refreshed hourly or daily on a schedule (default, cheapest).","default":"batch"},"period_granularity":{"type":"string","enum":["hourly","daily"],"title":"Period Granularity","description":"'hourly' — one row per workspace per hour. Use for near_realtime metrics where shift-level visibility matters (voice quality, latency). 'daily' — one row per workspace per day (default, cheapest).","default":"daily"},"source":{"type":"string","enum":["call_intelligence","world_events","surface_events","connector_events","zerobus_events","voice_judge_results","custom"],"title":"Source","description":"Source key for the producer that supplies this metric. Built-ins include 'call_intelligence', 'world_events', and 'surface_events'. Use 'custom' with custom_source_key for extension producers."},"custom_source_key":{"anyOf":[{"type":"string","maxLength":128,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$"},{"type":"null"}],"title":"Custom Source Key","description":"Extension source key used only when source='custom'."},"event_types":{"items":{"type":"string"},"type":"array","maxItems":100,"minItems":1,"title":"Event Types","description":"Event types to scan (e.g. 'call.outcome', 'surface.submitted'). For call_intelligence source, use pseudo-types: 'call_intelligence.row'."},"source_filter":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Filter","description":"Optional SQL WHERE fragment for additional filtering (e.g. \"source = 'voice_agent'\"). Applied after event_type filter."},"extraction_mode":{"type":"string","enum":["static","ai_classify","ai_extract","ai_query","sql_expr"],"title":"Extraction Mode","description":"'static' — JSONB path extraction (fast, free). 'ai_classify' — AI classification into user-defined labels (free). 'ai_extract' — AI field extraction from text (free). 'ai_query' — LLM-powered extraction with custom prompt (uses model_tier). 'sql_expr' — Raw SQL expression for computed metrics.","default":"static"},"extract_path":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Extract Path","description":"JSON path for static extraction (e.g. `$.quality_score`, `$.risk_level`). For `call_intelligence` and `world_events`, single-segment paths resolve to typed columns when available and fall back to JSONB extraction otherwise. Used when `extraction_mode='static'`."},"ai_labels":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":500},{"type":"null"}],"title":"Ai Labels","description":"Labels for ai_classify, the allowed answers of a categorical ai_query metric, or field names for ai_extract. Required when extraction_mode='ai_classify' or 'ai_extract'. Examples: ['positive', 'negative', 'neutral'] or ['diagnosis', 'medication']."},"ai_schema":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Ai Schema","description":"Extraction schema for ai_extract. Required when extraction_mode='ai_extract'."},"ai_query_endpoint":{"anyOf":[{"type":"string","maxLength":256},{"type":"null"}],"title":"Ai Query Endpoint","description":"Model serving endpoint for ai_query. Optional — if omitted, platform resolves from model_tier automatically. Override for custom endpoints."},"ai_query_prompt":{"anyOf":[{"type":"string","maxLength":8000},{"type":"null"}],"title":"Ai Query Prompt","description":"Prompt template for ai_query. Use {data} placeholder for event data. Example: 'Classify this call transcript into one of: {labels}. Transcript: {data}'. Budgeted at 8KB to hold the full rubric + output spec for standard quality judges (longest authored rubric — conversational_naturalness — is ~5KB)."},"sql_expression":{"anyOf":[{"type":"string","maxLength":1000},{"type":"null"}],"title":"Sql Expression","description":"Raw SQL expression evaluated in pipeline context. Has access to all columns in the source table. Example: 'CASE WHEN duration_seconds > 120 THEN 1.0 ELSE 0.0 END'. Required when extraction_mode='sql_expr'."},"aggregation":{"type":"string","enum":["count","sum","avg","min","max","count_distinct","ratio","rate"],"title":"Aggregation","description":"How to aggregate extracted values per workspace per period. 'ratio' requires ratio_numerator_event and ratio_denominator_event. 'rate' computes count(true) / count(all) for boolean metrics.","default":"count"},"ratio_numerator_event":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ratio Numerator Event","description":"Event type for numerator when aggregation='ratio'."},"ratio_denominator_event":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ratio Denominator Event","description":"Event type for denominator when aggregation='ratio'."},"valid_range_min":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Valid Range Min","description":"Minimum valid value for numerical metrics. Pipeline drops values outside range."},"valid_range_max":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Valid Range Max","description":"Maximum valid value for numerical metrics."},"freshness_sla_minutes":{"type":"integer","maximum":1440,"minimum":5,"title":"Freshness Sla Minutes","description":"Max acceptable staleness in minutes before alerting. Default: 60 (1 hour).","default":60},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit","description":"Display unit (e.g. 'score', 'minutes', '%', 'count')."},"categories":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":100},{"type":"null"}],"title":"Categories","description":"Allowed values for categorical metrics. Pipeline drops values not in this list when set. An ai_query metric reads ai_labels instead, and falls back to categories only when ai_labels is empty."},"model_tier":{"type":"string","enum":["free","fast","balanced","max","custom"],"title":"Model Tier","description":"AI model tier for extraction quality/cost tradeoff. 'free' — platform managed models (ai_classify, ai_extract). 'fast' — optimized for simple classification, low latency. 'balanced' — quality scoring, moderate reasoning. 'max' — complex analysis, multi-step reasoning. 'custom' — use ai_query_endpoint directly. When extraction_mode='ai_query' and ai_query_endpoint is not set, platform resolves model_tier to the optimal model automatically.","default":"free"},"channel_scope":{"type":"string","enum":["all","voice","text","surface","inbound","outbound"],"title":"Channel Scope","description":"Business-logic channel filter. 'voice' — voice calls only. 'text' — SMS/text sessions. 'surface' — form submissions. 'inbound'/'outbound' — by direction. 'all' — no channel filter (default). Pipeline translates to appropriate source + event_type filters.","default":"all"},"applies_to_product_types":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Applies To Product Types","description":"Product types this metric applies to (matches service tags, e.g. 'scheduling', 'outbound', 'coaching', 'intake', 'triage', 'support'). When set, the metric only computes for calls belonging to services whose config.tags include one of these keys. When None (default), the metric applies to every service regardless of product type."},"prompt":{"anyOf":[{"type":"string","maxLength":4000},{"type":"null"}],"title":"Prompt","description":"Rubric prompt for LLM judge evaluation with {$.path} context variables. Each {$.path} reference is extracted from the entity's projected state and substituted before sending to ai_query. The prompt is both the evaluation criteria and the context specification."},"granularity":{"type":"string","enum":["aggregate","per_entity"],"title":"Granularity","description":"'aggregate' groups by (workspace, period) — one value per time bucket. 'per_entity' keeps entity_id — one value per entity (call, encounter). Judge metrics are typically per_entity. Computed metrics are typically aggregate.","default":"aggregate"},"tags":{"anyOf":[{"items":{"type":"string","maxLength":64,"minLength":1},"type":"array","maxItems":20},{"type":"null"}],"title":"Tags","description":"Up to 20 slugs (lowercase letters, digits, '-' and '_', at most 64 characters each)."},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Notes","description":"Free-text notes about the definition."},"active":{"type":"boolean","title":"Active","default":true},"builtin":{"type":"boolean","title":"Builtin","description":"True for platform-provided metrics (read-only key).","default":false}},"type":"object","required":["key","name","metric_type","source","event_types"],"title":"MetricDefinition","description":"A metric the platform computes for a workspace: what to extract from events, and how to aggregate it.\n\nBuilt-in metrics ship with every workspace. Custom metrics are defined per workspace through the settings\nAPI, and they extract with AI functions or with static paths into the event data."},"NameString":{"maxLength":256,"minLength":1,"type":"string"},"DescriptionString":{"type":"string","maxLength":2000},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/metric-definitions/{key}":{"get":{"tags":["Metrics"],"summary":"Get a metric definition","description":"Get one metric definition with its latest revision.\n\nPermissions: authenticated (any role).","operationId":"get-metric-definition","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"key","in":"path","required":true,"schema":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_]*$","title":"Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricDefinitionItem"}}}},"404":{"description":"Metric not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"429":{"description":"Rate limited"}}}}}}
```

## Create or replace a metric definition

> Create or replace one metric definition.\
> \
> \`\`expected\_revision\`\` is the revision the caller read (0 for a new key); a key at another revision is a 409\
> and nothing is saved. A built-in accepts changes to its override fields only (\`\`active\`\`,\
> \`\`freshness\_sla\_minutes\`\`, \`\`id\`\`, \`\`valid\_range\_min\`\`, \`\`valid\_range\_max\`\`, \`\`period\_granularity\`\`); any other\
> difference from the built-in is a 422.\
> \
> Permissions: admin, owner.

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"PutMetricDefinitionRequest":{"properties":{"definition":{"$ref":"#/components/schemas/MetricDefinition"},"expected_revision":{"type":"integer","minimum":0,"title":"Expected Revision","description":"The revision the caller read; 0 for a key with none."},"note":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Note"}},"type":"object","required":["definition","expected_revision"],"title":"PutMetricDefinitionRequest"},"MetricDefinition":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"key":{"type":"string","maxLength":64,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$","title":"Key","description":"Lowercase slug used as metric key (e.g. 'voice_quality_score')"},"name":{"$ref":"#/components/schemas/NameString"},"description":{"anyOf":[{"$ref":"#/components/schemas/DescriptionString"},{"type":"null"}]},"metric_type":{"type":"string","enum":["numerical","categorical","boolean"],"title":"Metric Type"},"latency_tier":{"type":"string","enum":["streaming","near_realtime","batch"],"title":"Latency Tier","description":"'streaming': seconds of latency, fed continuously as events arrive. 'near_realtime': minutes of latency, refreshed on a trigger. 'batch': refreshed hourly or daily on a schedule (default, cheapest).","default":"batch"},"period_granularity":{"type":"string","enum":["hourly","daily"],"title":"Period Granularity","description":"'hourly' — one row per workspace per hour. Use for near_realtime metrics where shift-level visibility matters (voice quality, latency). 'daily' — one row per workspace per day (default, cheapest).","default":"daily"},"source":{"type":"string","enum":["call_intelligence","world_events","surface_events","connector_events","zerobus_events","voice_judge_results","custom"],"title":"Source","description":"Source key for the producer that supplies this metric. Built-ins include 'call_intelligence', 'world_events', and 'surface_events'. Use 'custom' with custom_source_key for extension producers."},"custom_source_key":{"anyOf":[{"type":"string","maxLength":128,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$"},{"type":"null"}],"title":"Custom Source Key","description":"Extension source key used only when source='custom'."},"event_types":{"items":{"type":"string"},"type":"array","maxItems":100,"minItems":1,"title":"Event Types","description":"Event types to scan (e.g. 'call.outcome', 'surface.submitted'). For call_intelligence source, use pseudo-types: 'call_intelligence.row'."},"source_filter":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Filter","description":"Optional SQL WHERE fragment for additional filtering (e.g. \"source = 'voice_agent'\"). Applied after event_type filter."},"extraction_mode":{"type":"string","enum":["static","ai_classify","ai_extract","ai_query","sql_expr"],"title":"Extraction Mode","description":"'static' — JSONB path extraction (fast, free). 'ai_classify' — AI classification into user-defined labels (free). 'ai_extract' — AI field extraction from text (free). 'ai_query' — LLM-powered extraction with custom prompt (uses model_tier). 'sql_expr' — Raw SQL expression for computed metrics.","default":"static"},"extract_path":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Extract Path","description":"JSON path for static extraction (e.g. `$.quality_score`, `$.risk_level`). For `call_intelligence` and `world_events`, single-segment paths resolve to typed columns when available and fall back to JSONB extraction otherwise. Used when `extraction_mode='static'`."},"ai_labels":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":500},{"type":"null"}],"title":"Ai Labels","description":"Labels for ai_classify, the allowed answers of a categorical ai_query metric, or field names for ai_extract. Required when extraction_mode='ai_classify' or 'ai_extract'. Examples: ['positive', 'negative', 'neutral'] or ['diagnosis', 'medication']."},"ai_schema":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Ai Schema","description":"Extraction schema for ai_extract. Required when extraction_mode='ai_extract'."},"ai_query_endpoint":{"anyOf":[{"type":"string","maxLength":256},{"type":"null"}],"title":"Ai Query Endpoint","description":"Model serving endpoint for ai_query. Optional — if omitted, platform resolves from model_tier automatically. Override for custom endpoints."},"ai_query_prompt":{"anyOf":[{"type":"string","maxLength":8000},{"type":"null"}],"title":"Ai Query Prompt","description":"Prompt template for ai_query. Use {data} placeholder for event data. Example: 'Classify this call transcript into one of: {labels}. Transcript: {data}'. Budgeted at 8KB to hold the full rubric + output spec for standard quality judges (longest authored rubric — conversational_naturalness — is ~5KB)."},"sql_expression":{"anyOf":[{"type":"string","maxLength":1000},{"type":"null"}],"title":"Sql Expression","description":"Raw SQL expression evaluated in pipeline context. Has access to all columns in the source table. Example: 'CASE WHEN duration_seconds > 120 THEN 1.0 ELSE 0.0 END'. Required when extraction_mode='sql_expr'."},"aggregation":{"type":"string","enum":["count","sum","avg","min","max","count_distinct","ratio","rate"],"title":"Aggregation","description":"How to aggregate extracted values per workspace per period. 'ratio' requires ratio_numerator_event and ratio_denominator_event. 'rate' computes count(true) / count(all) for boolean metrics.","default":"count"},"ratio_numerator_event":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ratio Numerator Event","description":"Event type for numerator when aggregation='ratio'."},"ratio_denominator_event":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ratio Denominator Event","description":"Event type for denominator when aggregation='ratio'."},"valid_range_min":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Valid Range Min","description":"Minimum valid value for numerical metrics. Pipeline drops values outside range."},"valid_range_max":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Valid Range Max","description":"Maximum valid value for numerical metrics."},"freshness_sla_minutes":{"type":"integer","maximum":1440,"minimum":5,"title":"Freshness Sla Minutes","description":"Max acceptable staleness in minutes before alerting. Default: 60 (1 hour).","default":60},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit","description":"Display unit (e.g. 'score', 'minutes', '%', 'count')."},"categories":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":100},{"type":"null"}],"title":"Categories","description":"Allowed values for categorical metrics. Pipeline drops values not in this list when set. An ai_query metric reads ai_labels instead, and falls back to categories only when ai_labels is empty."},"model_tier":{"type":"string","enum":["free","fast","balanced","max","custom"],"title":"Model Tier","description":"AI model tier for extraction quality/cost tradeoff. 'free' — platform managed models (ai_classify, ai_extract). 'fast' — optimized for simple classification, low latency. 'balanced' — quality scoring, moderate reasoning. 'max' — complex analysis, multi-step reasoning. 'custom' — use ai_query_endpoint directly. When extraction_mode='ai_query' and ai_query_endpoint is not set, platform resolves model_tier to the optimal model automatically.","default":"free"},"channel_scope":{"type":"string","enum":["all","voice","text","surface","inbound","outbound"],"title":"Channel Scope","description":"Business-logic channel filter. 'voice' — voice calls only. 'text' — SMS/text sessions. 'surface' — form submissions. 'inbound'/'outbound' — by direction. 'all' — no channel filter (default). Pipeline translates to appropriate source + event_type filters.","default":"all"},"applies_to_product_types":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Applies To Product Types","description":"Product types this metric applies to (matches service tags, e.g. 'scheduling', 'outbound', 'coaching', 'intake', 'triage', 'support'). When set, the metric only computes for calls belonging to services whose config.tags include one of these keys. When None (default), the metric applies to every service regardless of product type."},"prompt":{"anyOf":[{"type":"string","maxLength":4000},{"type":"null"}],"title":"Prompt","description":"Rubric prompt for LLM judge evaluation with {$.path} context variables. Each {$.path} reference is extracted from the entity's projected state and substituted before sending to ai_query. The prompt is both the evaluation criteria and the context specification."},"granularity":{"type":"string","enum":["aggregate","per_entity"],"title":"Granularity","description":"'aggregate' groups by (workspace, period) — one value per time bucket. 'per_entity' keeps entity_id — one value per entity (call, encounter). Judge metrics are typically per_entity. Computed metrics are typically aggregate.","default":"aggregate"},"tags":{"anyOf":[{"items":{"type":"string","maxLength":64,"minLength":1},"type":"array","maxItems":20},{"type":"null"}],"title":"Tags","description":"Up to 20 slugs (lowercase letters, digits, '-' and '_', at most 64 characters each)."},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Notes","description":"Free-text notes about the definition."},"active":{"type":"boolean","title":"Active","default":true},"builtin":{"type":"boolean","title":"Builtin","description":"True for platform-provided metrics (read-only key).","default":false}},"type":"object","required":["key","name","metric_type","source","event_types"],"title":"MetricDefinition","description":"A metric the platform computes for a workspace: what to extract from events, and how to aggregate it.\n\nBuilt-in metrics ship with every workspace. Custom metrics are defined per workspace through the settings\nAPI, and they extract with AI functions or with static paths into the event data."},"NameString":{"maxLength":256,"minLength":1,"type":"string"},"DescriptionString":{"type":"string","maxLength":2000},"MetricDefinitionItem":{"properties":{"definition":{"$ref":"#/components/schemas/MetricDefinition"},"revision":{"type":"integer","title":"Revision","description":"The latest revision of the key; 0 when it has none."},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Updated At","description":"When the latest revision was made; null when the key has none."},"transform_kind":{"type":"string","enum":["scalar","non_scalar"],"title":"Transform Kind","description":"Read-only: ``scalar`` for a per-entity metric, ``non_scalar`` for an aggregate one.","readOnly":true}},"type":"object","required":["definition","revision","updated_at","transform_kind"],"title":"MetricDefinitionItem"}}},"paths":{"/v1/{workspace_id}/metric-definitions/{key}":{"put":{"tags":["Metrics"],"summary":"Create or replace a metric definition","description":"Create or replace one metric definition.\n\n``expected_revision`` is the revision the caller read (0 for a new key); a key at another revision is a 409\nand nothing is saved. A built-in accepts changes to its override fields only (``active``,\n``freshness_sla_minutes``, ``id``, ``valid_range_min``, ``valid_range_max``, ``period_granularity``); any other\ndifference from the built-in is a 422.\n\nPermissions: admin, owner.","operationId":"put-metric-definition","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"key","in":"path","required":true,"schema":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_]*$","title":"Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutMetricDefinitionRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricDefinitionItem"}}}},"404":{"description":"Workspace not found"},"409":{"description":"The key is at another revision than expected_revision"},"422":{"description":"Validation error"},"429":{"description":"Rate limited"}}}}}}
```

## Delete a custom metric definition

> Delete a custom metric definition. Its results stay.\
> \
> Permissions: admin, owner.

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}}},"paths":{"/v1/{workspace_id}/metric-definitions/{key}":{"delete":{"tags":["Metrics"],"summary":"Delete a custom metric definition","description":"Delete a custom metric definition. Its results stay.\n\nPermissions: admin, owner.","operationId":"delete-metric-definition","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"key","in":"path","required":true,"schema":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_]*$","title":"Key"}}],"responses":{"204":{"description":"Successful Response"},"404":{"description":"Metric not found"},"409":{"description":"The metric changed while it was being deleted"},"422":{"description":"A built-in metric can't be deleted"},"429":{"description":"Rate limited"}}}}}}
```

## List a metric definition's revisions

> A key's revisions, newest first, without their definitions.\
> \
> Permissions: authenticated (any role).

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"MetricDefinitionRevisionListResponse":{"properties":{"items":{"items":{"$ref":"#/components/schemas/MetricDefinitionRevision"},"type":"array","title":"Items"},"has_more":{"type":"boolean","title":"Has More"},"continuation_token":{"title":"Continuation Token"}},"type":"object","required":["items","has_more"],"title":"MetricDefinitionRevisionListResponse"},"MetricDefinitionRevision":{"properties":{"revision":{"type":"integer","title":"Revision"},"definition_version":{"type":"string","title":"Definition Version"},"change":{"type":"string","enum":["created","updated","deleted"],"title":"Change"},"note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note"},"created_by_credential_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Created By Credential Id"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["revision","definition_version","change","note","created_by_credential_id","created_at"],"title":"MetricDefinitionRevision"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/metric-definitions/{key}/revisions":{"get":{"tags":["Metrics"],"summary":"List a metric definition's revisions","description":"A key's revisions, newest first, without their definitions.\n\nPermissions: authenticated (any role).","operationId":"list-metric-definition-revisions","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"key","in":"path","required":true,"schema":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_]*$","title":"Key"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"exclusiveMinimum":0,"default":50,"title":"Limit"}},{"name":"continuation_token","in":"query","required":false,"schema":{"title":"Continuation Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricDefinitionRevisionListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"429":{"description":"Rate limited"}}}}}}
```

## Get one revision of a metric definition

> One revision of a key, with the definition as saved (the removed one for a delete).\
> \
> Permissions: authenticated (any role).

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"MetricDefinitionRevisionDetail":{"properties":{"revision":{"type":"integer","title":"Revision"},"definition_version":{"type":"string","title":"Definition Version"},"change":{"type":"string","enum":["created","updated","deleted"],"title":"Change"},"note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note"},"created_by_credential_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Created By Credential Id"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"definition":{"additionalProperties":true,"type":"object","title":"Definition"}},"type":"object","required":["revision","definition_version","change","note","created_by_credential_id","created_at","definition"],"title":"MetricDefinitionRevisionDetail"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/metric-definitions/{key}/revisions/{revision}":{"get":{"tags":["Metrics"],"summary":"Get one revision of a metric definition","description":"One revision of a key, with the definition as saved (the removed one for a delete).\n\nPermissions: authenticated (any role).","operationId":"get-metric-definition-revision","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"key","in":"path","required":true,"schema":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_]*$","title":"Key"}},{"name":"revision","in":"path","required":true,"schema":{"type":"integer","minimum":1,"title":"Revision"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricDefinitionRevisionDetail"}}}},"404":{"description":"Revision not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"429":{"description":"Rate limited"}}}}}}
```

## List latest metric values

> List metric values. By default, the newest period of each metric series.\
> \
> A categorical or boolean series folds its newest period into one row:\
> \`\`distribution\`\` counts each value and \`\`value\`\` is the most frequent.\
> Only defined metrics are listed (builtins and saved definitions), the keys the get and trend routes accept.\
> Pages cover the first 10,000 values; narrow the filters or dates to read past them.\
> \
> Permissions: authenticated (any role).

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"MetricValueListResponse":{"properties":{"metrics":{"items":{"oneOf":[{"$ref":"#/components/schemas/NumericalMetricValueResponse"},{"$ref":"#/components/schemas/CategoricalMetricValueResponse"},{"$ref":"#/components/schemas/BooleanMetricValueResponse"}],"discriminator":{"propertyName":"metric_type","mapping":{"boolean":"#/components/schemas/BooleanMetricValueResponse","categorical":"#/components/schemas/CategoricalMetricValueResponse","numerical":"#/components/schemas/NumericalMetricValueResponse"}}},"type":"array","title":"Metrics"},"has_more":{"type":"boolean","title":"Has More"},"continuation_token":{"title":"Continuation Token"}},"type":"object","required":["metrics","has_more"],"title":"MetricValueListResponse"},"NumericalMetricValueResponse":{"properties":{"metric_key":{"type":"string","title":"Metric Key"},"source":{"type":"string","title":"Source","default":"production"},"entity_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"},"entity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"},"service_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Id"},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"session_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Session Id"},"period_start":{"type":"string","format":"date-time","title":"Period Start"},"period_end":{"type":"string","format":"date-time","title":"Period End"},"event_count":{"type":"integer","title":"Event Count"},"avg_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Confidence"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"computed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Computed At"},"metric_type":{"type":"string","const":"numerical","title":"Metric Type"},"value":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Value"}},"type":"object","required":["metric_key","period_start","period_end","event_count","metric_type","value"],"title":"NumericalMetricValueResponse"},"CategoricalMetricValueResponse":{"properties":{"metric_key":{"type":"string","title":"Metric Key"},"source":{"type":"string","title":"Source","default":"production"},"entity_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"},"entity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"},"service_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Id"},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"session_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Session Id"},"period_start":{"type":"string","format":"date-time","title":"Period Start"},"period_end":{"type":"string","format":"date-time","title":"Period End"},"event_count":{"type":"integer","title":"Event Count"},"avg_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Confidence"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"computed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Computed At"},"metric_type":{"type":"string","const":"categorical","title":"Metric Type"},"value":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Value","description":"The category this row counts. A list-metrics latest row gives its period's most frequent category."},"distribution":{"items":{"$ref":"#/components/schemas/CategoryCount"},"type":"array","title":"Distribution","description":"Events per category in this row's period, most frequent first. A list-metrics latest row\nlists every category its period saw; any other row lists its own category.","default":[]}},"type":"object","required":["metric_key","period_start","period_end","event_count","metric_type","value"],"title":"CategoricalMetricValueResponse"},"CategoryCount":{"properties":{"value":{"type":"string","title":"Value"},"count":{"type":"integer","title":"Count"}},"type":"object","required":["value","count"],"title":"CategoryCount"},"BooleanMetricValueResponse":{"properties":{"metric_key":{"type":"string","title":"Metric Key"},"source":{"type":"string","title":"Source","default":"production"},"entity_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"},"entity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"},"service_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Id"},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"session_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Session Id"},"period_start":{"type":"string","format":"date-time","title":"Period Start"},"period_end":{"type":"string","format":"date-time","title":"Period End"},"event_count":{"type":"integer","title":"Event Count"},"avg_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Confidence"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"computed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Computed At"},"metric_type":{"type":"string","const":"boolean","title":"Metric Type"},"value":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Value","description":"The value this row counts. A list-metrics latest row gives its period's more frequent value."},"distribution":{"items":{"$ref":"#/components/schemas/BooleanCount"},"type":"array","title":"Distribution","description":"Events per value in this row's period, most frequent first. A list-metrics latest row\nlists both values its period saw; any other row lists its own value.","default":[]}},"type":"object","required":["metric_key","period_start","period_end","event_count","metric_type","value"],"title":"BooleanMetricValueResponse"},"BooleanCount":{"properties":{"value":{"type":"boolean","title":"Value"},"count":{"type":"integer","title":"Count"}},"type":"object","required":["value","count"],"title":"BooleanCount"},"ValidationErrorResponse":{"properties":{"detail":{"anyOf":[{"type":"string"},{"items":{"additionalProperties":true,"type":"object"},"type":"array"}],"title":"Detail"}},"type":"object","required":["detail"],"title":"ValidationErrorResponse","description":"The body of a 422.\n\n``detail`` is a string when a route refuses the request itself, and a list of error objects when\nthe request fails validation before the route runs."},"AnalyticsUnavailableResponse":{"properties":{"detail":{"type":"string","const":"Analytics unavailable","title":"Detail"}},"type":"object","required":["detail"],"title":"AnalyticsUnavailableResponse","description":"The 503 body when the route couldn't read its data."}}},"paths":{"/v1/{workspace_id}/metrics":{"get":{"tags":["Metrics"],"summary":"List latest metric values","description":"List metric values. By default, the newest period of each metric series.\n\nA categorical or boolean series folds its newest period into one row:\n``distribution`` counts each value and ``value`` is the most frequent.\nOnly defined metrics are listed (builtins and saved definitions), the keys the get and trend routes accept.\nPages cover the first 10,000 values; narrow the filters or dates to read past them.\n\nPermissions: authenticated (any role).","operationId":"list-metrics","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"sort_by","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"},"description":"Order of the page, e.g. `-period_start` (the default, newest first) or `+metric_key`.","default":[],"title":"Sort By"},"description":"Order of the page, e.g. `-period_start` (the default, newest first) or `+metric_key`."},{"name":"source","in":"query","required":false,"schema":{"enum":["production","simulation","all"],"type":"string","default":"production","title":"Source"}},{"name":"scope","in":"query","required":false,"schema":{"enum":["aggregate","entity","all"],"type":"string","default":"aggregate","title":"Scope"}},{"name":"entity_type","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Entity Type"}},{"name":"entity_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":128},{"type":"null"}],"title":"Entity Id"}},{"name":"service_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Service Id"}},{"name":"run_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Run Id"}},{"name":"session_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":128},{"type":"null"}],"title":"Session Id"}},{"name":"date_from","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Date From"}},{"name":"date_to","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Date To"}},{"name":"latest_only","in":"query","required":false,"schema":{"type":"boolean","description":"Return each series' newest period only, a categorical or boolean period folded into one row.","default":true,"title":"Latest Only"},"description":"Return each series' newest period only, a categorical or boolean period folded into one row."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"exclusiveMinimum":0,"default":100,"title":"Limit"}},{"name":"continuation_token","in":"query","required":false,"schema":{"title":"Continuation Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricValueListResponse"}}}},"422":{"description":"Invalid continuation_token or date range, or a page past the first 10,000 values","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"429":{"description":"Rate limited"},"503":{"description":"Analytics unavailable: the route couldn't read its data, so treat this 503 as no answer, not as zero. A 200 is always a measured answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyticsUnavailableResponse"}}}}}}}}}
```

## List available metrics (builtin + custom)

> List the workspace's active metrics: builtins plus custom definitions.\
> \
> Resolved from the workspace's metric settings, so a builtin turned off\
> there is not listed.\
> \
> Permissions: authenticated (any role).

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"MetricCatalogResponse":{"properties":{"metrics":{"items":{"$ref":"#/components/schemas/MetricCatalogEntry"},"type":"array","title":"Metrics"}},"type":"object","required":["metrics"],"title":"MetricCatalogResponse"},"MetricCatalogEntry":{"properties":{"key":{"type":"string","maxLength":64,"minLength":1,"pattern":"^[a-z][a-z0-9_]*$","title":"Key","description":"Metric key (lowercase alphanumeric + underscores)"},"name":{"$ref":"#/components/schemas/NameString"},"description":{"anyOf":[{"$ref":"#/components/schemas/DescriptionString"},{"type":"null"}]},"metric_type":{"type":"string","enum":["numerical","categorical","boolean"],"title":"Metric Type"},"source":{"type":"string","enum":["call_intelligence","world_events","surface_events","connector_events","zerobus_events","voice_judge_results","custom"],"title":"Source"},"custom_source_key":{"anyOf":[{"type":"string","maxLength":128,"pattern":"^[a-z][a-z0-9_]*$"},{"type":"null"}],"title":"Custom Source Key"},"extraction_mode":{"type":"string","enum":["static","ai_classify","ai_extract","ai_query","sql_expr"],"title":"Extraction Mode","default":"static"},"granularity":{"type":"string","enum":["aggregate","per_entity"],"title":"Granularity","default":"aggregate"},"period_granularity":{"type":"string","enum":["hourly","daily"],"title":"Period Granularity","default":"daily"},"latency_tier":{"type":"string","enum":["streaming","near_realtime","batch"],"title":"Latency Tier","default":"batch"},"model_tier":{"type":"string","enum":["free","fast","balanced","max","custom"],"title":"Model Tier","default":"free"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"has_prompt":{"type":"boolean","title":"Has Prompt","default":false},"builtin":{"type":"boolean","title":"Builtin"}},"type":"object","required":["key","name","metric_type","source","builtin"],"title":"MetricCatalogEntry"},"NameString":{"maxLength":256,"minLength":1,"type":"string"},"DescriptionString":{"type":"string","maxLength":2000}}},"paths":{"/v1/{workspace_id}/metrics/catalog":{"get":{"tags":["Metrics"],"summary":"List available metrics (builtin + custom)","description":"List the workspace's active metrics: builtins plus custom definitions.\n\nResolved from the workspace's metric settings, so a builtin turned off\nthere is not listed.\n\nPermissions: authenticated (any role).","operationId":"get-metric-catalog","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricCatalogResponse"}}}},"429":{"description":"Rate limited"}},"parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}}]}}}}
```

## Get values for a specific metric

> Get values for a specific metric with optional time range, newest period first.\
> \
> Permissions: authenticated (any role).

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"MetricListResponse":{"properties":{"metrics":{"items":{"oneOf":[{"$ref":"#/components/schemas/NumericalMetricValueResponse"},{"$ref":"#/components/schemas/CategoricalMetricValueResponse"},{"$ref":"#/components/schemas/BooleanMetricValueResponse"}],"discriminator":{"propertyName":"metric_type","mapping":{"boolean":"#/components/schemas/BooleanMetricValueResponse","categorical":"#/components/schemas/CategoricalMetricValueResponse","numerical":"#/components/schemas/NumericalMetricValueResponse"}}},"type":"array","title":"Metrics"}},"type":"object","required":["metrics"],"title":"MetricListResponse"},"NumericalMetricValueResponse":{"properties":{"metric_key":{"type":"string","title":"Metric Key"},"source":{"type":"string","title":"Source","default":"production"},"entity_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"},"entity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"},"service_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Id"},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"session_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Session Id"},"period_start":{"type":"string","format":"date-time","title":"Period Start"},"period_end":{"type":"string","format":"date-time","title":"Period End"},"event_count":{"type":"integer","title":"Event Count"},"avg_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Confidence"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"computed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Computed At"},"metric_type":{"type":"string","const":"numerical","title":"Metric Type"},"value":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Value"}},"type":"object","required":["metric_key","period_start","period_end","event_count","metric_type","value"],"title":"NumericalMetricValueResponse"},"CategoricalMetricValueResponse":{"properties":{"metric_key":{"type":"string","title":"Metric Key"},"source":{"type":"string","title":"Source","default":"production"},"entity_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"},"entity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"},"service_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Id"},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"session_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Session Id"},"period_start":{"type":"string","format":"date-time","title":"Period Start"},"period_end":{"type":"string","format":"date-time","title":"Period End"},"event_count":{"type":"integer","title":"Event Count"},"avg_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Confidence"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"computed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Computed At"},"metric_type":{"type":"string","const":"categorical","title":"Metric Type"},"value":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Value","description":"The category this row counts. A list-metrics latest row gives its period's most frequent category."},"distribution":{"items":{"$ref":"#/components/schemas/CategoryCount"},"type":"array","title":"Distribution","description":"Events per category in this row's period, most frequent first. A list-metrics latest row\nlists every category its period saw; any other row lists its own category.","default":[]}},"type":"object","required":["metric_key","period_start","period_end","event_count","metric_type","value"],"title":"CategoricalMetricValueResponse"},"CategoryCount":{"properties":{"value":{"type":"string","title":"Value"},"count":{"type":"integer","title":"Count"}},"type":"object","required":["value","count"],"title":"CategoryCount"},"BooleanMetricValueResponse":{"properties":{"metric_key":{"type":"string","title":"Metric Key"},"source":{"type":"string","title":"Source","default":"production"},"entity_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"},"entity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"},"service_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Id"},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"session_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Session Id"},"period_start":{"type":"string","format":"date-time","title":"Period Start"},"period_end":{"type":"string","format":"date-time","title":"Period End"},"event_count":{"type":"integer","title":"Event Count"},"avg_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Confidence"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"computed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Computed At"},"metric_type":{"type":"string","const":"boolean","title":"Metric Type"},"value":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Value","description":"The value this row counts. A list-metrics latest row gives its period's more frequent value."},"distribution":{"items":{"$ref":"#/components/schemas/BooleanCount"},"type":"array","title":"Distribution","description":"Events per value in this row's period, most frequent first. A list-metrics latest row\nlists both values its period saw; any other row lists its own value.","default":[]}},"type":"object","required":["metric_key","period_start","period_end","event_count","metric_type","value"],"title":"BooleanMetricValueResponse"},"BooleanCount":{"properties":{"value":{"type":"boolean","title":"Value"},"count":{"type":"integer","title":"Count"}},"type":"object","required":["value","count"],"title":"BooleanCount"},"ErrorResponse":{"properties":{"detail":{"type":"string","title":"Detail"}},"type":"object","required":["detail"],"title":"ErrorResponse","description":"The body of an ``HTTPException``: ``{\"detail\": \"<message>\"}``."},"ValidationErrorResponse":{"properties":{"detail":{"anyOf":[{"type":"string"},{"items":{"additionalProperties":true,"type":"object"},"type":"array"}],"title":"Detail"}},"type":"object","required":["detail"],"title":"ValidationErrorResponse","description":"The body of a 422.\n\n``detail`` is a string when a route refuses the request itself, and a list of error objects when\nthe request fails validation before the route runs."},"AnalyticsUnavailableResponse":{"properties":{"detail":{"type":"string","const":"Analytics unavailable","title":"Detail"}},"type":"object","required":["detail"],"title":"AnalyticsUnavailableResponse","description":"The 503 body when the route couldn't read its data."}}},"paths":{"/v1/{workspace_id}/metrics/{metric_key}":{"get":{"tags":["Metrics"],"summary":"Get values for a specific metric","description":"Get values for a specific metric with optional time range, newest period first.\n\nPermissions: authenticated (any role).","operationId":"get-metric-values","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"metric_key","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z][a-z0-9_]*$","description":"Metric key (lowercase alphanumeric + underscores)","title":"Metric Key"},"description":"Metric key (lowercase alphanumeric + underscores)"},{"name":"source","in":"query","required":false,"schema":{"enum":["production","simulation","all"],"type":"string","default":"production","title":"Source"}},{"name":"scope","in":"query","required":false,"schema":{"enum":["aggregate","entity","all"],"type":"string","default":"aggregate","title":"Scope"}},{"name":"entity_type","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Entity Type"}},{"name":"entity_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":128},{"type":"null"}],"title":"Entity Id"}},{"name":"service_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Service Id"}},{"name":"run_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Run Id"}},{"name":"session_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":128},{"type":"null"}],"title":"Session Id"}},{"name":"date_from","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Date From"}},{"name":"date_to","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Date To"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"default":90,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricListResponse"}}}},"404":{"description":"Metric key is not defined in this workspace","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"date_from is after date_to","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"429":{"description":"Rate limited"},"503":{"description":"Analytics unavailable: the route couldn't read its data, so treat this 503 as no answer, not as zero. A 200 is always a measured answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyticsUnavailableResponse"}}}}}}}}}
```

## Get time-series trend for a metric

> Get every value a metric recorded in the last \`\`days\`\` days, newest period first.\
> \
> Permissions: authenticated (any role).

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"tags":[{"name":"Metrics"}],"servers":[{"url":"https://platform.api-us.concurrence.com"},{"url":"https://platform.api-eu.concurrence.com","description":"Production, European Union"},{"url":"https://platform.api-au.concurrence.com","description":"Production, Australia"},{"url":"https://platform.api-ca.concurrence.com","description":"Production, Canada"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"MetricListResponse":{"properties":{"metrics":{"items":{"oneOf":[{"$ref":"#/components/schemas/NumericalMetricValueResponse"},{"$ref":"#/components/schemas/CategoricalMetricValueResponse"},{"$ref":"#/components/schemas/BooleanMetricValueResponse"}],"discriminator":{"propertyName":"metric_type","mapping":{"boolean":"#/components/schemas/BooleanMetricValueResponse","categorical":"#/components/schemas/CategoricalMetricValueResponse","numerical":"#/components/schemas/NumericalMetricValueResponse"}}},"type":"array","title":"Metrics"}},"type":"object","required":["metrics"],"title":"MetricListResponse"},"NumericalMetricValueResponse":{"properties":{"metric_key":{"type":"string","title":"Metric Key"},"source":{"type":"string","title":"Source","default":"production"},"entity_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"},"entity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"},"service_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Id"},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"session_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Session Id"},"period_start":{"type":"string","format":"date-time","title":"Period Start"},"period_end":{"type":"string","format":"date-time","title":"Period End"},"event_count":{"type":"integer","title":"Event Count"},"avg_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Confidence"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"computed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Computed At"},"metric_type":{"type":"string","const":"numerical","title":"Metric Type"},"value":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Value"}},"type":"object","required":["metric_key","period_start","period_end","event_count","metric_type","value"],"title":"NumericalMetricValueResponse"},"CategoricalMetricValueResponse":{"properties":{"metric_key":{"type":"string","title":"Metric Key"},"source":{"type":"string","title":"Source","default":"production"},"entity_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"},"entity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"},"service_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Id"},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"session_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Session Id"},"period_start":{"type":"string","format":"date-time","title":"Period Start"},"period_end":{"type":"string","format":"date-time","title":"Period End"},"event_count":{"type":"integer","title":"Event Count"},"avg_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Confidence"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"computed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Computed At"},"metric_type":{"type":"string","const":"categorical","title":"Metric Type"},"value":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Value","description":"The category this row counts. A list-metrics latest row gives its period's most frequent category."},"distribution":{"items":{"$ref":"#/components/schemas/CategoryCount"},"type":"array","title":"Distribution","description":"Events per category in this row's period, most frequent first. A list-metrics latest row\nlists every category its period saw; any other row lists its own category.","default":[]}},"type":"object","required":["metric_key","period_start","period_end","event_count","metric_type","value"],"title":"CategoricalMetricValueResponse"},"CategoryCount":{"properties":{"value":{"type":"string","title":"Value"},"count":{"type":"integer","title":"Count"}},"type":"object","required":["value","count"],"title":"CategoryCount"},"BooleanMetricValueResponse":{"properties":{"metric_key":{"type":"string","title":"Metric Key"},"source":{"type":"string","title":"Source","default":"production"},"entity_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"},"entity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"},"service_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Id"},"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id"},"session_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Session Id"},"period_start":{"type":"string","format":"date-time","title":"Period Start"},"period_end":{"type":"string","format":"date-time","title":"Period End"},"event_count":{"type":"integer","title":"Event Count"},"avg_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Confidence"},"unit":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Unit"},"computed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Computed At"},"metric_type":{"type":"string","const":"boolean","title":"Metric Type"},"value":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Value","description":"The value this row counts. A list-metrics latest row gives its period's more frequent value."},"distribution":{"items":{"$ref":"#/components/schemas/BooleanCount"},"type":"array","title":"Distribution","description":"Events per value in this row's period, most frequent first. A list-metrics latest row\nlists both values its period saw; any other row lists its own value.","default":[]}},"type":"object","required":["metric_key","period_start","period_end","event_count","metric_type","value"],"title":"BooleanMetricValueResponse"},"BooleanCount":{"properties":{"value":{"type":"boolean","title":"Value"},"count":{"type":"integer","title":"Count"}},"type":"object","required":["value","count"],"title":"BooleanCount"},"ErrorResponse":{"properties":{"detail":{"type":"string","title":"Detail"}},"type":"object","required":["detail"],"title":"ErrorResponse","description":"The body of an ``HTTPException``: ``{\"detail\": \"<message>\"}``."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"AnalyticsUnavailableResponse":{"properties":{"detail":{"type":"string","const":"Analytics unavailable","title":"Detail"}},"type":"object","required":["detail"],"title":"AnalyticsUnavailableResponse","description":"The 503 body when the route couldn't read its data."}}},"paths":{"/v1/{workspace_id}/metrics/{metric_key}/trend":{"get":{"tags":["Metrics"],"summary":"Get time-series trend for a metric","description":"Get every value a metric recorded in the last ``days`` days, newest period first.\n\nPermissions: authenticated (any role).","operationId":"get-metric-trend","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"metric_key","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z][a-z0-9_]*$","description":"Metric key (lowercase alphanumeric + underscores)","title":"Metric Key"},"description":"Metric key (lowercase alphanumeric + underscores)"},{"name":"source","in":"query","required":false,"schema":{"enum":["production","simulation","all"],"type":"string","default":"production","title":"Source"}},{"name":"scope","in":"query","required":false,"schema":{"enum":["aggregate","entity","all"],"type":"string","default":"aggregate","title":"Scope"}},{"name":"entity_type","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Entity Type"}},{"name":"entity_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":128},{"type":"null"}],"title":"Entity Id"}},{"name":"service_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Service Id"}},{"name":"run_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Run Id"}},{"name":"session_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":128},{"type":"null"}],"title":"Session Id"}},{"name":"days","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"default":30,"title":"Days"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricListResponse"}}}},"404":{"description":"Metric key is not defined in this workspace","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"429":{"description":"Rate limited"},"503":{"description":"Analytics unavailable: the route couldn't read its data, so treat this 503 as no answer, not as zero. A 200 is always a measured answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyticsUnavailableResponse"}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.concurrence.com/api-reference/readme/platform/metrics.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
