# Business Ruleset

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


A business ruleset groups [business rules](/docs/api/business_rules) so that they can be evaluated together, in the priority order you assign, using the strategy set in `execute_mode`.

Rulesets let you apply a whole decision at once instead of calling each rule separately. Passing a `ruleset_id` to [Apply business rules](/docs/api/business_rules/apply-business-rules) evaluates the rules the ruleset contains in their priority order and returns a result for each one. The `execute_mode` decides whether evaluation runs through every rule or stops as soon as a rule evaluates to `true` or to `false`, and which of the results are returned.

Membership is managed separately from the rules themselves. [Add business rules to a ruleset](/docs/api/business_rulesets/add-business-rules-to-a-ruleset) and [Remove business rules from a ruleset](/docs/api/business_rulesets/remove-business-rules-from-a-ruleset) change membership incrementally, while passing `rules` to [Update a business ruleset](/docs/api/business_rulesets/update-a-business-ruleset) replaces it entirely. A rule can belong to more than one ruleset, and removing it from a ruleset does not delete the rule.

The `active` attribute controls whether Chargebee evaluates the ruleset. A rule is evaluated through a ruleset only when both the ruleset and the rule are `active`.

**Note:** Business rules are not enabled by default. Contact [Chargebee Support](https://www.chargebee.com/support/) to enable them for your site. Until they are enabled, these endpoints return an error.

## Sample Business ruleset

```json
{
  "id": "quote_create_rules",
  "name": "Quote creation rules",
  "description": "Rules evaluated when a quote is created.",
  "active": false,
  "execute_mode": "execute_all",
  "updated_at": 1788510782,
  "updated_by": "full_access_key_v1",
  "created_by": "full_access_key_v1",
  "created_at": 1788510782,
  "resource_version": 1788510782918,
  "object": "business_ruleset"
}
```

## Business Ruleset attributes

## Input Parameters

- `id` (required, string, max chars=100)
  Unique identifier of the business ruleset.

- `name` (required, string, max chars=500)
  Display name of the business ruleset.

- `description` (optional, string, max chars=1000)
  Description of what the business ruleset does.

- `active` (required, boolean)
  Whether Chargebee evaluates the ruleset. Use [Activate a business ruleset](/docs/api/business_rulesets/activate-a-business-ruleset) and [Deactivate a business ruleset](/docs/api/business_rulesets/deactivate-a-business-ruleset) to change this value.

- `execute_mode` (required, enumerated string, default=execute_all)
  Strategy that determines how the rules in the ruleset are evaluated and when evaluation stops.
  Possible enum values:
    - `stop_on_first_true`
      Evaluation stops as soon as a rule evaluates to `true`. The rules that come later in the evaluation order are not evaluated.
    - `stop_on_first_false`
      Evaluation stops as soon as a rule evaluates to `false`. The rules that come later in the evaluation order are not evaluated.
    - `execute_all`
      Every rule in the ruleset is evaluated and all the results are returned. This is the default.
    - `execute_all_true`
      Every rule in the ruleset is evaluated, and only the rules that evaluated to `true` are returned.

- `updated_at` (required, timestamp(UTC) in seconds)
  Timestamp at which the ruleset was last modified.

- `updated_by` (optional, string, max chars=100)
  User or API key that last modified the ruleset.

- `created_by` (required, string, max chars=100)
  User or API key that created the ruleset.

- `created_at` (required, timestamp(UTC) in seconds)
  Timestamp at which the ruleset was created.

- `rules` (optional)
  The [business rules](/docs/api/business_rules) that belong to the ruleset, each with the `rule_id` of the rule and the `priority` that determines its position in the ruleset's evaluation order. Priorities are unique within a ruleset.
  
  Only the identifier and priority of each rule are carried here, not its expression or actions. Use [List rules in a business ruleset](/docs/api/business_rulesets/list-rules-in-a-business-ruleset) to page through the membership of a ruleset, and [Retrieve a business rule](/docs/api/business_rules/retrieve-a-business-rule) to read a rule's definition.

- `resource_version` (optional, long)
  Version number of this resource. Each update of the resource increments the `resource_version`. Concurrent updates can be detected by comparing this value across requests.

