Skip to main content
Use simulations to dry-run single rules or full rule configurations without changing live balances, and use the sandbox to rehearse your end-to-end integration with saved events, test gift cards, and signed webhooks.

Choose an endpoint

Author a single rule

For one rule, iterate without touching live balances:
  1. Validate the condition (and optionally draft actions) with POST /v1/rules/validate.
  2. Simulate the draft with POST /v1/rules/simulate.
  3. Save the rule, then simulate the saved rule with POST /v1/rules/{rule_id}/simulate, passing participant_id to run against live participant state.
Writing rules covers request fields, warnings, and event.* field checks. A simulation result also shows the bucket each asset action would use, so you can check that a settlement with a future matures_in or matures_at lands in DEFERRED.

Test a full configuration

A rule configuration simulation tests a program’s rules together against sample or past events. It checks rule-set order, stop_after_match within each set, interactions between rules, and tier qualification after each event. It leaves live rules, balances, budgets, and participant state unchanged. You can retrieve the results afterward. Send it to POST /v1/programs/{program_id}/rule-configuration/simulations. Leave out rule_configuration to simulate your live configuration. To simulate a draft, add the same draft you send to analysis and preview as rule_configuration. Both return the same per-event detail. Use scenario mode for sample events, or replay mode for past events with their original timestamps. Both let you check which rules match, when budgets stop a payout, and which rules stop_after_match skips. Set options.compare_live to run your live configuration and a draft against the same inputs. Include the draft in rule_configuration. Use trace or full detail to see ordered condition and action outcomes. See Managing rule configuration for analysis, simulations, and the preview/apply path. See Rule sets for execution order and set-local stopping.

Scenario events

A scenario simulation sends sample events through your rules, in the order you list them. This example sends an authorization and then its settlement for one participant. It assumes the live configuration has two rules: the authorization CREDIT from Card authorizations and settlements on auth events, and the settlement CREDIT from Add a waiting period on settlement events.
This request simulates your live configuration. To simulate a draft, add rule_configuration to the request, using the same body you send to preview. The program comes from the path, so the body has no program_id. If you set neither external_id nor participant_id, each event goes to a random participant. scenario.participant_count sets how many participants the simulation has in total. Scrip adds sample participants when initial_state lists fewer. Scenario events have no timestamp of their own. Every event in a scenario simulation gets the same time, which Scrip picks for that simulation. It is not the current time, and it can be years away from today. Sending the same request again uses the same time, so time-based results repeat. To test an active window or a condition on now, replay real events, which keep their timestamps. You can also simulate one rule with an event_timestamp. The request returns 202 with the simulation’s id and its status:
Fetch the result with GET /v1/programs/{program_id}/rule-configuration/simulations/{simulation_id} until status is completed, failed, or timeout. At trace or full detail, result.events has one item per event, in order. Each item has event_index, event_type, source, participant_id, the rule_trace of the rules that ran, and totals. At "detail_level": "full", the default, it also has posting_diffs with one row for every balance change the event made, and state_diffs for state changes. With the two rules above on an UNLIMITED asset, the settlement’s rows show 42 moving into DEFERRED, the 50 pending leaving HELD, and the unused 8 going back to system issuance. Other fields are left out here:
At "detail_level": "full", an event can also have a lot_diffs list. The list appears only when the event creates, consumes, or changes the status of a lot. A SIMPLE asset has no lots, so its actions add no rows. Each row shows one change to a lot. These fields show which action caused it and what the lot looked like afterward: A row shows the lot as its action left it, even when a later action in the same event changes the lot again.

Test an automation

An automation sends its saved event_type and event_data unchanged. Check what the rules will do, then check that the automation delivers the event:
  1. What the rules will do. Send the automation’s event_type and event_data as a scenario event in a rule configuration simulation. The simulation shows which rules match and how balances would change, without changing live balances or state.
  2. A real end-to-end run. Create a one-time copy of the automation: same event_type and event_data, a ONE_TIME trigger with trigger_at omitted so it fires immediately, and a participant_filter pinned to a test participant (for example participant.external_id == "user_456"). The copy delivers one real event to that participant and moves to COMPLETED. Verify it like any processed event: fetch the event, read rule_evaluations, and check the balance.
Automations: testing an automation shows the request in full.

Verify a processed event

An event’s record shows its status and the rule evaluations Scrip recorded for it, so start debugging there:
  • status shows the lifecycle: PENDING → PROCESSING → COMPLETED or FAILED. Failed events carry a machine-readable error_code. Right after a 202, the GET can return 404 event_not_found while Scrip records the event. Wait for the event.completed webhook event or poll a bounded number of times; see Wait for the result.
  • rule_evaluations is the execution trace: which rules matched, credited, or were skipped, in the order they ran. An empty trace on a COMPLETED event means no condition matched.
  • GET /v1/events/{event_id}/impact shows the ledger effect: every balance change the event caused, with system accounts as counterparties.
Failed events with a fixed underlying cause can be replayed with the retry endpoint.

Test webhooks

Webhook handling is part of your integration:
  • 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.
  • Send a test delivery with POST /v1/webhook-endpoints/{webhook_endpoint_id}/test. Send a body such as {"event_type": "balance.credited"}. Scrip returns 202 and sends one signed sample marked "test": true. See Send a test delivery.
  • Verify signatures against the documented scheme, not by skipping verification in test environments. See Webhooks: Verify a delivery.
  • Watch endpoint health with the delivery listing and the endpoint’s circuit_broken_until and rate_limited_until fields to catch failures your handler swallows.
Webhook endpoints belong to your organization in one environment, not to a program. An endpoint subscribed to a webhook event type receives it from every program in that environment, so events you send to a program you created for a trial also reach the same endpoints your live programs use. Plan for that in handlers that notify customers or load data elsewhere. To try a handler without that traffic, send it a test delivery. In the sandbox, events reach only your sandbox endpoints, so a sandbox program and endpoint give you an end-to-end rehearsal of the production flow.

Writing rules

Validation and simulation payloads for a single rule.

Managing rule configuration

Preview and apply a multi-rule change.

Webhooks

Verify signatures and replay deliveries.