Update Message Rules


Update message rules.

Request Format


POST https://{apigw-address}/app-portal-service/v2.2/message-service/rule/update

Request Parameters (URI)


Name

Location (Path/Query)

Required/Optional

Data Type

Description

orgId

Query

Required

String

OU ID. How to get orgId >>

Request Parameters (Header)


Name

Required/Optional

Data Type

Description

Authorization

Optional

String

The access token generated after the user logs in and selects the OU, represented by Bearer Token, is in the form of Bearer {your token}. You can call the Log In or Refresh Access Token API to obtain the access token.

  • If this parameter is not specified, the user of the update will be considered as the application.

  • If this parameter is specified, the user of the update will be considered as the user which the access token belongs to. The OU for obtaining the Access Token should be consistent with the value of the request parameter orgId.

Request Parameters (Body)


Name

Required/Optional

Data Type

Description

ruleId

Required

String

Message rule ID.

ruleName

Optional

String

Message rule name. If not specified, the name will not be updated.

isEnable

Optional

String

Whether to enable the rule. The following values ​​are supported:

  • 0 for disabled.

  • 1 for enabled.

If not specified, the state of the rule will not be updated.

messageRule

Required

Object

Conditions that trigger messages based on specific marks, such as assets, users, or event types. After specifying, the existing conditions in the rule will be overwritten. Each rule must contain 1 to 6 marks. Only when all marks in the rule are satisfied can the message be triggered. Marks are key-value pairs in the form of "markN": ["value1", "value2", ...] or "markN": null, where:

  • Key: must be in the markN format, such as mark1, mark2, where N is a positive integer. Keys are unique within a rule.

  • Value: a list of strings (or null) representing the associated entities, such as site ID, user ID, etc. Each value can be up to 400 characters long. If multiple entities are listed in a value, an event that matches any of the entities satisfies the mark.

For example, "messageRule": {"mark1": ["siteA", "siteB"], "mark2": ["user123"]} means that the rule will be triggered and a message will be sent to the users or user groups when the event is associated with siteA or siteB, and is also associated with user123.

relations

Optional

RelationDTO Struct

The users or user groups associated with the rule. If not specified, the objects associated with the rule will not be updated. relationDTO Struct >>

RelationDTO Struct


Name

Required/Optional

Data Type

Description

type

Optional. Required if you need to specify the associated object of the rule.

Integer

The object type. The following values ​​are supported:

  • 0 for user.

  • 1 for user group.

identifiers

Optional. Required if you need to specify the associated object of the rule.

List

The ID of user or user group.

Response Parameters


Name

Data Type

Description

data

Boolean

Update result. true indicates that the update was successful. false indicates that the update failed.

Error Codes


Error Code

Description

31400

OU ID is required, parameters are invalid, etc.

31404

Non-existed OU, application, user, user group, or message rules; or application not acquired.

31600

Message rule error.

31601

The number of message rules exceeds the limit.

31602

The number of marks in the message rule exceeds the limit.

31603

The message rule does not match.

31604

Message rule marks are required.

31607

Organization structure error.

Samples

Request Sample


url: https://{apigw-address}/app-portal-service/v2.2/message-service/rule/update?orgId=your_org_id

method: POST

requestBody:
{
    "ruleId": "your_rule_id",
    "ruleName": "your_rule_name",
    "isEnable": 0,
    "messageRule": {
        "mark1": ["siteA","siteB"],
        "mark2": ["deviceA","deviceB"],
        "mark3": ["fault"],
        "mark4": [""],
        "mark6": null
    },
    "relations": [
        {
            "type": 0,
            "identifiers": ["your_user_id_1","your_user_id_2"]
        },
        {
            "type": 1,
            "identifiers": ["your_user_group_id"]
        }
    ]
}

Return Sample


{
    "code": 0,
    "message": "OK",
    "data": true
}