Skip to main content
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_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

Authorization
string
header
required

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

Body

application/json
project_id
string<uuid>
required

UUID of the project

application_id
string<uuid>
required

UUID of the application

name
string
required

Name of the alert rule

metric_source
enum<string>
required

Source of the metric data

Available options:
raw_data,
attribute,
evaluator,
custom
metric_name
string
required

Name of the metric (e.g., "traffic", "token_count", "attribute", "latency", or an evaluator type)

interval
enum<integer>
required

Interval in seconds (3600 = 1 hour, 86400 = 1 day)

Available options:
3600,
86400
aggregation
enum<string>
required

Supported aggregation types for GenAI metrics

Available options:
sum,
average,
p50,
p75,
p90,
p95,
p99,
count
threshold_type
enum<string>
required

Type of threshold

Available options:
ABSOLUTE
threshold_condition
enum<string>
required

Condition for threshold comparison

Available options:
ABOVE,
BELOW
critical_threshold
number<float>
required

Threshold value for triggering a critical alert

notification_settings
object[]
required

List of notification settings for the alert rule

query_scope
enum<string>
required

Scope of query processing

Available options:
SPAN,
SESSION
metric_unit
enum<string>

Unit for metric values.

Available options:
milliseconds
warning_threshold
number<float> | null

Threshold value for triggering a warning alert (optional)

token_type_id
string | null

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_id
string | null

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
string | null

Attribute value for the metric attribute (only for attribute metrics with count aggregation)

evaluator_rule_id
string<uuid> | null

Evaluator rule ID (required for evaluator metrics)

evaluator_output_name
string | null

Name of the evaluator output to monitor (required for evaluator metrics)

evaluator_output_value
string | null

Value of the evaluator output to filter on (only for evaluator metrics with count aggregation)

Response

GenAI Alert Rule created successfully

Response object for standard API responses.

api_version
enum<string>
default:3.0

API version.

Available options:
2.0,
3.0
kind
enum<string>
default:NORMAL

Type of response, indicating a normal response.

Available options:
NORMAL
data
object