The Rule Engine evaluates declarative rules against any JSON payload. A rule has a condition and a then/else block. Rules are organized into rule sets, persisted, versioned, and executed via REST. It powers pricing decisions, eligibility checks, dynamic scoring, fraud gates, and any custom logic that needs to change without redeploying code.
What it covers
- Pricing rules — Bulk discounts, channel-specific markups, dynamic margins based on competitor data.
- Eligibility checks — Whether an order can ship to an address, whether a customer qualifies for a promo, whether a lead matches an ICP.
- Scoring — Lead scoring weights, fraud risk, content recommendations.
- Custom business logic — Anything you'd otherwise write in a one-off service. Rule authors get YAML or JSON; engineers don't have to redeploy.
Surface area
Two controllers expose the engine:
/rule-engine/*— Stateless execution and validation./rules/*— Rule sets (CRUD, versions, clone, import/export), helpers (custom functions), AI generation, analytics./rule-sets/*— Lower-level rule-set CRUD.
Rule authoring: write YAML or JSON, validate, save as a rule set, execute by ID.
Rule shape, in brief
version: 2.0
rules:
- id: BULK_DISCOUNT
when: order.lineCount >= 10
then:
apply_discount:
type: percent
value: 5
else:
apply_discount:
type: percent
value: 0
The same rule in JSON:
{
"id": "BULK_DISCOUNT",
"when": { ">=": ["order.lineCount", 10] },
"then": { "apply_discount": { "type": "percent", "value": 5 } },
"else": { "apply_discount": { "type": "percent", "value": 0 } }
}
Rules can iterate (for), switch (switch/cases), set variables (vars), and call helper functions (COUNT, FILTER, SUM, plus org-defined helpers).
Where each piece lives
| Topic | Page |
|---|---|
| Data shape, operators, helpers | Syntax |
| Natural-language rule generation | AI generation |
| Validate and dry-run | Testing |
| Caching and indexed evaluation | Performance |
Cross-module use
The engine is used internally by:
- Sales Channel — per-channel pricing rules.
- CRM — audience segmentation, lead routing, scoring weights.
- Storefront — discount eligibility, dynamic pricing.
- Automation — when a flow needs richer evaluation than
check_field_valuecan express, an action calls the rule engine and branches on the outcome.
Rules and Automation conditions overlap. Use Automation conditions for simple field comparisons inside a workflow. Use the Rule Engine when the logic is reusable across surfaces (a pricing rule that applies in checkout, sales-channel sync, and quote generation alike).