curl --request POST \
--url https://api.example.com/v3/genai-alert-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"application_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metric_name": "<string>",
"threshold_type": "ABSOLUTE",
"critical_threshold": 123,
"notification_settings": [
{
"type": "EMAIL",
"config": {
"recipients": [
"jsmith@example.com"
]
}
}
],
"metric_unit": "milliseconds",
"warning_threshold": 123,
"token_type_id": "<string>",
"attribute_id": "<string>",
"attribute_value": "<string>",
"evaluator_rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"evaluator_output_name": "<string>",
"evaluator_output_value": "<string>"
}
'import requests
url = "https://api.example.com/v3/genai-alert-rules"
payload = {
"project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"application_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metric_name": "<string>",
"threshold_type": "ABSOLUTE",
"critical_threshold": 123,
"notification_settings": [
{
"type": "EMAIL",
"config": { "recipients": ["jsmith@example.com"] }
}
],
"metric_unit": "milliseconds",
"warning_threshold": 123,
"token_type_id": "<string>",
"attribute_id": "<string>",
"attribute_value": "<string>",
"evaluator_rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"evaluator_output_name": "<string>",
"evaluator_output_value": "<string>"
}
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({
project_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
application_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
name: '<string>',
metric_name: '<string>',
threshold_type: 'ABSOLUTE',
critical_threshold: 123,
notification_settings: [{type: 'EMAIL', config: {recipients: ['jsmith@example.com']}}],
metric_unit: 'milliseconds',
warning_threshold: 123,
token_type_id: '<string>',
attribute_id: '<string>',
attribute_value: '<string>',
evaluator_rule_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
evaluator_output_name: '<string>',
evaluator_output_value: '<string>'
})
};
fetch('https://api.example.com/v3/genai-alert-rules', 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.example.com/v3/genai-alert-rules",
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([
'project_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'application_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>',
'metric_name' => '<string>',
'threshold_type' => 'ABSOLUTE',
'critical_threshold' => 123,
'notification_settings' => [
[
'type' => 'EMAIL',
'config' => [
'recipients' => [
'jsmith@example.com'
]
]
]
],
'metric_unit' => 'milliseconds',
'warning_threshold' => 123,
'token_type_id' => '<string>',
'attribute_id' => '<string>',
'attribute_value' => '<string>',
'evaluator_rule_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'evaluator_output_name' => '<string>',
'evaluator_output_value' => '<string>'
]),
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.example.com/v3/genai-alert-rules"
payload := strings.NewReader("{\n \"project_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"application_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metric_name\": \"<string>\",\n \"threshold_type\": \"ABSOLUTE\",\n \"critical_threshold\": 123,\n \"notification_settings\": [\n {\n \"type\": \"EMAIL\",\n \"config\": {\n \"recipients\": [\n \"jsmith@example.com\"\n ]\n }\n }\n ],\n \"metric_unit\": \"milliseconds\",\n \"warning_threshold\": 123,\n \"token_type_id\": \"<string>\",\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\",\n \"evaluator_rule_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"evaluator_output_name\": \"<string>\",\n \"evaluator_output_value\": \"<string>\"\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.example.com/v3/genai-alert-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"project_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"application_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metric_name\": \"<string>\",\n \"threshold_type\": \"ABSOLUTE\",\n \"critical_threshold\": 123,\n \"notification_settings\": [\n {\n \"type\": \"EMAIL\",\n \"config\": {\n \"recipients\": [\n \"jsmith@example.com\"\n ]\n }\n }\n ],\n \"metric_unit\": \"milliseconds\",\n \"warning_threshold\": 123,\n \"token_type_id\": \"<string>\",\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\",\n \"evaluator_rule_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"evaluator_output_name\": \"<string>\",\n \"evaluator_output_value\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v3/genai-alert-rules")
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 \"project_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"application_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metric_name\": \"<string>\",\n \"threshold_type\": \"ABSOLUTE\",\n \"critical_threshold\": 123,\n \"notification_settings\": [\n {\n \"type\": \"EMAIL\",\n \"config\": {\n \"recipients\": [\n \"jsmith@example.com\"\n ]\n }\n }\n ],\n \"metric_unit\": \"milliseconds\",\n \"warning_threshold\": 123,\n \"token_type_id\": \"<string>\",\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\",\n \"evaluator_rule_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"evaluator_output_name\": \"<string>\",\n \"evaluator_output_value\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"api_version": "3.0",
"kind": "NORMAL",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metric_name": "<string>",
"threshold_type": "ABSOLUTE",
"critical_threshold": 123,
"organization": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"project": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"application": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"notification_settings": [
{
"type": "EMAIL",
"config": {
"recipients": [
"jsmith@example.com"
]
}
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"created_by": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"email": "jsmith@example.com",
"full_name": "<string>"
},
"updated_by": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"email": "jsmith@example.com",
"full_name": "<string>"
},
"metric_unit": "milliseconds",
"warning_threshold": 123,
"token_type": "<string>",
"attribute_name": "<string>",
"attribute_value": "<string>",
"evaluator_rule_name": "<string>",
"evaluator_output_name": "<string>",
"evaluator_output_value": "<string>"
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}Create GenAI Alert Rule
Creates a new GenAI Alert Rule
curl --request POST \
--url https://api.example.com/v3/genai-alert-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"application_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metric_name": "<string>",
"threshold_type": "ABSOLUTE",
"critical_threshold": 123,
"notification_settings": [
{
"type": "EMAIL",
"config": {
"recipients": [
"jsmith@example.com"
]
}
}
],
"metric_unit": "milliseconds",
"warning_threshold": 123,
"token_type_id": "<string>",
"attribute_id": "<string>",
"attribute_value": "<string>",
"evaluator_rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"evaluator_output_name": "<string>",
"evaluator_output_value": "<string>"
}
'import requests
url = "https://api.example.com/v3/genai-alert-rules"
payload = {
"project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"application_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metric_name": "<string>",
"threshold_type": "ABSOLUTE",
"critical_threshold": 123,
"notification_settings": [
{
"type": "EMAIL",
"config": { "recipients": ["jsmith@example.com"] }
}
],
"metric_unit": "milliseconds",
"warning_threshold": 123,
"token_type_id": "<string>",
"attribute_id": "<string>",
"attribute_value": "<string>",
"evaluator_rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"evaluator_output_name": "<string>",
"evaluator_output_value": "<string>"
}
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({
project_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
application_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
name: '<string>',
metric_name: '<string>',
threshold_type: 'ABSOLUTE',
critical_threshold: 123,
notification_settings: [{type: 'EMAIL', config: {recipients: ['jsmith@example.com']}}],
metric_unit: 'milliseconds',
warning_threshold: 123,
token_type_id: '<string>',
attribute_id: '<string>',
attribute_value: '<string>',
evaluator_rule_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
evaluator_output_name: '<string>',
evaluator_output_value: '<string>'
})
};
fetch('https://api.example.com/v3/genai-alert-rules', 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.example.com/v3/genai-alert-rules",
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([
'project_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'application_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>',
'metric_name' => '<string>',
'threshold_type' => 'ABSOLUTE',
'critical_threshold' => 123,
'notification_settings' => [
[
'type' => 'EMAIL',
'config' => [
'recipients' => [
'jsmith@example.com'
]
]
]
],
'metric_unit' => 'milliseconds',
'warning_threshold' => 123,
'token_type_id' => '<string>',
'attribute_id' => '<string>',
'attribute_value' => '<string>',
'evaluator_rule_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'evaluator_output_name' => '<string>',
'evaluator_output_value' => '<string>'
]),
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.example.com/v3/genai-alert-rules"
payload := strings.NewReader("{\n \"project_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"application_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metric_name\": \"<string>\",\n \"threshold_type\": \"ABSOLUTE\",\n \"critical_threshold\": 123,\n \"notification_settings\": [\n {\n \"type\": \"EMAIL\",\n \"config\": {\n \"recipients\": [\n \"jsmith@example.com\"\n ]\n }\n }\n ],\n \"metric_unit\": \"milliseconds\",\n \"warning_threshold\": 123,\n \"token_type_id\": \"<string>\",\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\",\n \"evaluator_rule_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"evaluator_output_name\": \"<string>\",\n \"evaluator_output_value\": \"<string>\"\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.example.com/v3/genai-alert-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"project_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"application_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metric_name\": \"<string>\",\n \"threshold_type\": \"ABSOLUTE\",\n \"critical_threshold\": 123,\n \"notification_settings\": [\n {\n \"type\": \"EMAIL\",\n \"config\": {\n \"recipients\": [\n \"jsmith@example.com\"\n ]\n }\n }\n ],\n \"metric_unit\": \"milliseconds\",\n \"warning_threshold\": 123,\n \"token_type_id\": \"<string>\",\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\",\n \"evaluator_rule_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"evaluator_output_name\": \"<string>\",\n \"evaluator_output_value\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v3/genai-alert-rules")
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 \"project_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"application_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metric_name\": \"<string>\",\n \"threshold_type\": \"ABSOLUTE\",\n \"critical_threshold\": 123,\n \"notification_settings\": [\n {\n \"type\": \"EMAIL\",\n \"config\": {\n \"recipients\": [\n \"jsmith@example.com\"\n ]\n }\n }\n ],\n \"metric_unit\": \"milliseconds\",\n \"warning_threshold\": 123,\n \"token_type_id\": \"<string>\",\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\",\n \"evaluator_rule_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"evaluator_output_name\": \"<string>\",\n \"evaluator_output_value\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"api_version": "3.0",
"kind": "NORMAL",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metric_name": "<string>",
"threshold_type": "ABSOLUTE",
"critical_threshold": 123,
"organization": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"project": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"application": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"notification_settings": [
{
"type": "EMAIL",
"config": {
"recipients": [
"jsmith@example.com"
]
}
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"created_by": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"email": "jsmith@example.com",
"full_name": "<string>"
},
"updated_by": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"email": "jsmith@example.com",
"full_name": "<string>"
},
"metric_unit": "milliseconds",
"warning_threshold": 123,
"token_type": "<string>",
"attribute_name": "<string>",
"attribute_value": "<string>",
"evaluator_rule_name": "<string>",
"evaluator_output_name": "<string>",
"evaluator_output_value": "<string>"
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
UUID of the project
UUID of the application
Name of the alert rule
Source of the metric data
raw_data, attribute, evaluator, custom Name of the metric (e.g., "traffic", "token_count", "attribute", "latency", or an evaluator type)
Interval in seconds (3600 = 1 hour, 86400 = 1 day)
3600, 86400 Supported aggregation types for GenAI metrics
sum, average, p50, p75, p90, p95, p99, count Type of threshold
ABSOLUTE Condition for threshold comparison
ABOVE, BELOW Threshold value for triggering a critical alert
List of notification settings for the alert rule
Show child attributes
Show child attributes
Scope of query processing
SPAN, SESSION Unit for metric values.
milliseconds Threshold value for triggering a warning alert (optional)
Token type identifier (required for token_count metrics). In V1, a Postgres UUID; in V2, a bare OTel attribute name (e.g. gen_ai.usage.input_tokens).
Attribute identifier (required for attribute metrics). In V1, a Postgres UUID; in V2, a bare OTel attribute name (e.g. gen_ai.usage.total_tokens).
Attribute value for the metric attribute (only for attribute metrics with count aggregation)
Evaluator rule ID (required for evaluator metrics)
Name of the evaluator output to monitor (required for evaluator metrics)
Value of the evaluator output to filter on (only for evaluator metrics with count aggregation)