Skip to content

Create Rule

POST
/api/organizations/{organization_id}/alerts/rules
curl --request POST \
--url https://example.com/api/organizations/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/alerts/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "aggregation": "avg", "comparator": "gt", "device_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "enabled": true, "for_s": 0, "metric_name": "example", "name": "example", "notify_email": true, "offline_after_s": 1, "rule_type": "metric", "severity": "info", "threshold": 1, "webhook_secret": "example", "webhook_url": "example", "window_s": 300 }'
organization_id
required
Organization Id
string format: uuid
Media type application/json
AlertRuleCreate

rule_type selects which fields apply (default metric, the original behaviour):

  • metric: metric_name, comparator and threshold are required.
  • offline: offline_after_s (60..604800) is required; the metric fields are rejected.
  • deployment_failed: no type-specific field; the metric fields are rejected. device_id optionally scopes any rule type to one device.
object
aggregation
Aggregation
string
default: avg
Allowed values: avg max min last
comparator
Any of:
string
Allowed values: gt gte lt lte
device_id
Any of:
string format: uuid
enabled
Enabled
boolean
default: true
for_s
For S
integer
0 <= 86400
metric_name
Any of:
string
>= 1 characters <= 255 characters
name
required
Name
string
>= 1 characters <= 255 characters
notify_email
Notify Email
boolean
default: true
offline_after_s
Any of:
integer
>= 60 <= 604800
rule_type
Rule Type
string
default: metric
Allowed values: metric offline deployment_failed
severity
Severity
string
default: warning
Allowed values: info warning critical
threshold
Any of:
number
webhook_secret
Any of:
string
>= 8 characters <= 256 characters
webhook_url
Any of:
string
<= 2048 characters
window_s
Window S
integer
default: 300 >= 60 <= 3600

Successful Response

Media type application/json
AlertRuleResponse
object
aggregation
required
Aggregation
string
comparator
required
Any of:
string
created_at
required
Created At
string format: date-time
created_by
required
Any of:
string format: uuid
device_id
required
Any of:
string format: uuid
enabled
required
Enabled
boolean
for_s
required
For S
integer
has_webhook_secret
required
Has Webhook Secret
boolean
id
required
Id
string format: uuid
metric_name
required
Any of:
string
name
required
Name
string
notify_email
required
Notify Email
boolean
offline_after_s
required
Any of:
integer
organization_id
required
Organization Id
string format: uuid
rule_type
required
Rule Type
string
severity
required
Severity
string
threshold
required
Any of:
number
updated_at
required
Updated At
string format: date-time
webhook_url
required
Any of:
string
window_s
required
Window S
integer
Example generated
{
"aggregation": "example",
"comparator": "example",
"created_at": "2026-04-15T12:00:00Z",
"created_by": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"device_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"enabled": true,
"for_s": 1,
"has_webhook_secret": true,
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"metric_name": "example",
"name": "example",
"notify_email": true,
"offline_after_s": 1,
"organization_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"rule_type": "example",
"severity": "example",
"threshold": 1,
"updated_at": "2026-04-15T12:00:00Z",
"webhook_url": "example",
"window_s": 1
}

Validation Error

Media type application/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
ctx
Context
object
input
Input
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
Example generated
{
"detail": [
{
"ctx": {},
"input": "example",
"loc": [
"example"
],
"msg": "example",
"type": "example"
}
]
}