Skip to main content
PATCH
/
organization
/
monitoring-metrics
Update monitoring-metrics config
curl --request PATCH \
  --url https://api.coval.dev/v1/organization/monitoring-metrics \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "default_monitoring_metrics": [
    "8EktrIgaVxn9LfxkIynagX"
  ],
  "conditional_monitoring_metrics": [
    {
      "id": "rule-voice",
      "type": "RUN_METADATA",
      "metadata_key": "channel",
      "metadata_type": "STRING",
      "match_type": "EQUALS",
      "metadata_value": "voice",
      "metric": "8EktrIgaVxn9LfxkIynagX",
      "metrics": [
        "8EktrIgaVxn9LfxkIynagX"
      ]
    }
  ]
}
'
import requests

url = "https://api.coval.dev/v1/organization/monitoring-metrics"

payload = {
"default_monitoring_metrics": ["8EktrIgaVxn9LfxkIynagX"],
"conditional_monitoring_metrics": [
{
"id": "rule-voice",
"type": "RUN_METADATA",
"metadata_key": "channel",
"metadata_type": "STRING",
"match_type": "EQUALS",
"metadata_value": "voice",
"metric": "8EktrIgaVxn9LfxkIynagX",
"metrics": ["8EktrIgaVxn9LfxkIynagX"]
}
]
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PATCH',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
default_monitoring_metrics: ['8EktrIgaVxn9LfxkIynagX'],
conditional_monitoring_metrics: [
{
id: 'rule-voice',
type: 'RUN_METADATA',
metadata_key: 'channel',
metadata_type: 'STRING',
match_type: 'EQUALS',
metadata_value: 'voice',
metric: '8EktrIgaVxn9LfxkIynagX',
metrics: ['8EktrIgaVxn9LfxkIynagX']
}
]
})
};

fetch('https://api.coval.dev/v1/organization/monitoring-metrics', 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.coval.dev/v1/organization/monitoring-metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'default_monitoring_metrics' => [
'8EktrIgaVxn9LfxkIynagX'
],
'conditional_monitoring_metrics' => [
[
'id' => 'rule-voice',
'type' => 'RUN_METADATA',
'metadata_key' => 'channel',
'metadata_type' => 'STRING',
'match_type' => 'EQUALS',
'metadata_value' => 'voice',
'metric' => '8EktrIgaVxn9LfxkIynagX',
'metrics' => [
'8EktrIgaVxn9LfxkIynagX'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$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.coval.dev/v1/organization/monitoring-metrics"

payload := strings.NewReader("{\n \"default_monitoring_metrics\": [\n \"8EktrIgaVxn9LfxkIynagX\"\n ],\n \"conditional_monitoring_metrics\": [\n {\n \"id\": \"rule-voice\",\n \"type\": \"RUN_METADATA\",\n \"metadata_key\": \"channel\",\n \"metadata_type\": \"STRING\",\n \"match_type\": \"EQUALS\",\n \"metadata_value\": \"voice\",\n \"metric\": \"8EktrIgaVxn9LfxkIynagX\",\n \"metrics\": [\n \"8EktrIgaVxn9LfxkIynagX\"\n ]\n }\n ]\n}")

req, _ := http.NewRequest("PATCH", url, payload)

req.Header.Add("x-api-key", "<api-key>")
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.patch("https://api.coval.dev/v1/organization/monitoring-metrics")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"default_monitoring_metrics\": [\n \"8EktrIgaVxn9LfxkIynagX\"\n ],\n \"conditional_monitoring_metrics\": [\n {\n \"id\": \"rule-voice\",\n \"type\": \"RUN_METADATA\",\n \"metadata_key\": \"channel\",\n \"metadata_type\": \"STRING\",\n \"match_type\": \"EQUALS\",\n \"metadata_value\": \"voice\",\n \"metric\": \"8EktrIgaVxn9LfxkIynagX\",\n \"metrics\": [\n \"8EktrIgaVxn9LfxkIynagX\"\n ]\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.coval.dev/v1/organization/monitoring-metrics")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"default_monitoring_metrics\": [\n \"8EktrIgaVxn9LfxkIynagX\"\n ],\n \"conditional_monitoring_metrics\": [\n {\n \"id\": \"rule-voice\",\n \"type\": \"RUN_METADATA\",\n \"metadata_key\": \"channel\",\n \"metadata_type\": \"STRING\",\n \"match_type\": \"EQUALS\",\n \"metadata_value\": \"voice\",\n \"metric\": \"8EktrIgaVxn9LfxkIynagX\",\n \"metrics\": [\n \"8EktrIgaVxn9LfxkIynagX\"\n ]\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "default_monitoring_metrics": [
    "8EktrIgaVxn9LfxkIynagX"
  ],
  "conditional_monitoring_metrics": [
    {
      "id": "rule-voice",
      "type": "RUN_METADATA",
      "metadata_key": "channel",
      "metadata_type": "STRING",
      "match_type": "EQUALS",
      "metadata_value": "voice",
      "metric": "8EktrIgaVxn9LfxkIynagX",
      "metrics": [
        "8EktrIgaVxn9LfxkIynagX"
      ]
    }
  ]
}
{
"error": {
"code": "INVALID_ARGUMENT",
"message": "Invalid request body",
"details": [
{
"field": "conditional_monitoring_metrics",
"description": "Provide exactly one of 'metric' or 'metrics'."
}
]
}
}
{
"error": {
"code": "UNAUTHENTICATED",
"message": "Authentication failed",
"details": [
{
"field": "x-api-key",
"description": "API key is required in the x-api-key header"
}
]
}
}
{
"error": {
"code": "PERMISSION_DENIED",
"message": "Insufficient permissions",
"details": [
{
"field": "permissions",
"description": "The API key does not include the required organization permission."
}
]
}
}
{
"error": {
"code": "NOT_FOUND",
"message": "Organization not found",
"details": [
{
"description": "Organization not found."
}
]
}
}
{
"error": {
"code": "INTERNAL",
"message": "Internal server error",
"details": [
{
"description": "An unexpected error occurred while processing the organization request"
}
]
}
}

Authorizations

x-api-key
string
header
required

API key for authentication

Body

application/json

Partial update. Provide at least one of default_monitoring_metrics or conditional_monitoring_metrics; each field provided fully replaces the stored value.

default_monitoring_metrics
string[] | null

Metric IDs run on every monitored conversation.

Maximum array length: 500
Example:
["8EktrIgaVxn9LfxkIynagX"]
conditional_monitoring_metrics
object[] | null

Rules that add metrics when run metadata matches.

Maximum array length: 500

Response

Configuration updated

The organization's monitoring-metric configuration.

default_monitoring_metrics
string[]

Metric IDs run on every monitored conversation.

Example:
["8EktrIgaVxn9LfxkIynagX"]
conditional_monitoring_metrics
object[]

Rules that add metrics when run metadata matches.