### GET /rules/{id} Source: https://connhex.com/api/rules-engine/latest/api.json Read rule. Required Permission: - Resource: ```ruleengine:rules:{id}``` - Action: ```ruleengine:rules:get``` ```markdown ### Parameters - **id** (string, path, required) ### Responses #### 200 - response **ReadRuleDto** - **conditions** (array (ReadConditionDto)) (required) Array items: - **params** (object) (required) - **source** (string (messages|params|metrics)) ("messages"|"params"|"metrics") - **metric** (string) (required): URN of the metric to be monitored (example: "urn:cpt:smartdevice:nid:D0CF5EFFFE26FDAB1:onoff") - **threshold** (number) (required) - **comparisonOperator** (string (>|>=|<|<=|==|!=)) (required) (">"|">="|"<"|"<="|"=="|"!=") - **unit** (string) (example: "°C") - **durationSecs** (number) (required) - **activeWindow** (object) - **from** (string) (required) (example: "08:10") - **to** (string) (required) (example: "13:15") - **timezone** (string) (required): IANA timezone identifier (example: "Europe/Rome") - **channelId** (string) (required): Connectable channel whose messages are evaluated by the condition. You must have access to this channel (action `core:channels:subscribe`) to create or update a rule. - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **type** (string (threshold|lastMessageOlderThan|delta)) (required) ("threshold"|"lastMessageOlderThan"|"delta") - **id** (string) (required) - **tags** (array (ReadTagDto)) (required) Array items: - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **label** (string) (required): The key or category of the tag used for grouping or filtering. (example: "deviceID") - **labelValue** (string) (required): The specific value assigned to the tag label. (example: "e0ce7733-cd7c-415b-8430-4b1a5876362d") - **metadata** (object): Additional custom properties or contextual data associated with this tag. Useful for storing extra structured information. (example: "{ 'alias': 'Main Boiler Sensor', 'location': 'Warehouse A' }") - **id** (string) (required) - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **name** (string) (required) - **severity** (string (info|warning|critical)) ("info"|"warning"|"critical") - **description** (string) - **processable** (string (enabled|disabled)) ("enabled"|"disabled") - **notification** (object) (required) - **messages** (array (NotificationMessageDto)) (required) Array items: - **target** (string): Notification target, whose format depends on the selected `medium`. If not specified, the notification is sent to the user who created the rule. Supported formats: - `email`: email address - `sms`: E.164 phone number (e.g. "+391234567890") - `telegram`: username ("@user") - `slack` / `discord` / `msteams`: webhook URL - `fcm`: device registration token The value must match the expected format for the chosen medium. Invalid or incompatible values may result in notification delivery failure. - **targets** (array (string)): Notification targets: an array of target addresses (emails, phone numbers, device tokens, etc.). (example: ["admin@connhex.com","user@connhex.com"]) - **policy** (string (trigger|reentry)) (required): Defines when the notification should be dispatched: - `trigger`: The notification is sent when the rule is triggered (its conditions are satisfied). - `reentry`: The notification is sent when the rule re-enters (its associated conditions are no longer satisfied). ("trigger"|"reentry") - **medium** (string (email|telegram|sms|slack|discord|fcm|msteams)) (required) ("email"|"telegram"|"sms"|"slack"|"discord"|"fcm"|"msteams") - **text** (string) (required) - **muted** (boolean) - **id** (string) (required) #### 404 - response ### Example Usage ```bash curl -X GET "https://apis./rules/{id}" ``` ``` -------------------------------- ### GET /rules Source: https://connhex.com/api/rules-engine/latest/api.json List rules. Required Permission: - Resource: ```ruleengine:rules``` - Action: ```ruleengine:rules:list``` ```markdown ### Parameters - **ids** (array (string), query, optional) - **tagLabels** (array (string), query, optional) - **tagLabelValues** (array (string), query, optional) - **severity** (string (info|warning|critical), query, optional) - **status** (string (active|inactive), query, optional) - **page** (number, query, optional) - **pageSize** (number, query, optional) - **createdAfter** (string (date-time), query, optional) - **sort** (string, query, optional) ### Responses #### 200 - response **PagedRulesDto** - **results** (array (ReadRuleDto)) (required) Array items: - **conditions** (array (ReadConditionDto)) (required) Array items: - **params** (object) (required) - **source** (string (messages|params|metrics)) ("messages"|"params"|"metrics") - **metric** (string) (required): URN of the metric to be monitored (example: "urn:cpt:smartdevice:nid:D0CF5EFFFE26FDAB1:onoff") - **threshold** (number) (required) - **comparisonOperator** (string (>|>=|<|<=|==|!=)) (required) (">"|">="|"<"|"<="|"=="|"!=") - **unit** (string) (example: "°C") - **durationSecs** (number) (required) - **activeWindow** (object) - **from** (string) (required) (example: "08:10") - **to** (string) (required) (example: "13:15") - **timezone** (string) (required): IANA timezone identifier (example: "Europe/Rome") - **channelId** (string) (required): Connectable channel whose messages are evaluated by the condition. You must have access to this channel (action `core:channels:subscribe`) to create or update a rule. - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **type** (string (threshold|lastMessageOlderThan|delta)) (required) ("threshold"|"lastMessageOlderThan"|"delta") - **id** (string) (required) - **tags** (array (ReadTagDto)) (required) Array items: - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **label** (string) (required): The key or category of the tag used for grouping or filtering. (example: "deviceID") - **labelValue** (string) (required): The specific value assigned to the tag label. (example: "e0ce7733-cd7c-415b-8430-4b1a5876362d") - **metadata** (object): Additional custom properties or contextual data associated with this tag. Useful for storing extra structured information. (example: "{ 'alias': 'Main Boiler Sensor', 'location': 'Warehouse A' }") - **id** (string) (required) - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **name** (string) (required) - **severity** (string (info|warning|critical)) ("info"|"warning"|"critical") - **description** (string) - **processable** (string (enabled|disabled)) ("enabled"|"disabled") - **notification** (object) (required) - **messages** (array (NotificationMessageDto)) (required) Array items: - **target** (string): Notification target, whose format depends on the selected `medium`. If not specified, the notification is sent to the user who created the rule. Supported formats: - `email`: email address - `sms`: E.164 phone number (e.g. "+391234567890") - `telegram`: username ("@user") - `slack` / `discord` / `msteams`: webhook URL - `fcm`: device registration token The value must match the expected format for the chosen medium. Invalid or incompatible values may result in notification delivery failure. - **targets** (array (string)): Notification targets: an array of target addresses (emails, phone numbers, device tokens, etc.). (example: ["admin@connhex.com","user@connhex.com"]) - **policy** (string (trigger|reentry)) (required): Defines when the notification should be dispatched: - `trigger`: The notification is sent when the rule is triggered (its conditions are satisfied). - `reentry`: The notification is sent when the rule re-enters (its associated conditions are no longer satisfied). ("trigger"|"reentry") - **medium** (string (email|telegram|sms|slack|discord|fcm|msteams)) (required) ("email"|"telegram"|"sms"|"slack"|"discord"|"fcm"|"msteams") - **text** (string) (required) - **muted** (boolean) - **id** (string) (required) - **total** (number) (required) ### Example Usage ```bash curl -X GET "https://apis./rules?ids=item1,item2&tagLabels=item1,item2&tagLabelValues=item1,item2&severity=info&status=active&page=0&pageSize=1000&createdAfter=2023-01-01T00:00:00Z&sort=createdAt:desc" ``` ``` -------------------------------- ### GET /rules/events Source: https://connhex.com/api/rules-engine/latest/api.json List rule events. Required Permission: - Resource: ```ruleengine:rules``` - Action: ```ruleengine:rules:list``` ```markdown ### Parameters - **ruleId** (string, query, optional) - **ruleIds** (array (string), query, optional) - **from** (string (date-time), query, optional) - **to** (string (date-time), query, optional) - **status** (string (active|inactive), query, optional) - **page** (number, query, optional) - **pageSize** (number, query, optional) - **sort** (string, query, optional) ### Responses #### 200 - response **PagedRulesEventsDto** - **results** (array (ReadRuleEventDto)) (required) Array items: - **ruleId** (string) (required) - **ruleSnapshot** (object) (required) - **name** (string) (required) - **severity** (string (info|warning|critical)) ("info"|"warning"|"critical") - **description** (string) - **processable** (string (enabled|disabled)) ("enabled"|"disabled") - **notification** (object) (required) - **messages** (array (NotificationMessageDto)) (required) Array items: - **target** (string): Notification target, whose format depends on the selected `medium`. If not specified, the notification is sent to the user who created the rule. Supported formats: - `email`: email address - `sms`: E.164 phone number (e.g. "+391234567890") - `telegram`: username ("@user") - `slack` / `discord` / `msteams`: webhook URL - `fcm`: device registration token The value must match the expected format for the chosen medium. Invalid or incompatible values may result in notification delivery failure. - **targets** (array (string)): Notification targets: an array of target addresses (emails, phone numbers, device tokens, etc.). (example: ["admin@connhex.com","user@connhex.com"]) - **policy** (string (trigger|reentry)) (required): Defines when the notification should be dispatched: - `trigger`: The notification is sent when the rule is triggered (its conditions are satisfied). - `reentry`: The notification is sent when the rule re-enters (its associated conditions are no longer satisfied). ("trigger"|"reentry") - **medium** (string (email|telegram|sms|slack|discord|fcm|msteams)) (required) ("email"|"telegram"|"sms"|"slack"|"discord"|"fcm"|"msteams") - **text** (string) (required) - **muted** (boolean) - **id** (string) (required) - **conditionsEvents** (array (ReadConditionEventDto)) (required) Array items: - **conditionId** (string) (required) - **conditionSnapshot** (object) (required) - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string (date-time)) (required) - **id** (string) (required) - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string) (required) - **id** (string) (required) - **total** (number) (required) ### Example Usage ```bash curl -X GET "https://apis./rules/events?ruleId=string&ruleIds=item1,item2&from=2023-01-01T00:00:00Z&to=2023-01-01T00:00:00Z&status=active&page=0&pageSize=1000&sort=createdAt:desc" ``` ``` -------------------------------- ### POST /rules/bulk Source: https://connhex.com/api/rules-engine/latest/api.json Bulk create rules. Required Permission: - Resource: ```ruleengine:rules``` - Action: ```ruleengine:rules:create``` ```markdown ### Request Body **Content-Type:** application/json - **rules** (array (CreateRuleDto)) (required) Array items: - **name** (string) (required) - **severity** (string (info|warning|critical)) ("info"|"warning"|"critical") - **description** (string) - **processable** (string (enabled|disabled)) ("enabled"|"disabled") - **tags** (array (CreateTagDto)) Array items: - **label** (string) (required): The key or category of the tag used for grouping or filtering. (example: "deviceID") - **labelValue** (string) (required): The specific value assigned to the tag label. (example: "e0ce7733-cd7c-415b-8430-4b1a5876362d") - **metadata** (object): Additional custom properties or contextual data associated with this tag. Useful for storing extra structured information. (example: "{ 'alias': 'Main Boiler Sensor', 'location': 'Warehouse A' }") - **notification** (object) (required) - **messages** (array (NotificationMessageDto)) (required) Array items: - **target** (string): Notification target, whose format depends on the selected `medium`. If not specified, the notification is sent to the user who created the rule. Supported formats: - `email`: email address - `sms`: E.164 phone number (e.g. "+391234567890") - `telegram`: username ("@user") - `slack` / `discord` / `msteams`: webhook URL - `fcm`: device registration token The value must match the expected format for the chosen medium. Invalid or incompatible values may result in notification delivery failure. - **targets** (array (string)): Notification targets: an array of target addresses (emails, phone numbers, device tokens, etc.). (example: ["admin@connhex.com","user@connhex.com"]) - **policy** (string (trigger|reentry)) (required): Defines when the notification should be dispatched: - `trigger`: The notification is sent when the rule is triggered (its conditions are satisfied). - `reentry`: The notification is sent when the rule re-enters (its associated conditions are no longer satisfied). ("trigger"|"reentry") - **medium** (string (email|telegram|sms|slack|discord|fcm|msteams)) (required) ("email"|"telegram"|"sms"|"slack"|"discord"|"fcm"|"msteams") - **text** (string) (required) - **muted** (boolean) - **conditions** (array (CreateConditionDto)) (required) Array items: - **params** (object) (required) - **source** (string (messages|params|metrics)) ("messages"|"params"|"metrics") - **metric** (string) (required): URN of the metric to be monitored (example: "urn:cpt:smartdevice:nid:D0CF5EFFFE26FDAB1:onoff") - **threshold** (number) (required) - **comparisonOperator** (string (>|>=|<|<=|==|!=)) (required) (">"|">="|"<"|"<="|"=="|"!=") - **unit** (string) (example: "°C") - **durationSecs** (number) (required) - **activeWindow** (object) - **from** (string) (required) (example: "08:10") - **to** (string) (required) (example: "13:15") - **timezone** (string) (required): IANA timezone identifier (example: "Europe/Rome") - **channelId** (string) (required): Connectable channel whose messages are evaluated by the condition. You must have access to this channel (action `core:channels:subscribe`) to create or update a rule. - **type** (string (threshold|lastMessageOlderThan|delta)) (required) ("threshold"|"lastMessageOlderThan"|"delta") ### Responses #### 201 - response - Array of ReadRuleDto #### 400 - Missing user identity id Missing user identity id ### Example Usage ```bash curl -X POST "https://apis./rules/bulk" \ -H "Content-Type: application/json" \ -d '{ "rules": [ "value" ] }' ``` ``` -------------------------------- ### POST /rules Source: https://connhex.com/api/rules-engine/latest/api.json Create rule. Required Permission: - Resource: ```ruleengine:rules``` - Action: ```ruleengine:rules:create``` ```markdown ### Request Body **Content-Type:** application/json - **name** (string) (required) - **severity** (string (info|warning|critical)) ("info"|"warning"|"critical") - **description** (string) - **processable** (string (enabled|disabled)) ("enabled"|"disabled") - **tags** (array (CreateTagDto)) Array items: - **label** (string) (required): The key or category of the tag used for grouping or filtering. (example: "deviceID") - **labelValue** (string) (required): The specific value assigned to the tag label. (example: "e0ce7733-cd7c-415b-8430-4b1a5876362d") - **metadata** (object): Additional custom properties or contextual data associated with this tag. Useful for storing extra structured information. (example: "{ 'alias': 'Main Boiler Sensor', 'location': 'Warehouse A' }") - **notification** (object) (required) - **messages** (array (NotificationMessageDto)) (required) Array items: - **target** (string): Notification target, whose format depends on the selected `medium`. If not specified, the notification is sent to the user who created the rule. Supported formats: - `email`: email address - `sms`: E.164 phone number (e.g. "+391234567890") - `telegram`: username ("@user") - `slack` / `discord` / `msteams`: webhook URL - `fcm`: device registration token The value must match the expected format for the chosen medium. Invalid or incompatible values may result in notification delivery failure. - **targets** (array (string)): Notification targets: an array of target addresses (emails, phone numbers, device tokens, etc.). (example: ["admin@connhex.com","user@connhex.com"]) - **policy** (string (trigger|reentry)) (required): Defines when the notification should be dispatched: - `trigger`: The notification is sent when the rule is triggered (its conditions are satisfied). - `reentry`: The notification is sent when the rule re-enters (its associated conditions are no longer satisfied). ("trigger"|"reentry") - **medium** (string (email|telegram|sms|slack|discord|fcm|msteams)) (required) ("email"|"telegram"|"sms"|"slack"|"discord"|"fcm"|"msteams") - **text** (string) (required) - **muted** (boolean) - **conditions** (array (CreateConditionDto)) (required) Array items: - **params** (object) (required) - **source** (string (messages|params|metrics)) ("messages"|"params"|"metrics") - **metric** (string) (required): URN of the metric to be monitored (example: "urn:cpt:smartdevice:nid:D0CF5EFFFE26FDAB1:onoff") - **threshold** (number) (required) - **comparisonOperator** (string (>|>=|<|<=|==|!=)) (required) (">"|">="|"<"|"<="|"=="|"!=") - **unit** (string) (example: "°C") - **durationSecs** (number) (required) - **activeWindow** (object) - **from** (string) (required) (example: "08:10") - **to** (string) (required) (example: "13:15") - **timezone** (string) (required): IANA timezone identifier (example: "Europe/Rome") - **channelId** (string) (required): Connectable channel whose messages are evaluated by the condition. You must have access to this channel (action `core:channels:subscribe`) to create or update a rule. - **type** (string (threshold|lastMessageOlderThan|delta)) (required) ("threshold"|"lastMessageOlderThan"|"delta") ### Responses #### 201 - response **ReadRuleDto** - **conditions** (array (ReadConditionDto)) (required) Array items: - **params** (object) (required) - **source** (string (messages|params|metrics)) ("messages"|"params"|"metrics") - **metric** (string) (required): URN of the metric to be monitored (example: "urn:cpt:smartdevice:nid:D0CF5EFFFE26FDAB1:onoff") - **threshold** (number) (required) - **comparisonOperator** (string (>|>=|<|<=|==|!=)) (required) (">"|">="|"<"|"<="|"=="|"!=") - **unit** (string) (example: "°C") - **durationSecs** (number) (required) - **activeWindow** (object) - **from** (string) (required) (example: "08:10") - **to** (string) (required) (example: "13:15") - **timezone** (string) (required): IANA timezone identifier (example: "Europe/Rome") - **channelId** (string) (required): Connectable channel whose messages are evaluated by the condition. You must have access to this channel (action `core:channels:subscribe`) to create or update a rule. - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **type** (string (threshold|lastMessageOlderThan|delta)) (required) ("threshold"|"lastMessageOlderThan"|"delta") - **id** (string) (required) - **tags** (array (ReadTagDto)) (required) Array items: - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **label** (string) (required): The key or category of the tag used for grouping or filtering. (example: "deviceID") - **labelValue** (string) (required): The specific value assigned to the tag label. (example: "e0ce7733-cd7c-415b-8430-4b1a5876362d") - **metadata** (object): Additional custom properties or contextual data associated with this tag. Useful for storing extra structured information. (example: "{ 'alias': 'Main Boiler Sensor', 'location': 'Warehouse A' }") - **id** (string) (required) - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **name** (string) (required) - **severity** (string (info|warning|critical)) ("info"|"warning"|"critical") - **description** (string) - **processable** (string (enabled|disabled)) ("enabled"|"disabled") - **notification** (object) (required) - **messages** (array (NotificationMessageDto)) (required) Array items: - **target** (string): Notification target, whose format depends on the selected `medium`. If not specified, the notification is sent to the user who created the rule. Supported formats: - `email`: email address - `sms`: E.164 phone number (e.g. "+391234567890") - `telegram`: username ("@user") - `slack` / `discord` / `msteams`: webhook URL - `fcm`: device registration token The value must match the expected format for the chosen medium. Invalid or incompatible values may result in notification delivery failure. - **targets** (array (string)): Notification targets: an array of target addresses (emails, phone numbers, device tokens, etc.). (example: ["admin@connhex.com","user@connhex.com"]) - **policy** (string (trigger|reentry)) (required): Defines when the notification should be dispatched: - `trigger`: The notification is sent when the rule is triggered (its conditions are satisfied). - `reentry`: The notification is sent when the rule re-enters (its associated conditions are no longer satisfied). ("trigger"|"reentry") - **medium** (string (email|telegram|sms|slack|discord|fcm|msteams)) (required) ("email"|"telegram"|"sms"|"slack"|"discord"|"fcm"|"msteams") - **text** (string) (required) - **muted** (boolean) - **id** (string) (required) #### 400 - Missing user identity id Missing user identity id ### Example Usage ```bash curl -X POST "https://apis./rules" \ -H "Content-Type: application/json" \ -d '{ "name": "string", "severity": "info", "description": "string", "processable": "enabled", "tags": [ "value" ], "notification": "value", "conditions": [ "value" ] }' ``` ``` -------------------------------- ### Schema: ActiveWindowDto Source: https://connhex.com/api/rules-engine/latest/api.json Schema definition for ActiveWindowDto ```markdown ## Schema: ActiveWindowDto Schema definition for ActiveWindowDto **Type:** object - **from** (string) (required) (example: "08:10") - **to** (string) (required) (example: "13:15") - **timezone** (string) (required): IANA timezone identifier (example: "Europe/Rome") ``` -------------------------------- ### Security: chx_auth_session Source: https://connhex.com/api/rules-engine/latest/api.json Security scheme: chx_auth_session ```markdown ## Security: chx_auth_session **Description:** Security scheme: chx_auth_session **Type:** apiKey ``` -------------------------------- ### Schema: CreateTagDto Source: https://connhex.com/api/rules-engine/latest/api.json Schema definition for CreateTagDto ```markdown ## Schema: CreateTagDto Schema definition for CreateTagDto **Type:** object - **label** (string) (required): The key or category of the tag used for grouping or filtering. (example: "deviceID") - **labelValue** (string) (required): The specific value assigned to the tag label. (example: "e0ce7733-cd7c-415b-8430-4b1a5876362d") - **metadata** (object): Additional custom properties or contextual data associated with this tag. Useful for storing extra structured information. (example: "{ 'alias': 'Main Boiler Sensor', 'location': 'Warehouse A' }") ``` -------------------------------- ### Schema: BulkCreateRulesDto Source: https://connhex.com/api/rules-engine/latest/api.json Schema definition for BulkCreateRulesDto ```markdown ## Schema: BulkCreateRulesDto Schema definition for BulkCreateRulesDto **Type:** object - **rules** (array (CreateRuleDto)) (required) Array items: - **name** (string) (required) - **severity** (string (info|warning|critical)) ("info"|"warning"|"critical") - **description** (string) - **processable** (string (enabled|disabled)) ("enabled"|"disabled") - **tags** (array (CreateTagDto)) Array items: - **label** (string) (required): The key or category of the tag used for grouping or filtering. (example: "deviceID") - **labelValue** (string) (required): The specific value assigned to the tag label. (example: "e0ce7733-cd7c-415b-8430-4b1a5876362d") - **metadata** (object): Additional custom properties or contextual data associated with this tag. Useful for storing extra structured information. (example: "{ 'alias': 'Main Boiler Sensor', 'location': 'Warehouse A' }") - **notification** (object) (required) - **messages** (array (NotificationMessageDto)) (required) Array items: - **target** (string): Notification target, whose format depends on the selected `medium`. If not specified, the notification is sent to the user who created the rule. Supported formats: - `email`: email address - `sms`: E.164 phone number (e.g. "+391234567890") - `telegram`: username ("@user") - `slack` / `discord` / `msteams`: webhook URL - `fcm`: device registration token The value must match the expected format for the chosen medium. Invalid or incompatible values may result in notification delivery failure. - **targets** (array (string)): Notification targets: an array of target addresses (emails, phone numbers, device tokens, etc.). (example: ["admin@connhex.com","user@connhex.com"]) - **policy** (string (trigger|reentry)) (required): Defines when the notification should be dispatched: - `trigger`: The notification is sent when the rule is triggered (its conditions are satisfied). - `reentry`: The notification is sent when the rule re-enters (its associated conditions are no longer satisfied). ("trigger"|"reentry") - **medium** (string (email|telegram|sms|slack|discord|fcm|msteams)) (required) ("email"|"telegram"|"sms"|"slack"|"discord"|"fcm"|"msteams") - **text** (string) (required) - **muted** (boolean) - **conditions** (array (CreateConditionDto)) (required) Array items: - **params** (object) (required) - **source** (string (messages|params|metrics)) ("messages"|"params"|"metrics") - **metric** (string) (required): URN of the metric to be monitored (example: "urn:cpt:smartdevice:nid:D0CF5EFFFE26FDAB1:onoff") - **threshold** (number) (required) - **comparisonOperator** (string (>|>=|<|<=|==|!=)) (required) (">"|">="|"<"|"<="|"=="|"!=") - **unit** (string) (example: "°C") - **durationSecs** (number) (required) - **activeWindow** (object) - **from** (string) (required) (example: "08:10") - **to** (string) (required) (example: "13:15") - **timezone** (string) (required): IANA timezone identifier (example: "Europe/Rome") - **channelId** (string) (required): Connectable channel whose messages are evaluated by the condition. You must have access to this channel (action `core:channels:subscribe`) to create or update a rule. - **type** (string (threshold|lastMessageOlderThan|delta)) (required) ("threshold"|"lastMessageOlderThan"|"delta") ``` -------------------------------- ### Schema: CreateConditionDto Source: https://connhex.com/api/rules-engine/latest/api.json Schema definition for CreateConditionDto ```markdown ## Schema: CreateConditionDto Schema definition for CreateConditionDto **Type:** object - **params** (object) (required) - **source** (string (messages|params|metrics)) ("messages"|"params"|"metrics") - **metric** (string) (required): URN of the metric to be monitored (example: "urn:cpt:smartdevice:nid:D0CF5EFFFE26FDAB1:onoff") - **threshold** (number) (required) - **comparisonOperator** (string (>|>=|<|<=|==|!=)) (required) (">"|">="|"<"|"<="|"=="|"!=") - **unit** (string) (example: "°C") - **durationSecs** (number) (required) - **activeWindow** (object) - **from** (string) (required) (example: "08:10") - **to** (string) (required) (example: "13:15") - **timezone** (string) (required): IANA timezone identifier (example: "Europe/Rome") - **channelId** (string) (required): Connectable channel whose messages are evaluated by the condition. You must have access to this channel (action `core:channels:subscribe`) to create or update a rule. - **type** (string (threshold|lastMessageOlderThan|delta)) (required) ("threshold"|"lastMessageOlderThan"|"delta") ``` -------------------------------- ### PATCH /rules/{id} Source: https://connhex.com/api/rules-engine/latest/api.json Update rule. Required Permission: - Resource: ```ruleengine:rules:{id}``` - Action: ```ruleengine:rules:update``` ```markdown ### Parameters - **id** (string, path, required) ### Request Body **Content-Type:** application/json - **conditions** (array (object)) - **tags** (array (object)) - **name** (string) - **severity** (string (info|warning|critical)) ("info"|"warning"|"critical") - **description** (string) - **processable** (string (enabled|disabled)) ("enabled"|"disabled") - **notification** (object) - **messages** (array (NotificationMessageDto)) (required) Array items: - **target** (string): Notification target, whose format depends on the selected `medium`. If not specified, the notification is sent to the user who created the rule. Supported formats: - `email`: email address - `sms`: E.164 phone number (e.g. "+391234567890") - `telegram`: username ("@user") - `slack` / `discord` / `msteams`: webhook URL - `fcm`: device registration token The value must match the expected format for the chosen medium. Invalid or incompatible values may result in notification delivery failure. - **targets** (array (string)): Notification targets: an array of target addresses (emails, phone numbers, device tokens, etc.). (example: ["admin@connhex.com","user@connhex.com"]) - **policy** (string (trigger|reentry)) (required): Defines when the notification should be dispatched: - `trigger`: The notification is sent when the rule is triggered (its conditions are satisfied). - `reentry`: The notification is sent when the rule re-enters (its associated conditions are no longer satisfied). ("trigger"|"reentry") - **medium** (string (email|telegram|sms|slack|discord|fcm|msteams)) (required) ("email"|"telegram"|"sms"|"slack"|"discord"|"fcm"|"msteams") - **text** (string) (required) - **muted** (boolean) ### Responses #### 200 - response **ReadRuleDto** - **conditions** (array (ReadConditionDto)) (required) Array items: - **params** (object) (required) - **source** (string (messages|params|metrics)) ("messages"|"params"|"metrics") - **metric** (string) (required): URN of the metric to be monitored (example: "urn:cpt:smartdevice:nid:D0CF5EFFFE26FDAB1:onoff") - **threshold** (number) (required) - **comparisonOperator** (string (>|>=|<|<=|==|!=)) (required) (">"|">="|"<"|"<="|"=="|"!=") - **unit** (string) (example: "°C") - **durationSecs** (number) (required) - **activeWindow** (object) - **from** (string) (required) (example: "08:10") - **to** (string) (required) (example: "13:15") - **timezone** (string) (required): IANA timezone identifier (example: "Europe/Rome") - **channelId** (string) (required): Connectable channel whose messages are evaluated by the condition. You must have access to this channel (action `core:channels:subscribe`) to create or update a rule. - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **type** (string (threshold|lastMessageOlderThan|delta)) (required) ("threshold"|"lastMessageOlderThan"|"delta") - **id** (string) (required) - **tags** (array (ReadTagDto)) (required) Array items: - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **label** (string) (required): The key or category of the tag used for grouping or filtering. (example: "deviceID") - **labelValue** (string) (required): The specific value assigned to the tag label. (example: "e0ce7733-cd7c-415b-8430-4b1a5876362d") - **metadata** (object): Additional custom properties or contextual data associated with this tag. Useful for storing extra structured information. (example: "{ 'alias': 'Main Boiler Sensor', 'location': 'Warehouse A' }") - **id** (string) (required) - **status** (string (active|inactive)) (required) ("active"|"inactive") - **createdAt** (string (date-time)) (required) - **updatedAt** (string (date-time)) (required) - **deletedAt** (string (date-time)) (required) - **name** (string) (required) - **severity** (string (info|warning|critical)) ("info"|"warning"|"critical") - **description** (string) - **processable** (string (enabled|disabled)) ("enabled"|"disabled") - **notification** (object) (required) - **messages** (array (NotificationMessageDto)) (required) Array items: - **target** (string): Notification target, whose format depends on the selected `medium`. If not specified, the notification is sent to the user who created the rule. Supported formats: - `email`: email address - `sms`: E.164 phone number (e.g. "+391234567890") - `telegram`: username ("@user") - `slack` / `discord` / `msteams`: webhook URL - `fcm`: device registration token The value must match the expected format for the chosen medium. Invalid or incompatible values may result in notification delivery failure. - **targets** (array (string)): Notification targets: an array of target addresses (emails, phone numbers, device tokens, etc.). (example: ["admin@connhex.com","user@connhex.com"]) - **policy** (string (trigger|reentry)) (required): Defines when the notification should be dispatched: - `trigger`: The notification is sent when the rule is triggered (its conditions are satisfied). - `reentry`: The notification is sent when the rule re-enters (its associated conditions are no longer satisfied). ("trigger"|"reentry") - **medium** (string (email|telegram|sms|slack|discord|fcm|msteams)) (required) ("email"|"telegram"|"sms"|"slack"|"discord"|"fcm"|"msteams") - **text** (string) (required) - **muted** (boolean) - **id** (string) (required) #### 404 - response ### Example Usage ```bash curl -X PATCH "https://apis./rules/{id}" \ -H "Content-Type: application/json" \ -d '{ "conditions": [ "value" ], "tags": [ "value" ], "name": "string", "severity": "info", "description": "string", "processable": "enabled", "notification": "value" }' ``` ```