${{ ... }} to compute amounts, counter values, attributes, reference IDs, or dynamic targets.
Operators
Available variables
When a rule runs, these variables are available in your conditions and in every action field that uses${{ }}, including target.
event
The event_data payload from your API request, with event.type set to the event’s event_type. Fields depend on what you send, so every expression you write is specific to your event schema.
double():
Numeric magnitude limit
CEL evaluates JSON numbers as 64-bit floats, which are only exact up to a magnitude of 2^53 (9,007,199,254,740,992). To protect ledger precision, event ingestion and rule simulation reject any JSON number inevent_data above that magnitude with 400 amount_precision_exceeded. If you need to carry larger values, send them as strings; string values pass through exactly. The same boundary applies at execution time: an amount expression whose result exceeds 2^53 fails the action rather than posting an imprecise amount.
Optional fields
Not every event has the same shape. If a condition references a field that isn’t in the payload, the condition evaluates tofalse, the rule does not match, and no rule-evaluation row is recorded for that rule. Use has() to check for a field before accessing it:
FAILED.
participant
The participant’s current state at the time of evaluation. Most rules use this to check tags, counters, or attributes before granting rewards.
Identity
Participant identity fields are available alongside state:enrolled_at and created_at are CEL timestamps, so date math works directly without timestamp():
Tags
"x" in participant.tag (and "x" in participant.counter) reflects whether a key is actually set, while participant.tag.<name> returns the default (false / 0) for unset keys, and has(participant.counter.x) is always true. Use in when you need a real presence check.Counters
Use theparticipant.counter.<name> shorthand. A missing counter defaults to 0, so you don’t need get():
participant.counter["q1-2027"].
Counter values are always evaluated numerically, even when the source carried them as decimal strings (the wire format the participant state endpoints return). You can copy a counters map from a state read into a simulation request as-is, with no casting needed.
Attributes
A missing attribute viaparticipant.attribute.<name> is null (no error):
Balances
Useparticipant.balance.<symbol> to read the participant’s available ledger balance for a program-linked asset:
0. An unknown symbol has no default: a condition that reads it does not match, and an action expression that reads it fails the action. Even get(participant.balances, "unknown", 0.0) does not return the default for an unknown symbol.
Balances are snapshotted at event start, like counters. Actions from earlier rules in the same event are not visible to later rule conditions, so use the projected-balance form above when you need to detect a same-event crossing.
Balance references are also validated when you save a rule. A symbol not linked to the rule’s program is rejected with a 400 such as unknown asset symbol "gems" (linked to program: credits, points). In automation participant_filter and guard_condition expressions, balance references are rejected at save entirely.
recipient
The second participant named by recipient_id or recipient_external_id on the event. Rules can read recipient.id and recipient.external_id. Use {"participant_id": "${{ recipient.id }}"} as an action’s target to credit that participant. See Sending an event.
program
The program’s current state. Supports the same tags, counters, and attributes as participants. Use this for global logic that isn’t tied to any one participant, like a program-wide redemption cap.
groups
List of groups the participant belongs to. Each entry has id, name, tags, counters, attributes, and tiers, and supports the same counter/tag/attribute shorthand.
A participant can belong to multiple groups, so prefer
groups.exists(g, ...) over assuming a specific list position.now
The event’s event_timestamp as a CEL timestamp. Scrip uses the event timestamp rather than wall-clock time so that evaluation stays deterministic across retries and reprocessing.
Quick reference
Numbers and money
Rules read numbers fromevent_data, counters, and balances as floating-point numbers. When one side of an operator is an event, counter, or balance number, 10 and 10.0 mean the same thing, so participant.counter.purchase_count >= 10 and event.amount * 10 need no .0.
Whole numbers behave differently in three places:
For amounts, three more rules apply:
- Scrip rounds the result of an amount expression to the asset’s
scale, half-up. On ascale: 0asset,211.5credits212. Money amounts end to end explains why cents work best. - An amount expression that returns
0or less fails the action, and with it the whole event. A positive result that rounds to0at the asset’s scale credits nothing, and the event completes. math.floor()andround(value, 0)return0for small amounts. Guard the condition so the rule matches only when the result is positive.
Helper functions
Scrip addsget(), round(), the duration_* helpers, and the calendar.* helpers on top of standard CEL for safe map access, rounding, and time calculations. has() and timestamp() are standard CEL functions, listed here because most rules use them.
get(map, key, default)
Reads a value from a map, returning default if the key doesn’t exist. For counters, tags, and attributes, prefer the dot-access shorthand (participant.counter/tag/attribute.<name>), which already returns a default for a missing key.
Tiers have no shorthand: read a tier with participant.tiers.<key>.<field>. Every tier the program defines has an entry, even for a participant with no level. On an event with no participant, participant.tiers is empty, so use get() with a default object to keep the field access safe.
round(value, scale)
Rounds a number to the specified decimal places. Halves round away from zero.
round() result of exactly 0 fails the action and the whole event, so round(event.amount * 0.01, 2) fails a purchase under $0.50. A positive amount that rounds to 0 at the asset’s scale is skipped instead. Scrip already rounds amounts to the asset’s scale, so leave round() out unless you need a different number of decimal places. See Numbers and money.
duration_hours(duration)
Converts a CEL duration to hours. You get a duration by subtracting two timestamps. Multiply by 60 for minutes.
duration_days(duration)
Converts a CEL duration to days.
duration_weeks(duration)
Converts a CEL duration to weeks.
Calendar helpers
Five helpers work with calendar days, weeks, and months.period is "DAY", "WEEK" (starting Monday), or "MONTH". zone is an IANA time zone name, such as "America/Chicago". It is optional and defaults to UTC. Returned timestamps are in UTC.
calendar.next for an expiry at the end of the event’s month. This CREDIT issues a lot that expires at midnight on the first of the next month in Chicago:
expires_at that has already passed, so its lot cannot be spent and expires within a few minutes.
calendar.daysBetween counts date changes, not 24-hour blocks: 11:55 PM to 12:05 AM the next day is 1, and daylight saving changes do not affect it. An unknown period or time zone fails when the expression runs, not when you save the rule. To keep a separate counter total per period, use a calendar counter.
has(field)
Returns true if a field exists on an object. Use this for event fields that only appear on some event types.
timestamp(string)
Parses an RFC 3339 string (e.g., "2027-06-01T00:00:00Z") into a CEL timestamp for comparison and arithmetic.
Extensions
Scrip enables the CEL math, sets, and strings extension libraries.Math
Min/max capping, absolute value, and rounding. Useful for bounding dynamic amounts to a floor or ceiling.Sets
Membership checks across lists for tag-based conditions.Strings
The strings extension adds these functions, which you call on a string value asvalue.function(): charAt, indexOf, lastIndexOf, lowerAscii, upperAscii, replace, split, substring, trim, join, format, and reverse, plus the global strings.quote(s).
Expressions in action fields
In an action field, wrap a CEL expression in${{ ... }}. Rule actions lists the fields that accept it and what each field does with a value that has no wrapper. These expressions read the same variables and the same event-start snapshot as the condition.
order_id 1001, 3% is 3.15. Scrip rounds the result to the asset’s scale, so the participant earns 3 points on the scale: 0 PTS asset. The last_order attribute becomes order-1001.
A value can be one expression, or text with one or more expressions in it:
Common patterns
These patterns come up in most programs. Each one is a complete condition you can use directly or adapt.One-time gate
Grant a reward once, then tag the participant to prevent re-triggering.Threshold crossing
Detect the event that pushes a counter past a target. Counters reflect pre-event state, so check the current value plus the incoming amount.Milestone (Nth occurrence)
Fire on exactly the Nth event of a type. The counter hasn’t incremented yet, so add 1 to get the count including this event.Date range
Restrict a rule to events within a specific window.Days since a date
Check elapsed time between two dates withduration_days.
Capped bonus
Reward a percentage of the event amount but cap the maximum payout.Category-specific
Only match events in certain categories.Segment-specific
Use tags to restrict rules to a participant segment.Exclude already-rewarded
Prevent a participant from claiming a promotion more than once.Common gotchas
Rule actions
Use expressions in amounts, values, dates, and targets.
Validate and simulate
Check a condition against sample data before you save it.
Common patterns
Complete rules for milestones, thresholds, and caps.