Skip to main content
POST
/
v1
/
alert-rules
Create an alert rule
curl --request POST \
  --url https://api.us.poly.ai/v1/alert-rules \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '
{
  "name": "High turn latency (p95)",
  "project_id": "proj_abc123",
  "metric": "turn_latency_p95",
  "operator": ">=",
  "threshold_value": 1500,
  "window_duration": "5m",
  "enabled": true
}
'
import requests

url = "https://api.us.poly.ai/v1/alert-rules"

payload = {
    "name": "High turn latency (p95)",
    "project_id": "proj_abc123",
    "metric": "turn_latency_p95",
    "operator": ">=",
    "threshold_value": 1500,
    "window_duration": "5m",
    "enabled": True
}
headers = {
    "X-API-KEY": "<api-key>",
    "Content-Type": "application/json"
}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    name: 'High turn latency (p95)',
    project_id: 'proj_abc123',
    metric: 'turn_latency_p95',
    operator: '>=',
    threshold_value: 1500,
    window_duration: '5m',
    enabled: true
  })
};

fetch('https://api.us.poly.ai/v1/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.us.poly.ai/v1/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([
    'name' => 'High turn latency (p95)',
    'project_id' => 'proj_abc123',
    'metric' => 'turn_latency_p95',
    'operator' => '>=',
    'threshold_value' => 1500,
    'window_duration' => '5m',
    'enabled' => true
  ]),
  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.us.poly.ai/v1/alert-rules"

	payload := strings.NewReader("{\n  \"name\": \"High turn latency (p95)\",\n  \"project_id\": \"proj_abc123\",\n  \"metric\": \"turn_latency_p95\",\n  \"operator\": \">=\",\n  \"threshold_value\": 1500,\n  \"window_duration\": \"5m\",\n  \"enabled\": true\n}")

	req, _ := http.NewRequest("POST", 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.post("https://api.us.poly.ai/v1/alert-rules")
  .header("X-API-KEY", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"High turn latency (p95)\",\n  \"project_id\": \"proj_abc123\",\n  \"metric\": \"turn_latency_p95\",\n  \"operator\": \">=\",\n  \"threshold_value\": 1500,\n  \"window_duration\": \"5m\",\n  \"enabled\": true\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.us.poly.ai/v1/alert-rules")

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

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"High turn latency (p95)\",\n  \"project_id\": \"proj_abc123\",\n  \"metric\": \"turn_latency_p95\",\n  \"operator\": \">=\",\n  \"threshold_value\": 1500,\n  \"window_duration\": \"5m\",\n  \"enabled\": true\n}"

response = http.request(request)
puts response.read_body
{
  "id": "ar_0Kx4mNpQ8rWvYb2dFgHjLs",
  "name": "<string>",
  "threshold_value": 1,
  "enabled": true,
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "project_id": "<string>",
  "since": "2023-11-07T05:31:56Z",
  "last_evaluated_at": "2023-11-07T05:31:56Z",
  "current_value": 123
}
{
  "success": false,
  "error": "<string>",
  "error_id": "<string>",
  "error_code": "<string>",
  "error_message": "<string>",
  "data": "<unknown>"
}
{
  "success": false,
  "error": "<string>",
  "error_id": "<string>",
  "error_code": "<string>",
  "error_message": "<string>",
  "data": "<unknown>"
}
{
  "success": false,
  "error": "<string>",
  "error_id": "<string>",
  "error_code": "<string>",
  "error_message": "<string>",
  "data": "<unknown>"
}
{
  "success": false,
  "error": "<string>",
  "error_id": "<string>",
  "error_code": "<string>",
  "error_message": "<string>",
  "data": "<unknown>"
}
{
  "success": false,
  "error": "<string>",
  "error_id": "<string>",
  "error_code": "<string>",
  "error_message": "<string>",
  "data": "<unknown>"
}
{
  "success": false,
  "error": "<string>",
  "error_id": "<string>",
  "error_code": "<string>",
  "error_message": "<string>",
  "data": "<unknown>"
}

Authorizations

X-API-KEY
string
header
required

An API key is a token that you provide when making API calls. Include the token in a header parameter called X-API-KEY.

Body

application/json

Fields for creating a new alert rule: which metric to watch, the threshold condition, and how long it must hold to fire.

name
string
required

Alert rule name

metric
enum<string>
required

Metric to monitor

Available options:
turn_latency_p50,
turn_latency_p95,
api_errors,
function_errors,
call_crashes,
call_volume
operator
enum<string>
required

Comparison operator

Available options:
>,
<,
>=,
<=
threshold_value
integer
required

Threshold value

Required range: x >= 0
window_duration
enum<string>
required

Window duration (5m, 10m, or 60m)

Available options:
5m,
10m,
60m
project_id
string | null

Project ID (optional)

enabled
boolean
default:true

Whether the alert is enabled

Response

Alert rule created successfully.

An alert rule: its trigger condition, evaluation window, and current state.

id
string
required

Alert rule ID

Pattern: ^ar_[A-Za-z0-9]+$
Example:

"ar_0Kx4mNpQ8rWvYb2dFgHjLs"

name
string
required

Alert rule name

metric
enum<string>
required

Metric being monitored

Available options:
turn_latency_p50,
turn_latency_p95,
api_errors,
function_errors,
call_crashes,
call_volume
operator
enum<string>
required

Comparison operator

Available options:
>,
<,
>=,
<=
threshold_value
integer
required

Threshold value

Required range: x >= 0
window_duration
enum<string>
required

Window duration (5m, 10m, or 60m)

Available options:
5m,
10m,
60m
enabled
boolean
required

Whether the alert is enabled

created_at
string<date-time>
required

Creation timestamp

updated_at
string<date-time>
required

Last update timestamp

project_id
string | null

Project ID

current_state
enum<string>

Current alert state

Available options:
ok,
alert,
no_data,
unknown
since
string<date-time> | null

When the current state started

last_evaluated_at
string<date-time> | null

Last evaluation timestamp

current_value
integer | null

Current metric value

Last modified on March 10, 2026