rule_configuration_version, increases by one on every change.
Writing rules covers creating and updating one rule at a time. Use this page when more than one writer can change the same program, or when one change touches several rules or sets. The dashboard and the Scrip MCP server, which lets AI clients work with your programs, follow the same flow.
Choose an endpoint
Create and patch on a single rule or set do not check
rule_configuration_version, so two writers can overwrite each other. They still return the new version when the write changes the configuration. Place rules and sets with position, and read their resulting rank in order.
Read the current configuration
ACTIVE and SUSPENDED rule in each set. Archived rules are omitted.
expected_rule_configuration_version. A preview takes it as base_rule_configuration_version. If another writer changes the program first, those requests return 409 rule_configuration_version_conflict. Read the configuration again and rebuild the request from the new configuration.
Leave rule_set_id and order out when you rebuild a request from this response: a preview request that includes either returns 400 validation_error.
See Get the complete rule configuration.
Move or reorder
To place one rule or set, send aposition object. Its placement is first, last, before, or after, and before and after also need a reference_id. See Rule sets for execution order.
Each example below starts from the configuration above, at version 12. Each returns 200 with the renumbered order and the new rule_configuration_version, 13. Send that number on your next write.
Move one set. This puts tracking before default:
ACTIVE and SUSPENDED rules in one set the same way. Include every non-archived rule in that set exactly once. An empty rule_ids list is valid for an empty set. This request puts Dining bonus first in default:
tracking set:
Check a draft
Single-rule validation and simulation evaluate one rule. They do not run the rest of the program, so they cannot prove cross-set order,stop_after_match, or conditions that depend on an earlier rule’s writes. Analyze the draft and simulate it before you apply a change that spans several rules.
Send {} to analyze the live configuration:
proposed_configuration, in the same shape as a preview. The response lists findings. Each finding has these fields:
See Analyze a rule configuration.
Then send the same draft as
rule_configuration to POST /v1/programs/{program_id}/rule-configuration/simulations. The simulation shows the results without changing live rules, balances, budgets, or participant state.
Test a full configuration covers testing with sample events or past events, comparing a draft with the live rules (compare_live), and reading each event’s rule trace. The multi-set example shows a layout where set-local stops and the event-start snapshot matter.
Preview and apply
Use preview and apply when one change updates several rule sets, rules, positions, statuses, actions, budgets, or field definitions. The preview body is the configuration you want, in execution order. This one starts from the configuration read above, at version12, and adds a suspended Summer bonus rule to default:
Preview runs the same CEL, action, target, asset, and budget checks as a single-rule write. It does not change the live configuration or increment the version.
Event field and state definitions
field_definitions is optional. It annotates an event field, and a rule can read any event.* field without one. Add state_definitions for any new counter or tag a new or changed rule writes:
field_definitions: Specifyevent_type(the event name the definition applies to, matched againstevent.type),path(such asevent.amount),label, andtype(text,number,dollars,cents,bool,datetime, orenumwithvalues).state_definitions: Specifyscope(participant,group, orprogram),kind(counterortag),key,label, andunit(number,dollars, orcentsfor counters). A counter can also take awindowfor a rolling total; see Counter windows. A definition can carry display fields too; see Display fields.- Definitions are additive across your organization; omitting existing definitions from a preview request leaves them saved.
A rule that reads an event field no recent event carries gets an
event_field_not_received warning. The warning compares the rule with the program’s externally sent events from the last 7 days, up to 50. When the condition checks event.type against a literal name, the comparison uses events of that name and the warning carries event_type. Preview returns it with the rule’s rule_id and client_ref.
200 with a change_id and the new rule_configuration, whose rule_configuration_version is one higher, 13 here. A preview can be applied once. If it expires, was already applied, or no longer matches the live configuration, create a new preview.
See Preview a rule-configuration change set and Apply a rule-configuration change set.
History
Each change that takes effect creates one revision. A revision stores the configuration at that version and the diff from the previous one. List revisions, newest first:pagination.next_cursor for the next page.
Get one revision:
Roll back
Rollback builds a normal preview that restores a past configuration. History is left in place; the restore is a new revision.preview_token and request_hash as any other preview.
Rule sets created after the target revision remain, with no rules, because rule sets cannot be deleted. The preview warns about each of those sets. Rules created after the target are archived. Rules archived since the target come back with their original IDs. Existing rule and rule-set IDs stay the same.
The new revision records source_revision, so you can see which version was restored and who applied it.
See Preview a rule-configuration rollback.
If a request fails
Testing
Prove a draft with analysis and simulations before you apply.
Writing rules
Create or patch one rule, including validation and simulation.
Rule sets
Execution order and set-local
stop_after_match.