Creates a business ruleset. A ruleset groups business rules so that they can be evaluated together, in the priority order you assign, using the strategy set in execute_mode.
Use this operation when a decision is made by several rules that belong together, such as all the checks that a quote must pass or the ladder of discounts that can apply to it. Once the ruleset exists, a single call to Apply business rules with its ruleset_id evaluates all of its rules.
Passing rules is optional. You can create an empty ruleset and fill it later with Add business rules to a ruleset.
Prerequisites & Constraints
- Business rules must be enabled for the site.
- Each rule referenced in
rulesmust already exist.
Impacts
Business ruleset
A business ruleset is created with active set to false and with the rules you passed in rules as its membership.
Nothing is evaluated yet. A rule is evaluated through a ruleset only when both the ruleset and the rule itself are active, so each one has to be activated separately.
Implementation Notes
- Create the rules first with Create a business rule, then reference their identifiers in
rules. Arule_idthat does not resolve to an existing rule is rejected. - Call Activate a business ruleset once the membership is in place, so that Chargebee starts evaluating the ruleset.
Use Cases
Evaluate every rule in the group
Leave execute_mode at its default of execute_all, or set it to execute_all_true if you only want the rules that matched to be returned. Use this when the rules are independent of one another, such as a set of validations that should all be reported.
Pick the first rule that matches
Set execute_mode to stop_on_first_true and assign the priorities so that the most specific rule is evaluated first. Evaluation stops at the first rule that matches, which makes the ruleset behave like an ordered list of alternatives.
Stop at the first failed check
Set execute_mode to stop_on_first_false so that evaluation stops at the first rule that is not satisfied. Use this when later rules only make sense if the earlier ones passed.
Sample Request
Sample Result[JSON]
URL Format
Input Parameters
Strategy that determines how the rules in the ruleset are evaluated and when evaluation stops.
Default value
execute_all.
Evaluation stops as soon as a rule evaluates to true. The rules that come later in the evaluation order are not evaluated.
Evaluation stops as soon as a rule evaluates to false. The rules that come later in the evaluation order are not evaluated.
Every rule in the ruleset is evaluated and all the results are returned. This is the default.
Every rule in the ruleset is evaluated, and only the rules that evaluated to true are returned.
The business rules that make up the ruleset, along with the priorities that determine their positions in its evaluation order. Each entry takes the rule_id of an existing business rule and an optional priority; when priority is omitted, it is assigned from the position of the entry in the array. Pass the list as a JSON array.
Constraints
- Each
rule_idmust belong to a business rule that already exists. - A
prioritycan be used by only one rule in the ruleset. Two entries that carry the samepriorityare rejected.
Example →
rules = [{"rule_id":"custom-uuid-1","priority":1},{"rule_id":"custom-uuid-2","priority":2}]
Returns
The newly created business ruleset, with active set to false and with the rules you passed in rules as its membership.