Create Rule
POST
/api/organizations/{organization_id}/alerts/rules
const url = 'https://example.com/api/organizations/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/alerts/rules';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"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}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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 }'Authorizations
Section titled “ Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ” organization_id
required
Organization Id
string format: uuid
Request Bodyrequired
Section titled “ Request Bodyrequired ” Media type application/json
AlertRuleCreate
rule_type selects which fields apply (default metric, the original behaviour):
metric:metric_name,comparatorandthresholdare 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_idoptionally scopes any rule type to one device.
object
aggregation
Aggregation
string
enabled
Enabled
boolean
for_s
For S
integer
name
required
Name
string
notify_email
Notify Email
boolean
rule_type
Rule Type
string
severity
Severity
string
window_s
Window S
integer
Responses
Section titled “ Responses ”Successful Response
Media type application/json
AlertRuleResponse
object
aggregation
required
Aggregation
string
created_at
required
Created At
string format: date-time
enabled
required
Enabled
boolean
for_s
required
For S
integer
has_webhook_secret
required
Has Webhook Secret
boolean
id
required
Id
string format: uuid
name
required
Name
string
notify_email
required
Notify Email
boolean
organization_id
required
Organization Id
string format: uuid
rule_type
required
Rule Type
string
severity
required
Severity
string
updated_at
required
Updated At
string format: date-time
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" } ]}