Introducing OpenTelemetry for Chargebee SDKs — trace every API call in any telemetry tool.

Update a business rule draft

Updates the draft version of a business rule. The first edit creates a draft from the released version, and every later edit updates that same draft. Changes made to a draft do not affect rule evaluation until the draft is released.

Send the full definition of the rule rather than only the attributes you are changing. The values you pass replace the draft instead of being merged into it, so an attribute you leave out is dropped from the draft rather than carried over.

Use this operation to revise a rule that is already in use. The released version stays in effect while you prepare the next one, which lets you stage a change and review it before it takes effect.

Prerequisites & Constraints

Business rules must be enabled for the site.

Impacts

Business rule

The draft version of the rule is replaced with the values you pass, and updated_at and updated_by are set. latest_version, released_at, released_by, and active are unchanged, and Chargebee keeps evaluating the released version.

Implementation Notes

Sample Request

Sample Result[JSON]

URL Format

POST https://[site].chargebee.com/api/v2/business_rules/{business-rule-id}/draft

Input Parameters

name
required, string, max chars=500

Display name of the business rule.

description
optional, string, max chars=1000

Description of what the business rule does.

structured_expression
required, jsonobject

A structured JSON representation of the rule logic, designed for visual editors and dynamic builders. Chargebee validates and compiles it when the draft is updated. Pass it as a JSON object.

See Expressions for the node types and the operators each field type supports, and Context for the fields a condition can reference.

Impacts

  • A condition whose field is absent from the context passed to Apply business rules evaluates to false, so the rule never matches and no error is returned.

Example → structured_expression = {"type":"GROUP","operation":"AND","children":[{"type":"CONDITION","field":"customer.language","operator":"CONTAINS","value":"en"},{"type":"CONDITION","field":"quote.shipping_address_country","operator":"ANY_OF","values":["IN","US","GB"]}]}

actions_on_success
optional

The actions to execute when the rule expression evaluates to true, passed as a JSON array. Each action takes the action_template_id of the template it is built from and that template's parameters in input.

See Actions for the templates available, the parameters each one takes, and the optional action-level structured_expression that narrows the items an action applies to.

Example → actions_on_success = [{"action_template_id":"action-apply-discount","input":{"apply_on":"invoice_amount","duration_type":"one_time","discount":15.0,"discount_type":"percentage"}}]

Returns

Business rule object

The business rule with its draft updated. latest_version, released_at, released_by, and active are unchanged, so Chargebee keeps evaluating the released version until the draft is released.