Skip to main content
A program’s rule configuration is every rule set and non-archived rule Scrip will evaluate: order, status, actions, and budgets. Scrip stores that snapshot under one number, rule_configuration_version, and increases the number 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 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.

Read the current configuration

The response is one snapshot: every rule set in execution order, and every ACTIVE and SUSPENDED rule in each set. Archived rules are omitted.
Pass rule_configuration_version from this response on move, reorder, preview, and rollback requests. 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 snapshot. See Get the complete rule configuration.

Move or reorder

To place one rule or set, send a position of first, last, before, or after. before and after need reference_id. See Rule sets for execution order. Move one set:
Replace the full set order when you already have the sequence you want. The list must contain every current rule set exactly once:
Reorder the 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:
Move a rule inside its set, or into another set, in one request:
A cross-set move renumbers the source and destination in the same transaction.

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 run a test before you apply a change that spans several rules. Send {} to analyze the live configuration:
To analyze a draft, send that draft as proposed_configuration in the same shape as preview. Each finding includes severity, confidence, runtime_semantics, and remediation.
Analysis is conservative and advisory. Treat a likely or advisory finding as a reason to inspect and test the draft.
See Analyze a rule configuration. Then send the same draft as rule_configuration to POST /v1/test-runs. The test run evaluates in a transaction that rolls back. It does not change live rules, balances, budgets, or stored state. Testing covers scenario vs replay, compare_live, and traces. 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, or budgets. The preview body is the configuration you want, in execution order:
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. The response includes: Read the plan, diff, and warnings. Then apply exactly what preview stored:
The apply body cannot change the proposal. Scrip verifies the token, expiry, request hash, configuration version, and referenced dependencies, then commits the plan in one transaction. A successful apply increases rule_configuration_version by one. A preview can be applied once. If it expires, was already applied, or no longer matches current dependencies, 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:
Use pagination.next_cursor for the next page. Get one revision:
Find the latest tracked revision at or before a timestamp:
If the timestamp is before tracked history, the response omits revision and returns a caveats entry. Compare two tracked revisions:
Omit to_version, or pass to_version=current, to compare a tracked revision with the live configuration.
Program-level history starts at earliest_tracked_version. Requests that reach before it return caveats (history_not_yet_tracked, pre_history_legacy_data).

Roll back

Rollback builds a normal preview that restores a past configuration. History is left in place; the restore is a new revision.
Review the plan, inverse diff, and warnings. Apply it with the same 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. Existing rule and rule-set IDs stay the same. The new revision records source_revision, so you can see which historical configuration was restored and who applied it. See Preview a rule-configuration rollback.

If a request fails