Metric

Create a threshold on a metric

Create a boolean threshold derived from an existing metric. The source metric is addressed by its UUID or its stable slug. The threshold fires when the source metric meets the comparison condition. Scope and supported contexts are inherited from the source metric.

post/v1/metric/definitions/{idOrSlug}/thresholds

Path parameters

idOrSlugstring required

The metric definition's Roark ID (UUID) or its stable slug (e.g. customer_satisfaction).

Request body

slugstring

Stable slug for the metric. Auto-generated from name if omitted.

metricIdstring

Alias of slug accepted for backwards compatibility. Use slug for new integrations.

operator'GREATER_THAN' | 'GREATER_THAN_OR_EQUALS' | 'LESS_THAN' | 'LESS_THAN_OR_EQUALS' | 'EQUALS' | 'NOT_EQUALS' required

Comparison operator

valuestring required

Value to compare the source metric against (as a string)

aggregationMode'EACH' | 'COUNT' | 'AVERAGE' | 'MIN' | 'MAX' | 'MEDIAN' | 'P95' | 'P99' | 'SUM'

How to aggregate the source metric before applying the comparison (default: EACH)

countThresholdinteger

Required when aggregationMode is COUNT. The threshold fires when the count is met.

sourceParticipantRole'AGENT' | 'CUSTOMER' | 'SIMULATED_CUSTOMER' | 'BACKGROUND_SPEAKER'

When the source metric is per-participant, restrict evaluation to this role. Only valid for sources with TURN/SEGMENT contexts.

sourceVariantIdstring uuid

Variant of the source metric to use

Example request

{
  "slug": "customer_satisfaction",
  "metricId": "customer_satisfaction",
  "operator": "GREATER_THAN_OR_EQUALS",
  "value": "4"
}

Response

The created threshold (as a metric definition)

Changes

Changed in 1 of the 105 revisions of this API.1