Save rules
put_rulesCreate or replace a domain's rule set from YAML, with validation and a dry-run mode to test before saving, reporting errors and overlap warnings.
Instructions
Create or replace a domain's rule set from YAML (self-serve rule authoring).
The first save to a new domain claims it for your account (plan limits apply); the built-in demo domains are read-only. Rules are validated before saving — set dry_run=true to validate without persisting. The response reports ok/errors, the parsed rules, and any overlap warnings.
YAML format — a list of rules. Flat form (conditions are AND-ed): - name: "Approve" salience: 10 conditions: - type: loan field: credit_score op: ">=" value: 700 action: verdict: "APPROVED" reason: "Credit score meets threshold"
Tree form — when: holds nested all/any/not condition groups, and an
action may assert derived facts that other rules consume (forward
chaining; the rule graph derives from these automatically):
- name: "Sepsis Screen"
salience: 30
when:
all:
- {type: clinical, field: temperature_f, op: ">=", value: 101.5}
- any:
- {type: clinical, field: wbc_count, op: ">", value: 12.0}
- {type: clinical, field: bands_pct, op: ">", value: 10}
action:
verdict: "URGENT_ALERT"
assert:
- {type: sepsis_flag, fields: {severity: high}}
- name: "Escalate"
salience: 40
when:
all:
- {type: sepsis_flag, field: severity, op: "==", value: high}
- {type: clinical, field: age, op: ">=", value: 65}
action:
verdict: "ADMIT_ICU"
Use either conditions: or when: per rule, never both. not passes
when the inner condition does not hold (including when the field is
absent). Produce/consume cycles between rules are rejected at validation.
An action may also carry retrieval_scope: { <key>: <value> } to narrow
which documents retrieval searches (Pattern 01).
A rule may also carry citation: — the policy sentence it encodes. It is
stored with the rule and shown beside it in decision audits, so a verdict
can be defended with the source language, not just the rule name:
- name: "Decline Late Returns"
salience: 20
citation: "Returns are accepted within 30 days of delivery."
when:
all:
- {type: retail, field: days_since_delivery, op: ">", value: 30}
action:
verdict: "DENIED"
IMPORTANT: when persisting drafts returned by import_policy_rules, copy
each rule's citation through into this YAML. Dropping it silently loses
the link from the decision back to the policy clause that justifies it.
Args: domain: Domain to author (an owned domain, or a new name to claim). rules_yaml: The full rule set as YAML text. dry_run: Validate only, without saving.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | ||
| dry_run | No | ||
| rules_yaml | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |