The authoring loop
For a single rule, iterate without touching live data:- Validate the condition (and optionally draft actions) with
POST /v1/rules/validate. This catches CEL compile errors and, with aprogram_id, checks tier keys and asset symbols against real configuration. - Simulate the draft with
POST /v1/rules/simulatebefore saving. The response shows whether the condition matched and every resolved action amount. - Save the rule, then simulate the saved rule with
POST /v1/rules/{id}/simulate, passingparticipant_idto run against a real participant’s live state, the same context production evaluation sees.
event.* fields are schemaless, so a misspelled event field compiles fine and then silently never matches. Check which event fields your rules depend on with the event references endpoint and confirm your event sender supplies each one.
Testing multiple rule sets
Simulation evaluates one rule. It does not run the program’s other rules or rule sets, so it cannot prove cross-set ordering orstop_after_match containment.
To verify the full execution sequence before publishing, send the same draft used by analysis and preview as rule_configuration in POST /v1/test-runs. Scenario mode exercises matches, misses, windows, budgets, and set-local stops. Replay mode runs recent historical events. Both run in rollback-only transactions.
Set options.compare_live to run the current and proposed configurations against the same inputs. Use trace or full to see ordered condition and action outcomes. Put specific rule IDs in options.diagnostics.rules when you need clause-level explanations.
Check these properties in the event response:
- Evaluations follow ascending set order and then local rule order.
- Each evaluation carries the
rule_set_idused at execution time. - A matching
stop_after_matchrule skips later rules in its own set only. - Rules in later sets still participate.
- Conditions and dynamic action expressions use the pre-event state snapshot.
Verifying processed events
Every event records what happened, which makes the event itself your main debugging tool:statusshows the lifecycle:PENDING→PROCESSING→COMPLETEDorFAILED. Failed events carry a machine-readableerror_code.rule_evaluationsis the execution trace: which rules matched, credited, or were skipped, in the order they ran. An empty trace on aCOMPLETEDevent means no condition matched.GET /v1/events/{id}/impactshows the ledger effect: every balance change the event caused, with system accounts as counterparties.
Testing webhooks
Webhook handling is part of your integration and deserves its own tests:- Replay real deliveries with the resend endpoint instead of manufacturing traffic: it re-dispatches a past delivery through the normal path with a fresh signature.
- Verify signatures against the documented scheme, not by skipping verification in test environments. The signature verification section includes worked examples.
- Watch endpoint health with delivery stats and the delivery listing to catch failures your handler swallows.