curl --request POST \
--url https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"operator": "GREATER_THAN_OR_EQUALS",
"value": "4",
"slug": "customer_satisfaction",
"metricId": "customer_satisfaction",
"aggregationMode": "EACH",
"countThreshold": 1,
"sourceVariantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds"
payload = {
"operator": "GREATER_THAN_OR_EQUALS",
"value": "4",
"slug": "customer_satisfaction",
"metricId": "customer_satisfaction",
"aggregationMode": "EACH",
"countThreshold": 1,
"sourceVariantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
operator: 'GREATER_THAN_OR_EQUALS',
value: '4',
slug: 'customer_satisfaction',
metricId: 'customer_satisfaction',
aggregationMode: 'EACH',
countThreshold: 1,
sourceVariantId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'operator' => 'GREATER_THAN_OR_EQUALS',
'value' => '4',
'slug' => 'customer_satisfaction',
'metricId' => 'customer_satisfaction',
'aggregationMode' => 'EACH',
'countThreshold' => 1,
'sourceVariantId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds"
payload := strings.NewReader("{\n \"operator\": \"GREATER_THAN_OR_EQUALS\",\n \"value\": \"4\",\n \"slug\": \"customer_satisfaction\",\n \"metricId\": \"customer_satisfaction\",\n \"aggregationMode\": \"EACH\",\n \"countThreshold\": 1,\n \"sourceVariantId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"operator\": \"GREATER_THAN_OR_EQUALS\",\n \"value\": \"4\",\n \"slug\": \"customer_satisfaction\",\n \"metricId\": \"customer_satisfaction\",\n \"aggregationMode\": \"EACH\",\n \"countThreshold\": 1,\n \"sourceVariantId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"operator\": \"GREATER_THAN_OR_EQUALS\",\n \"value\": \"4\",\n \"slug\": \"customer_satisfaction\",\n \"metricId\": \"customer_satisfaction\",\n \"aggregationMode\": \"EACH\",\n \"countThreshold\": 1,\n \"sourceVariantId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"slug": "<string>",
"metricId": "<string>",
"variantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"versionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"type": "COUNT",
"scope": "GLOBAL",
"supportedContexts": [
"CALL"
],
"supportedConversationSources": [
"SIMULATED"
],
"requiresLiveConversation": true,
"supportsVariants": true,
"calculationType": "THRESHOLD",
"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"
}
}
}{
"type": "validation",
"code": "invalid_parameter",
"message": "The request was invalid",
"param": "email"
}{
"type": "authentication",
"code": "unauthorized",
"message": "Authentication required"
}{
"type": "forbidden",
"code": "permission_denied",
"message": "You do not have permission to access this resource"
}{
"type": "not_found",
"code": "resource_not_found",
"message": "The requested resource could not be found"
}{
"type": "rate_limit",
"code": "too_many_requests",
"message": "Rate limit exceeded"
}{
"type": "internal",
"code": "internal_error",
"message": "Internal server error"
}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.
curl --request POST \
--url https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"operator": "GREATER_THAN_OR_EQUALS",
"value": "4",
"slug": "customer_satisfaction",
"metricId": "customer_satisfaction",
"aggregationMode": "EACH",
"countThreshold": 1,
"sourceVariantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds"
payload = {
"operator": "GREATER_THAN_OR_EQUALS",
"value": "4",
"slug": "customer_satisfaction",
"metricId": "customer_satisfaction",
"aggregationMode": "EACH",
"countThreshold": 1,
"sourceVariantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
operator: 'GREATER_THAN_OR_EQUALS',
value: '4',
slug: 'customer_satisfaction',
metricId: 'customer_satisfaction',
aggregationMode: 'EACH',
countThreshold: 1,
sourceVariantId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'operator' => 'GREATER_THAN_OR_EQUALS',
'value' => '4',
'slug' => 'customer_satisfaction',
'metricId' => 'customer_satisfaction',
'aggregationMode' => 'EACH',
'countThreshold' => 1,
'sourceVariantId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds"
payload := strings.NewReader("{\n \"operator\": \"GREATER_THAN_OR_EQUALS\",\n \"value\": \"4\",\n \"slug\": \"customer_satisfaction\",\n \"metricId\": \"customer_satisfaction\",\n \"aggregationMode\": \"EACH\",\n \"countThreshold\": 1,\n \"sourceVariantId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"operator\": \"GREATER_THAN_OR_EQUALS\",\n \"value\": \"4\",\n \"slug\": \"customer_satisfaction\",\n \"metricId\": \"customer_satisfaction\",\n \"aggregationMode\": \"EACH\",\n \"countThreshold\": 1,\n \"sourceVariantId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.roark.ai/v1/metric/definitions/{idOrSlug}/thresholds")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"operator\": \"GREATER_THAN_OR_EQUALS\",\n \"value\": \"4\",\n \"slug\": \"customer_satisfaction\",\n \"metricId\": \"customer_satisfaction\",\n \"aggregationMode\": \"EACH\",\n \"countThreshold\": 1,\n \"sourceVariantId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"slug": "<string>",
"metricId": "<string>",
"variantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"versionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"type": "COUNT",
"scope": "GLOBAL",
"supportedContexts": [
"CALL"
],
"supportedConversationSources": [
"SIMULATED"
],
"requiresLiveConversation": true,
"supportsVariants": true,
"calculationType": "THRESHOLD",
"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"
}
}
}{
"type": "validation",
"code": "invalid_parameter",
"message": "The request was invalid",
"param": "email"
}{
"type": "authentication",
"code": "unauthorized",
"message": "Authentication required"
}{
"type": "forbidden",
"code": "permission_denied",
"message": "You do not have permission to access this resource"
}{
"type": "not_found",
"code": "resource_not_found",
"message": "The requested resource could not be found"
}{
"type": "rate_limit",
"code": "too_many_requests",
"message": "Rate limit exceeded"
}{
"type": "internal",
"code": "internal_error",
"message": "Internal server error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The metric definition's Roark ID (UUID) or its stable slug (e.g. customer_satisfaction).
Body
Input for creating a new threshold derived from a source metric.
Comparison operator
GREATER_THAN, GREATER_THAN_OR_EQUALS, LESS_THAN, LESS_THAN_OR_EQUALS, EQUALS, NOT_EQUALS "GREATER_THAN_OR_EQUALS"
Value to compare the source metric against (as a string)
1"4"
Stable slug for the metric. Auto-generated from name if omitted.
1 - 50"customer_satisfaction"
Alias of slug accepted for backwards compatibility. Use slug for new integrations.
1 - 50"customer_satisfaction"
How to aggregate the source metric before applying the comparison (default: EACH)
EACH, COUNT, AVERAGE, MIN, MAX, MEDIAN, P95, P99, SUM Required when aggregationMode is COUNT. The threshold fires when the count is met.
x >= 0When the source metric is per-participant, restrict evaluation to this role. Only valid for sources with TURN/SEGMENT contexts.
AGENT, CUSTOMER, SIMULATED_CUSTOMER, BACKGROUND_SPEAKER Variant of the source metric to use
Response
The created threshold (as a metric definition)
Show child attributes
Show child attributes