Skip to main content
Actions define what happens when a rule’s condition matches. Each rule has one or more actions, and they apply together. If one action fails, the event fails and none of its changes are kept. See Failure is all-or-nothing.

Action types

Dynamic action fields

Wrap CEL expressions in ${{ ... }} to compute values dynamically from the event or participant state. You can also combine literal text and expressions, such as "auth-${{ event.authorization_id }}".
Every action expression reads the same variables and event-start snapshot as the rule condition. See Expressions in action fields for details.

Asset actions

CREDIT

Add funds to an account.
A duration is a number and a unit, such as 90d, and you can combine units, as in 36h30m. Use w for weeks, d for days, h for hours, m for minutes, and s for seconds. m always means minutes. Months and years are not supported, so write 90d for about three months. See Durations. For UNLIMITED assets, CREDIT creates new funds. For PREFUNDED assets, CREDIT draws from the program wallet.
Automatic rounding: If the evaluated amount has more decimal places than the asset’s scale, the value is rounded automatically. For example, ${{ event.amount * 0.03 }} might produce 1.009, which rounds to "1.01" on a scale: 2 asset. No error is returned, so you rarely need round() in an amount. A round() result of exactly 0 fails the event; see Numbers and money.

DEBIT

Remove funds from an account.
Fails with insufficient balance if the available balance is less than the requested amount, unless allow_negative is true. See Balance operations for details and use cases.

HOLD

Reserve funds by moving them from AVAILABLE to HELD.
Held funds are not spendable. Use HOLD to set a participant’s own value aside, for example during a review. For a card authorization, credit pending rewards into HELD instead (see Authorization and settlement). When reference_id is provided, the held lots are stamped so a future RELEASE can target them by reference.

RELEASE

Move funds from HELD back to AVAILABLE.

FORFEIT

Remove funds permanently. Scrip debits the participant and records the value as breakage in the SYSTEM_BREAKAGE system account.
Use for point expiration or policy violations. Rule-triggered forfeits are blocked for non-active participants. Use a FORFEIT balance operation for manual cleanup of closed accounts.

VOID_PENDING

Cancel pending rewards, the lots credited directly into the HELD bucket (not moved there from AVAILABLE by a HOLD action). Returns value to the original source account (program wallet for PREFUNDED, SYSTEM_ISSUANCE for UNLIMITED).
Use it when a merchant cancels a transaction before settlement. Lots that a participant already owned and moved to HELD via a HOLD action are excluded, so you cannot accidentally void participant-owned funds. Set amount for a partial refund. It is the rewards to cancel, not the refunded purchase amount. Calculate it as the rewards for the amount authorized before this refund minus the rewards for the amount still authorized. See how to calculate amount for a worked example. Scrip voids the newest pending rewards first and leaves the rest in HELD for settlement. If amount exceeds the rewards left, Scrip voids what is left. See Void pending rewards. bucket and lot_ids are not supported.

State actions

Every rule condition and action expression in an event reads participant, group, and program state as it was when processing started. A change a rule makes shows in the next event, not in later rules or actions of the same event. See State snapshot evaluation.

TAG

Add a boolean flag to an entity.

UNTAG

Remove a boolean flag from an entity.
Removing a tag that does not exist makes no change and succeeds without error.

COUNTER

Add to a numeric value, or replace it.
See Auto-resetting counters for reset_after and Calendar counters for reset_period, which uses the event’s event_timestamp to choose the period. A counter with a window takes neither field.

SET_ATTRIBUTE

Set a key-value pair on an entity.
Use a plain string for literals ("high") and ${{ ... }} for dynamic values ("${{ event.category }}").

SET_TIER

Assign a tier level on an entity. Each tier represents a separate track (e.g., "status", "loyalty"), and level specifies a position within that track. Tier levels have a numeric rank that defines their order in the hierarchy.
tier and level are the keys of a tier and level you have already created; see Tiers. Saving the rule does not check that this tier and level exist, though a tier key read in a CEL expression is checked. If the tier or level does not exist when the rule runs, the action fails and the event fails with it. A SET_TIER for an archived tier assigns nothing, and the event completes. If the participant already holds a tier in the same track, SET_TIER overwrites it. The previous tier is recorded as a transition for audit purposes. This rule promotes a participant to gold when their lifetime spend crosses $1,000:
Tier state is available in CEL via participant.tiers. Each entry is a map with level (string), rank (number), benefits (map), acquired (timestamp string or null), and expires (timestamp string or null).
get() with a default object keeps the expression safe on an event with no participant. See Helper functions. If expires_in or expires_at is set, Scrip schedules a tier_expiration event for that time. That event applies the tier’s downgrade policy, or removes the level on a tier with no retention mode. See Tiers.

Scheduling actions

These actions create automations: stored event submissions that Scrip fires on a trigger. SCHEDULE_EVENT creates a one-time automation that sends one event after a delay, and BROADCAST creates a one-time automation that sends an event to every active participant after the triggering event completes. Both take a required event_type, the name of the event they send, and an optional event_data object that works like the event_data of POST /v1/events: it is submitted verbatim when the automation fires. Receiving rules match the name as event.type. event_data must not contain a type key.

SCHEDULE_EVENT

Create a follow-up event that fires after a delay. By default the follow-up event goes to the same participant. Set target to send it to a different participant or to the program. Scrip stores the pending event as a ONE_TIME automation with source: RULE_ACTION. This rule grants a signup bonus and schedules an inactivity check 30 days later:
When the follow-up event fires, it enters the rules engine like any other event. A separate rule handles it:
An event schedules each follow-up once. A failed event schedules nothing, so retrying it does not create a second follow-up. Two SCHEDULE_EVENT actions with different targets each schedule their own follow-up. With target, Scrip looks up the recipient when the rule runs, and the recipient must be enrolled in the program. When the follow-up event fires, your rules see it as the recipient’s event: participant holds the recipient’s counters, tags, and tiers, not those of the participant who triggered it. With {"type": "PROGRAM"}, the follow-up event has no participant. These two rules pay a referrer at most five times, as long as no other rule or request changes the referrer’s referral_payouts counter. The first sends a referral_payout event to the referrer named in the buyer’s referred_by attribute. The second runs on that event, so it can check the referrer’s own payout count. Scrip processes one participant’s events one at a time, so two payout events cannot both see the same count:

BROADCAST

Send an event to every active participant in the program. Scrip stores the broadcast as a one-time automation with source: RULE_ACTION, and starts sending the events after the triggering event completes.
BROADCAST cannot include target, asset_id, amount, or other action-specific fields. The broadcast event itself triggers rules, and those rules define what happens. This pair of rules runs a conditional monthly bonus. The first rule fires the broadcast; the second rule runs for each participant who qualifies:
For more control over which participants receive the event (participant filtering, scheduling, guard conditions), create automations directly via the API. See Automations.

Event data templates

String values in event_data may embed ${{ }} templates at any nesting depth, for both actions. Templates resolve when the triggering rule fires, against the triggering event’s context. A whole-string template keeps the expression’s type (numbers arrive as JSON numbers); mixed text and template stringifies the result. Templates in object keys stay as written. A template that errors at runtime fails the whole event, the same as a bad amount expression. A whole-string template that evaluates to CEL null becomes JSON null; in mixed text, null contributes an empty string. Numeric results must be finite and within the precision-safe range (magnitude at or below 2^53). Results outside that range, NaN, and non-JSON-encodable values fail the action with an error naming the event_data field path.
Here projected_points arrives in the follow-up event as a JSON number, and label as a concatenated string. For BROADCAST, templates resolve once, against the triggering event’s context, not per recipient: every participant receives the same resolved event_data.
BROADCAST and SCHEDULE_EVENT actions do not run in test mode, but single-rule simulations and rule configuration simulations still show what they would do. The action result includes the event_data that would be sent, or the field whose template failed. For SCHEDULE_EVENT it also shows who would receive the event: resolved_target in a single-rule simulation, or target on the skipped_action_details entry in a rule configuration simulation.

Targeting

By default, actions apply to the event’s participant. Use target to apply an action to a different participant, a group, or the program. These action types support target: CREDIT, DEBIT, TAG, UNTAG, COUNTER, SET_ATTRIBUTE, SET_TIER, and SCHEDULE_EVENT. SCHEDULE_EVENT can target a participant or the program, but not a group. See SCHEDULE_EVENT for how the follow-up event is delivered.

Static targets

Target the program itself or a specific group by ID:
A group id is a fixed UUID, not an expression. The participant who triggers the event must be an active member of that group, or the action fails. To credit whichever group a participant belongs to, write one rule per group and check membership in the condition:
When you have many groups, credit them from your backend with an ADJUST balance operation on POST /v1/groups/{group_id}/balances/operations instead.

Dynamic targets

A dynamic target finds the participant with an expression, so the recipient can change from event to event. The expression can read the same variables as the rule condition: event, participant, program, groups, recipient, and now. Use external_id to find a participant by your app’s user ID, or participant_id to find them by their Scrip ID. Reference a field from event data (most common):
Use a fixed participant (CEL string literal, note the inner quotes):
Look up by Scrip UUID instead of external ID:
Read the target from the participant’s own data, such as a referrer ID saved as an attribute when they signed up:
If the expression returns null or an empty string, the action fails and the whole event fails with it. When the attribute might be missing, check for it in the condition, for example event.type == 'first_purchase' && participant.attribute.referred_by != null. A target reads the participant’s data as it was when processing started. If an earlier action in the same event sets referred_by, the target still sees the old value. See State snapshot evaluation. Set only one of external_id, participant_id, or id per target. The participant must exist and be enrolled in the program. When you save a rule, Scrip checks target expressions the same way it checks conditions, so a misspelled participant field or an unknown asset symbol is rejected. When you simulate a rule, each targeted action shows who it would reach in resolved_target, for example {"external_id": "user_123"}. groups is not available in simulation, so a target that reads groups shows an error there instead.

Example: referral bonus

Credit both the new user and their referrer from a single event:

Lot expiration and vesting

For LOT-mode assets, CREDIT actions can set expiration and vesting dates:
Use expires_in and matures_in for durations, and expires_at and matures_at for RFC 3339 timestamps. A field named *_at also accepts a ${{ }} expression that resolves to a timestamp, and a field named *_in accepts one that resolves to a duration. Send one field of each pair. A duration counts from the time Scrip processes the event. For occurrence-based or exact calendar deadlines, compute an RFC 3339 timestamp in your backend and resolve it from event_data. On a SIMPLE-mode asset, saving a rule that sets any of these fields returns 400 validation_error, with param naming the field. See Save-time validation. See Lots and expiration for details on lot lifecycle.

Participant status restrictions

A SUSPENDED or CLOSED participant cannot earn or spend. Their events are accepted and their rules run. A balance, counter, or tier action fails the event with participant_inactive when the event’s participant, or the participant the action changes, is inactive. The failed event keeps none of its changes, tags included. See Inactive participants and events.

Writing rules

Rule structure, budgets, time windows, and state snapshot evaluation.

CEL expressions

Write dynamic ${{ ... }} expressions for amounts, counters, and targets.

Common patterns

Copy-paste rule recipes for multipliers, bonuses, streaks, and tiers.