Create 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_source": "raw_data",
"metric_name": "<string>",
"interval": 3600,
"aggregation": "sum",
"threshold_type": "ABSOLUTE",
"threshold_condition": "ABOVE",
"critical_threshold": 123,
"query_scope": "SPAN",
"organization": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"project": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"asset_type": "ML_MODEL"
},
"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>",
"semantic_name": "<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>"
}
]
}
}GenAI Alert Rules
Create GenAI Alert Rule
Creates a new GenAI Alert Rule
POST
/
v3
/
genai-alert-rules
Create 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_source": "raw_data",
"metric_name": "<string>",
"interval": 3600,
"aggregation": "sum",
"threshold_type": "ABSOLUTE",
"threshold_condition": "ABOVE",
"critical_threshold": 123,
"query_scope": "SPAN",
"organization": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"project": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"asset_type": "ML_MODEL"
},
"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>",
"semantic_name": "<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
Body
application/json
Source of the metric data.
| Value | Description |
|---|---|
raw_data | Core span-level metrics (traffic, latency, status, error rate). |
attribute | Span attribute metrics (token count, custom attributes). |
evaluator | Automated evaluator scores from EvaluatorRule instances. |
custom | User-defined FQL custom metrics. |
annotation | Human/LLM/code annotation scores from online_scores (Source IN ('human','llm','code')). Requires enable_online_scores_reads feature flag. |
Available options:
raw_data, attribute, evaluator, custom, annotation Semantic concept name (e.g. input_tokens, model_name). When set, the alert queries by semantic concept rather than a specific attribute key, making it SDK-agnostic. Mutually exclusive with token_type_id and attribute_id.
Available options:
input_tokens, output_tokens, total_tokens, total_cost, input_cost, output_cost, model_name, provider_name, agent_name, agent_id, agent_description, tool_name, tool_id, tool_type, tool_definitions, session_id, user_id, input, output, system_instructions, retrieval_context, tool_input, tool_output, latency, ttft, span_name, span_type, received_time, request_id, response_id, cache_read_input_tokens, cache_creation_input_tokens, reasoning_tokens, finish_reason Was this page helpful?