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
- Retrieve the current definition before you send this request, so that you can pass it back in full. Use Retrieve a business rule draft if the rule already has a draft, or Retrieve a business rule if it does not, which returns the released version the draft will be created from.
- Call Release a business rule to promote the draft to the version that Chargebee evaluates, or Delete a business rule draft to discard it.
Sample Request
Sample Result[JSON]
URL Format
Input Parameters
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
fieldis absent from the context passed to Apply business rules evaluates tofalse, 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"]}]}
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
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.