Skip to main content
POST
/
v1
/
metric
/
definitions
/
{metricId}
/
thresholds
Create a threshold on a metric
curl --request POST \
  --url https://api.roark.ai/v1/metric/definitions/{metricId}/thresholds \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "Customer Satisfaction",
  "operator": "GREATER_THAN_OR_EQUALS",
  "value": "4",
  "metricId": "customer_satisfaction",
  "aggregationMode": "EACH",
  "countThreshold": 1,
  "sourceParticipantRole": "AGENT",
  "sourceVariantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'
{
  "data": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "metricId": "<string>",
    "variantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "versionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "name": "<string>",
    "description": "<string>",
    "calculationType": "PROVIDER",
    "type": "COUNT",
    "scope": "GLOBAL",
    "supportedContexts": [
      "CALL"
    ],
    "unit": {
      "name": "<string>",
      "symbol": "<string>"
    },
    "threshold": {
      "sourceMetricDefinitionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "operator": "GREATER_THAN",
      "thresholdValue": "<string>",
      "aggregationMode": "EACH",
      "countThreshold": 123,
      "sourceParticipantRole": "AGENT",
      "sourceVariantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
    },
    "formula": {
      "expression": "<string>",
      "sources": [
        {
          "sourceMetricDefinitionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "sourceVariantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
        }
      ]
    },
    "pattern": {
      "operation": "PATTERN_EXISTS",
      "windowMode": "<string>",
      "triggerCombinator": "AND",
      "triggers": [
        {
          "sourceMetricDefinitionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "operator": "GREATER_THAN",
          "thresholdValue": "<string>",
          "sourceParticipantRole": "AGENT",
          "sourceVariantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
        }
      ],
      "outcome": {
        "sourceMetricDefinitionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "operator": "GREATER_THAN",
        "thresholdValue": "<string>",
        "sourceParticipantRole": "AGENT",
        "sourceVariantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "windowBefore": 123,
        "windowAfter": 123
      }
    }
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.roark.ai/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

metricId
string
required

Body

application/json

Input for creating a new threshold derived from a source metric.

name
string
required

Name of the metric

Required string length: 1 - 100
Example:

"Customer Satisfaction"

operator
enum<string>
required

Comparison operator

Available options:
GREATER_THAN,
GREATER_THAN_OR_EQUALS,
LESS_THAN,
LESS_THAN_OR_EQUALS,
EQUALS,
NOT_EQUALS
Example:

"GREATER_THAN_OR_EQUALS"

value
string
required

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

Minimum string length: 1
Example:

"4"

metricId
string

Unique identifier for the metric. Auto-generated from name if omitted.

Required string length: 1 - 50
Example:

"customer_satisfaction"

aggregationMode
enum<string>
default:EACH

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

Available options:
EACH,
COUNT,
AVERAGE,
MIN,
MAX,
MEDIAN,
P95,
P99,
SUM
countThreshold
integer

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

Required range: x >= 0
sourceParticipantRole
enum<string>

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

Available options:
AGENT,
CUSTOMER,
SIMULATED_CUSTOMER,
BACKGROUND_SPEAKER
sourceVariantId
string<uuid>

Variant of the source metric to use

Response

The created threshold (as a metric definition)

data
object
required

Metric definition data