Create alert policy
POST/api/v1/orgs/{orgId}/alert-policies
Create a new alert policy definition. New policies always start disabled;
call the enable/disable action afterwards to activate evaluation. Device/data-stream bindings are
managed separately via the data-streams sub-resource, not part of this payload.
Request Body
policyName(string, required): Policy name. Must be unique within the org (among non-deleted policies). Ex:WaterLevel alert policy.description(string, optional): Policy description. Max length: 500.alertLevel(string, required): Trigger threshold expression, evaluated against the incoming data stream value. Ex:>=70.alertResetLevel(string, required): Reset/release threshold expression. Ex:<65.delay(integer, optional, default: 0): Debounce delay in seconds. The condition must hold continuously for this many seconds before an alert is actually fired or released;0disables debouncing (fires/releases almost immediately). Must be non-negative.notification(object, optional): Notification configuration for this policy. Omit to leave the policy without any notification target (no message is sent when it fires).channelIds(string[], required): Existing channel IDs to notify. Ex:channel_3fa85f64-5717-4562-b3fc-2c963f66afa6. Every ID must belong to an existing channel in this org.recipients(array, required): Recipients for the notification. Each item:name(string, optional),target(string, required),type(string, required —to/cc/bcc).templateId(string, optional): Existing template ID to render. Ex:tmpl_7fa85f64-5717-4562-b3fc-2c963f66afa6. Use together withvariables; mutually exclusive withsubject/content(providing both results in400).variables(object, optional): Key/value substitutions used when rendering the template. Ex:{"threshold": "70"}. Only meaningful together withtemplateId.subject(string, optional): Literal subject line, used instead of a template. Mutually exclusive withtemplateId/variables.content(string, optional): Literal message content, used instead of a template. Mutually exclusive withtemplateId/variables.
Responses
201 Created: Alert policy created successfully.400 Bad Request: Validation error (missing required field, invalid range, ortemplateId+subject/contentboth provided).404 Not Found: AchannelIdsentry ortemplateIddoes not exist in this org.409 Conflict: An alert policy with the samepolicyNamealready exists in this org.
Request
Responses
- 201
Created