Update a rule in a ruleset
Applies one or more changes to an existing rule in a ruleset at the account or zone level.
Use one of the following API endpoints:
Operation | Method + Endpoint |
---|---|
Update an account ruleset rule | PATCH /accounts/{account_id}/rulesets/{ruleset_id}/rules/{rule_id} |
Update a zone ruleset rule | PATCH /zones/{zone_id}/rulesets/{ruleset_id}/rules/{rule_id} |
You can update the definition of the rule, changing its fields, or change the order of the rule in the ruleset. Invoking this method creates a new version of the ruleset.
To update the definition of a rule, include the new rule definition in the request body. You must include all the rule fields that you want to be part of the new rule definition, even if you are not changing their values.
The response will include the complete ruleset after updating the rule.
To reorder a rule in a list of ruleset rules, include a position
object in the request, containing one of the following:
-
"before": "<RULE_ID>"
— Places the rule before rule<RULE_ID>
. Use this argument with an empty rule ID value (""
) to set the rule as the first rule in the ruleset. -
"after": "<RULE_ID>"
— Places the rule after rule<RULE_ID>
. Use this argument with an empty rule ID value (""
) to set the rule as the last rule in the ruleset. -
"index": <POSITION_NUMBER>
— Places the rule in the exact position specified by the integer number<POSITION_NUMBER>
. Position numbers start with1
. Existing rules in the ruleset from the specified position number onward are shifted one position (no rule is overwritten). For example, when you place a rule in position n usingindex
, existing rules with index n, n+1, n+2, and so on, are shifted one position — their new position will be n+1, n+2, n+3, and so forth. If the index is out of range, the method returns a400
HTTP status code.
Reorder a rule without changing its definition by including only the position
object in the PATCH
request body. You can also update a rule definition and reorder it in the same PATCH
request by including both the rule
object and the position
object.
The following examples build upon the following (abbreviated) ruleset:
The following request with the position
object places rule <RULE_ID_2>
as the first rule:
In this case, the new rule order would be:
<RULE_ID_2>
, <RULE_ID_1>
, <RULE_ID_3>
, <RULE_ID_4>
The following request with the position
object places rule <RULE_ID_2>
after rule 3:
In this case, the new rule order would be:
<RULE_ID_1>
, <RULE_ID_3>
, <RULE_ID_2>
, <RULE_ID_4>
The following request with the position
object places rule <RULE_ID_1>
in position 3, becoming the third rule in the ruleset:
In this case, the new rule order would be:
<RULE_ID_2>
, <RULE_ID_3>
, <RULE_ID_1>
, <RULE_ID_4>