Create an alert rule
POST
/alerts/rules
const url = 'https://your-server.example/api/alerts/rules';const options = { method: 'POST', headers: {cookie: 'session=<session>', 'Content-Type': 'application/json'}, body: '{"id":1,"name":"example","scope":"example","target":"example","metric":"example","operator":">","threshold":1,"duration_seconds":1,"webhook_ids":[1],"enabled":true}'};
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://your-server.example/api/alerts/rules \ --header 'Content-Type: application/json' \ --cookie session=<session> \ --data '{ "id": 1, "name": "example", "scope": "example", "target": "example", "metric": "example", "operator": ">", "threshold": 1, "duration_seconds": 1, "webhook_ids": [ 1 ], "enabled": true }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
id
integer format: int64
name
string
scope
System, app, or webhook
string
target
App slug or “*”.
string
metric
string
operator
string
threshold
number
duration_seconds
integer
webhook_ids
Array<integer>
enabled
boolean
Responses
Section titled “Responses”Created.
Media typeapplication/json
object
id
integer format: int64
name
string
scope
System, app, or webhook
string
target
App slug or “*”.
string
metric
string
operator
string
threshold
number
duration_seconds
integer
webhook_ids
Array<integer>
enabled
boolean
Example
{ "operator": ">"}