---
title: "POST /sources/{id}/kapacitors/{kapa_id}/rules"
method: POST
path: "/sources/{id}/kapacitors/{kapa_id}/rules"
tags: ["sources", "kapacitors", "rules"]
---

# POST /sources/{id}/kapacitors/{kapa_id}/rules

`POST /sources/{id}/kapacitors/{kapa_id}/rules`

Create kapacitor alert rule

## Path parameters

- `id` string, required
- `kapa_id` string, required

## Request body

- Rule
  - `id` string — ID for this rule; the ID is shared with kapacitor
  - `query` QueryConfig, required
    - `id` string
    - `database` string, required
    - `measurement` string, required
    - `retentionPolicy` string, required
    - `areTagsAccepted` boolean, required
    - `rawText` string
    - `tags` object, required
    - `groupBy` object, required
      - `time` string, required
      - `tags` string[], required
    - `fields` Field[], required
      - `value` string, required — value is the value of the field. Meaning of the value is implied by the `type` key
      - `type` 'func' | 'field' | 'integer' | 'number' | 'regex' | 'wildcard', required — type describes the field type. func is a function; field is a field reference
      - `alias` string — Alias overrides the field name in the returned response. Applies only if type is `func`
      - `args` Field[] — Args are the arguments to the function
    - `range` object
      - `lower` string, required
      - `upper` string, required
  - `name` string — User facing name of the alerting rule
  - `every` string, required — Golang duration string specifying how often the alert condition is checked
  - `alertNodes` object — Arguments and properties for alerts. Disabled alerts are unset or empty arrays.
    - `typeOf` 'alert' — Object type
    - `stateChangesOnly` boolean — Only send alerts when state criticality changes
    - `noRecoveries` boolean — Do not send alerts when state recovers from criticality
    - `useFlapping` boolean — Enable flapping detection to prevent flood of alerts from rapid changes
    - `post` object[] — Parameters for POST notifications
      - `url` string — POST destination
      - `headers` object — Headers to be added to POST request
    - `tcp` object[] — Parameters for TCP notifications
      - `address` string — Address and port to send the alert to
    - `email` object[] — Parameters for email notifications
      - `to` string[] — Destination email address
    - `exec` object[] — Parameters for exec notifications
      - `command` string[] — Space-separated command and args to execute
    - `log` object[] — Parameters for log notifications
      - `filePath` string — Absolute path to the log file which will be created if it does not exist
    - `victorOps` object[] — Parameters for VictorOps notifications
      - `routingKey` string — Routing key used to map alerts to teams
    - `pagerDuty` object[] — Parameters for PagerDuty notifications
      - `serviceKey` string — GUID of Generic API integration
    - `pagerDuty2` object[] — Parameters for PagerDuty v2 notifications
      - `serviceKey` string — GUID of Generic API integration
    - `pushover` object[] — Parameters for Pushover notifications
      - `userKey` string — User/group key
      - `device` string — Device name to alert specific devices (comma separated to specify multiple)
      - `title` string — Notification title, otherwise app name is used
      - `url` string — Supplementary URL to show with notification
      - `urlTitle` string — Title for supplementary URL, otherwise just URL is shown
      - `sound` string — Name of supported sound to override the user's default sound choice
    - `sensu` object[] — Parameters for sensu notifications
      - `source` string — Check source used to create a proxy client for external resources
      - `handlers` string[] — Sensu event handlers for taking action on events
    - `slack` object[] — Parameters for Slack notifications
      - `channel` string — Channel to post messages to
      - `username` string — Slack bot username
      - `iconEmoji` string — Emoji name surrounded by : characters will replace the normal user icon for the Slack bot
      - `workspace` string — Slack workspace for the alert handler
    - `telegram` object[] — Parameters for Telegram notifications
      - `chatId` string — Telegram user/group ID to post messages to
      - `parseMode` 'Markdown' | 'HTML' — Specify the mode used to render the message
      - `disableWebPagePreview` boolean — Disables link previews in alert messages
      - `disableNotification` boolean — Disables notifications on iOS devices and disables sounds on Android devices
    - `alerta` object[] — Parameters for Alerta notifications
      - `token` string — Authentication token (overrides global config)
      - `resource` string — Resource under alarm
      - `event` string — Event name
      - `environment` string — Affected environment
      - `group` string — Event type group
      - `value` string — Event value
      - `origin` string — Name of monitoring component that generated alert
      - `service` string[] — List of affected services
    - `opsGenie` object[] — Parameters for OpsGenie notifications
      - `teams` string[] — Teams the alert will be routed to
      - `recipients` string[] — Single user, group, escalation or schedule to alert
    - `opsGenie2` object[] — Parameters for OpsGenie v2 notifications
      - `teams` string[] — Teams the alert will be routed to
      - `recipients` string[] — Single user, group, escalation or schedule to alert
    - `talk` object[] — Parameters for Jane Talk notifications
    - `kafka` object[] — Parameters for Kafka notifications
      - `cluster` string — Cluster to notify
      - `kafka-topic` string — Topic to notify
      - `template` string — Notification template
    - `serviceNow` object[] — Parameters for ServiceNow notifications
      - `source` string — Notification source
      - `node` string — Notification node
      - `type` string — Notification type
      - `resource` string — Notification resource
      - `metric_name` string — Metric name
      - `message_key` string — Message key
    - `bigPanda` object[] — Parameters for BigPanda notifications
      - `app-key` string — App key
      - `primary-property` string — Primary property
      - `secondary-property` string — Secondary property
    - `teams` object[] — Parameters for Teams notifications
      - `channel_url` string — Channel URL to override global configuration
    - `zenoss` object[] — Parameters for Zenoss notifications
      - `action` string — Action
      - `method` string — Method
      - `type` string — Type
      - `tid` integer — TID
      - `device` string — Device
      - `component` string — Component
      - `evclasskey` string — Event Class Key
      - `evclass` string — Event Class
  - `message` string — Message to send when alert occurs.
  - `details` string — Template for constructing a detailed HTML message for the alert. (Currently, only used for email/smtp
  - `trigger` 'deadman' | 'relative' | 'threshold', required — Trigger defines the alerting structure; deadman alert if no data are received for the specified time range; relative alert if the data change relative to the data in a different time range; threshold alert if the data cross a boundary
  - `values` object — Alerting logic for trigger type
    - `change` '% change' | 'change' — Specifies if the change is percent or absolute
    - `period` string — Length of time before deadman is alerted (golang duration)
    - `shift` string — Amount of time to look into the past to compare to the present (golang duration)
    - `operator` 'greater than' | 'less than' | 'equal to or less than' | 'equal to or greater' | 'equal to' | 'not equal to' | 'inside range' | 'outside range' — Operator for alert comparison
    - `value` string — Value is the boundary value when alert goes critical
    - `rangeValue` string — Optional value for range comparisions
  - `dbrps` DBRP[] — List of database retention policy pairs the task is allowed to access.
    - `db` string, required — Database name
    - `rp` string, required — Retention policy
  - `tickscript` string — TICKscript representing this rule
  - `status` 'enabled' | 'disabled' — Represents if this rule is enabled or disabled in kapacitor
  - `executing` boolean — Whether the task is currently executing.
  - `type` 'stream' | 'batch' — Represents the task type where stream is data streamed to kapacitor and batch is queried by kapacitor.
  - `error` string — Any error encountered when kapacitor executes the task.
  - `created` string — Date the task was first created
  - `modified` string — Date the task was last modified
  - `last-enabled` string — Date the task was last set to status enabled
  - `template-id` string — Template ID when created from template
  - `vars` object — task external variables
  - `links` object
    - `self` string, uri, required — Self link pointing to this rule resource
    - `kapacitor` string, uri, required — Link pointing to the kapacitor proxy for this rule including the path query parameter.
    - `output` string, uri — Link pointing to the kapacitor httpOut node of the tickscript; includes the path query argument

## Response `201`

Kapacitor alert rule successfully created

- Rule
  - `id` string — ID for this rule; the ID is shared with kapacitor
  - `query` QueryConfig, required
    - `id` string
    - `database` string, required
    - `measurement` string, required
    - `retentionPolicy` string, required
    - `areTagsAccepted` boolean, required
    - `rawText` string
    - `tags` object, required
    - `groupBy` object, required
      - `time` string, required
      - `tags` string[], required
    - `fields` Field[], required
      - `value` string, required — value is the value of the field. Meaning of the value is implied by the `type` key
      - `type` 'func' | 'field' | 'integer' | 'number' | 'regex' | 'wildcard', required — type describes the field type. func is a function; field is a field reference
      - `alias` string — Alias overrides the field name in the returned response. Applies only if type is `func`
      - `args` Field[] — Args are the arguments to the function
    - `range` object
      - `lower` string, required
      - `upper` string, required
  - `name` string — User facing name of the alerting rule
  - `every` string, required — Golang duration string specifying how often the alert condition is checked
  - `alertNodes` object — Arguments and properties for alerts. Disabled alerts are unset or empty arrays.
    - `typeOf` 'alert' — Object type
    - `stateChangesOnly` boolean — Only send alerts when state criticality changes
    - `noRecoveries` boolean — Do not send alerts when state recovers from criticality
    - `useFlapping` boolean — Enable flapping detection to prevent flood of alerts from rapid changes
    - `post` object[] — Parameters for POST notifications
      - `url` string — POST destination
      - `headers` object — Headers to be added to POST request
    - `tcp` object[] — Parameters for TCP notifications
      - `address` string — Address and port to send the alert to
    - `email` object[] — Parameters for email notifications
      - `to` string[] — Destination email address
    - `exec` object[] — Parameters for exec notifications
      - `command` string[] — Space-separated command and args to execute
    - `log` object[] — Parameters for log notifications
      - `filePath` string — Absolute path to the log file which will be created if it does not exist
    - `victorOps` object[] — Parameters for VictorOps notifications
      - `routingKey` string — Routing key used to map alerts to teams
    - `pagerDuty` object[] — Parameters for PagerDuty notifications
      - `serviceKey` string — GUID of Generic API integration
    - `pagerDuty2` object[] — Parameters for PagerDuty v2 notifications
      - `serviceKey` string — GUID of Generic API integration
    - `pushover` object[] — Parameters for Pushover notifications
      - `userKey` string — User/group key
      - `device` string — Device name to alert specific devices (comma separated to specify multiple)
      - `title` string — Notification title, otherwise app name is used
      - `url` string — Supplementary URL to show with notification
      - `urlTitle` string — Title for supplementary URL, otherwise just URL is shown
      - `sound` string — Name of supported sound to override the user's default sound choice
    - `sensu` object[] — Parameters for sensu notifications
      - `source` string — Check source used to create a proxy client for external resources
      - `handlers` string[] — Sensu event handlers for taking action on events
    - `slack` object[] — Parameters for Slack notifications
      - `channel` string — Channel to post messages to
      - `username` string — Slack bot username
      - `iconEmoji` string — Emoji name surrounded by : characters will replace the normal user icon for the Slack bot
      - `workspace` string — Slack workspace for the alert handler
    - `telegram` object[] — Parameters for Telegram notifications
      - `chatId` string — Telegram user/group ID to post messages to
      - `parseMode` 'Markdown' | 'HTML' — Specify the mode used to render the message
      - `disableWebPagePreview` boolean — Disables link previews in alert messages
      - `disableNotification` boolean — Disables notifications on iOS devices and disables sounds on Android devices
    - `alerta` object[] — Parameters for Alerta notifications
      - `token` string — Authentication token (overrides global config)
      - `resource` string — Resource under alarm
      - `event` string — Event name
      - `environment` string — Affected environment
      - `group` string — Event type group
      - `value` string — Event value
      - `origin` string — Name of monitoring component that generated alert
      - `service` string[] — List of affected services
    - `opsGenie` object[] — Parameters for OpsGenie notifications
      - `teams` string[] — Teams the alert will be routed to
      - `recipients` string[] — Single user, group, escalation or schedule to alert
    - `opsGenie2` object[] — Parameters for OpsGenie v2 notifications
      - `teams` string[] — Teams the alert will be routed to
      - `recipients` string[] — Single user, group, escalation or schedule to alert
    - `talk` object[] — Parameters for Jane Talk notifications
    - `kafka` object[] — Parameters for Kafka notifications
      - `cluster` string — Cluster to notify
      - `kafka-topic` string — Topic to notify
      - `template` string — Notification template
    - `serviceNow` object[] — Parameters for ServiceNow notifications
      - `source` string — Notification source
      - `node` string — Notification node
      - `type` string — Notification type
      - `resource` string — Notification resource
      - `metric_name` string — Metric name
      - `message_key` string — Message key
    - `bigPanda` object[] — Parameters for BigPanda notifications
      - `app-key` string — App key
      - `primary-property` string — Primary property
      - `secondary-property` string — Secondary property
    - `teams` object[] — Parameters for Teams notifications
      - `channel_url` string — Channel URL to override global configuration
    - `zenoss` object[] — Parameters for Zenoss notifications
      - `action` string — Action
      - `method` string — Method
      - `type` string — Type
      - `tid` integer — TID
      - `device` string — Device
      - `component` string — Component
      - `evclasskey` string — Event Class Key
      - `evclass` string — Event Class
  - `message` string — Message to send when alert occurs.
  - `details` string — Template for constructing a detailed HTML message for the alert. (Currently, only used for email/smtp
  - `trigger` 'deadman' | 'relative' | 'threshold', required — Trigger defines the alerting structure; deadman alert if no data are received for the specified time range; relative alert if the data change relative to the data in a different time range; threshold alert if the data cross a boundary
  - `values` object — Alerting logic for trigger type
    - `change` '% change' | 'change' — Specifies if the change is percent or absolute
    - `period` string — Length of time before deadman is alerted (golang duration)
    - `shift` string — Amount of time to look into the past to compare to the present (golang duration)
    - `operator` 'greater than' | 'less than' | 'equal to or less than' | 'equal to or greater' | 'equal to' | 'not equal to' | 'inside range' | 'outside range' — Operator for alert comparison
    - `value` string — Value is the boundary value when alert goes critical
    - `rangeValue` string — Optional value for range comparisions
  - `dbrps` DBRP[] — List of database retention policy pairs the task is allowed to access.
    - `db` string, required — Database name
    - `rp` string, required — Retention policy
  - `tickscript` string — TICKscript representing this rule
  - `status` 'enabled' | 'disabled' — Represents if this rule is enabled or disabled in kapacitor
  - `executing` boolean — Whether the task is currently executing.
  - `type` 'stream' | 'batch' — Represents the task type where stream is data streamed to kapacitor and batch is queried by kapacitor.
  - `error` string — Any error encountered when kapacitor executes the task.
  - `created` string — Date the task was first created
  - `modified` string — Date the task was last modified
  - `last-enabled` string — Date the task was last set to status enabled
  - `template-id` string — Template ID when created from template
  - `vars` object — task external variables
  - `links` object
    - `self` string, uri, required — Self link pointing to this rule resource
    - `kapacitor` string, uri, required — Link pointing to the kapacitor proxy for this rule including the path query parameter.
    - `output` string, uri — Link pointing to the kapacitor httpOut node of the tickscript; includes the path query argument

## Other responses

- `404` — Source ID or Kapacitor ID does not exist.
- `422` — Source ID , Kapacitor ID or alert are unprocessable
- `default` — Internal server error; generally a problem creating alert in kapacitor

---

[API](https://skmtc.net/influxdata/apis/chronograf.md) · [All operations](https://skmtc.net/influxdata/apis/chronograf/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/influxdata/chronograf/versions/ce55d963b4ac/schema)
