Skip to main content
POST
Simulate a draft rule
Tests an unsaved rule against sample data or a stored event. No rule, event, or balance change is saved. Send either event or event_id, not both. A stored event uses its original data and timestamp. When you omit both participant_id and participant_state, Scrip uses that event’s participant with their current state, or empty defaults if the event has no participant. Only the supplied rule is evaluated, so the result does not test ordering or stop behavior across rule sets. The response includes warnings from validating the draft’s expressions.
See Testing for the authoring workflow and testing a complete rule configuration.

Authorizations

Authorization
string
header
default:sk_...
required

Send your API key as Authorization: Bearer <key>.

Body

application/json

Program context, draft rule, sample event or stored event_id, and optional participant state

Simulates an unsaved rule against an event and a participant state. Nothing is saved.

program_id
string<uuid>
required

Program providing the validation and evaluation context (asset linkage, tier keys, participant state lookups)

Example:

"8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01"

rule
object
required

Rule is the draft rule to evaluate. It is validated exactly like rule create (CEL syntax, action structure, asset existence and program linkage, tier references) but never persisted.

diagnostics
boolean

Include an explanation of each part of the CEL condition. Nothing is saved.

Example:

true

event
object

Sample event data to evaluate against the draft rule. Numbers with a magnitude greater than 2^53 are rejected to prevent loss of precision. Supply exactly one of event or event_id.

Example:
event_id
string<uuid>

ID of a stored event to test the draft against. Scrip uses the event's original data and timestamp. The event must belong to the program in program_id. Supply exactly one of event or event_id.

Example:

"e5dc1b6a-7f3d-4e2a-8c1b-9a0f4d7e6c05"

event_timestamp
string<date-time>

When the sample event occurred. Used to check whether it falls within the rule's active window. Cannot be used with event_id, which uses the stored timestamp.

Example:

"2027-01-15T10:30:00Z"

event_type
string

The name of the sample event, such as purchase: the event_type an ingested event carries. Required with event, and the rule reads it as event.type. The event object must not contain a type key. Omit it with event_id, which uses the stored event's name.

Example:

"purchase"

participant_id
string<uuid>

A real participant whose current tags, counters, attributes and tiers Scrip loads as the simulation's participant context. Send this or participant_state, not both.

Example:

"f7a8b9c0-1d2e-4f3a-b4c5-d6e7f8a9b006"

participant_state
object

Simulated participant state (tags, counters, attributes), with the same meaning as in POST /v1/rules/{rule_id}/simulate. Send this or participant_id, not both.

Response

Simulation result

The result of a rule simulation: the rule, the evaluation and any warnings.

evaluation
object

Evaluation contains the simulation results

rule
object

Rule contains metadata about the rule that was simulated

warnings
object[]

Advisories about the simulation context. For example, missing_participant_context means the condition reads participant state but the request sent neither participant_id nor participant_state, so the condition ran against empty defaults.