Skip to main content
An automation stores the event_type and event_data you would send to POST /v1/events and submits them when its trigger fires, either once to the program or individually to each matching participant. The event then enters the rules engine like any other event. Every automation has an event_type, the name of the event it fires. Rules match it as event.type, exactly as they do for events you send. An automation that stores:
fires an event that this rule condition matches:
Events fired by automations are system events (source: SYSTEM). Their event_timestamp is the scheduled trigger time, even if processing starts later. Each firing reuses its idempotency key on retries to prevent duplicate events. Use automations for monthly bonuses, one-time promotions, birthday rewards, or any event that should happen without an API call from your application.

Anatomy

Every automation combines five things: a name, a trigger (when it fires), a scope (who receives the event), and the event_type and event_data it submits.
The API returns 201 Created with the automation. The cron and one-time examples below show the full response. A name that another non-archived automation in the program already uses returns 409 automation_name_already_exists. The trigger object has the same shape in create requests, update requests, and responses: Not every trigger and scope combination is valid:

Trigger types

Cron

A cron automation fires on a recurring schedule.
A cron automation stays ACTIVE across firings. Transient failures do not disable it; it records last_error and fires again on schedule. Only a terminal error, such as a cron expression that can no longer be scheduled, sets status: FAILED (see lifecycle). Updating cron_expression or timezone recomputes next_run_at in the same request.
A scheduled reset and a purchase can run in either order. A purchase near midnight on the 1st may therefore count toward either month, even though the reset’s event_timestamp is the scheduled time. For exact monthly totals, use a calendar counter instead of a scheduled reset. It files each event under the month of its event_timestamp. See Processing order is not guaranteed.

One-time

A one-time automation fires once, at trigger_at or as soon as possible when trigger_at is omitted, then moves to COMPLETED.
Omitting trigger_at means “now”: the automation usually starts within 10 seconds. A one-time program-scoped automation with no trigger_at is the way to push a one-off event to the program without waiting. The BROADCAST rule action creates exactly this shape with PARTICIPANTS scope; see Rule actions. To reschedule a pending one-time automation, PATCH its trigger.trigger_at:
The API returns 200 with the updated automation. Send "trigger_at": null to fire it as soon as possible. For a worked one-time example paired with the rule that consumes its event, see the one-time bonus blast.

Participant state

A participant-state automation fires per participant, when that participant’s own state says it is time. Each qualifying participant gets a subscription with an independent schedule. Participant-state automations always use PARTICIPANTS scope.
The API returns 201 Created with execution_status: IDLE. Subscriptions appear within about five minutes, after Scrip first evaluates the automation; see Subscriptions. The schedule_type determines how each participant’s trigger time is computed. offset, interval, and delay below all take a duration such as 30d or 24h; see Durations for the units.
Trigger types are CRON, ONE_TIME, and PARTICIPANT_STATE. Schedule types are ATTRIBUTE_DATE, INTERVAL, CRON, and THRESHOLD.
ATTRIBUTE_DATE reads a date from a participant attribute and triggers on that date. MM-DD format recurs yearly (birthdays, anniversaries). YYYY-MM-DD fires once on the exact date (trial expirations, contract renewals). If the attribute is missing or unparseable, that participant is skipped.
This triggers 7 days before each participant’s birthday (negative offset). A participant with birthday: "03-15" would trigger on March 8th each year. Dates resolve to midnight in the trigger’s timezone. INTERVAL triggers at a fixed duration relative to each participant’s subscription. The timer is independent per participant: if participant A subscribes on January 1 and participant B subscribes on January 15, a 30-day interval fires January 31 for A and February 14 for B.
CRON is a calendar-aligned schedule shared across participants. Unlike INTERVAL, all subscribed participants fire at the same wall-clock times regardless of when they were subscribed.
THRESHOLD triggers when a participant’s counter crosses a value. The delay defers the event after the condition is met, giving the participant time to take further action before it fires.
This fires 24 hours after a participant’s lifetime_spend counter reaches 1000. If the counter drops below 1000 during the delay, a guard_condition can prevent the event from firing.

Subscriptions

Each qualifying participant gets a subscription: the per-participant record of when their event should fire. A birthday automation with three qualifying participants creates three subscriptions, each with a different next_trigger_at based on that participant’s birthday attribute. Scrip re-evaluates the automation about every five minutes to pick up new participants and drop those who no longer match. A subscription fires once its next_trigger_at passes. When many subscriptions come due at once, some fire several minutes later. Inspect individual subscriptions with the subscriptions listing:
A subscription’s status is one of ACTIVE, FIRING, PAUSED, COMPLETED, FAILED, or CANCELLED, and the listing accepts a status filter with the same values. For a worked participant-state example paired with the rule that consumes its event, see the birthday reward.

Scopes and fan-out

The scope decides who receives the event when the trigger fires. PROGRAM submits a single event to the program. Rules evaluate once, without a participant context, which fits program-level work such as resetting program counters. For ONE_TIME automations you can add participant_id to deliver that single event to one specific participant instead. PARTICIPANTS delivers the firing as an individual event to every matching participant (fan-out). Each participant’s event evaluates rules against that participant’s own state, exactly as if you had sent one event per participant yourself. participant_filter selects who matches; with no filter, every active participant in the program receives the event. Every fan-out event is a system event with the scheduled trigger time as its event_timestamp. Its idempotency key names the automation, the trigger time, and the participant, so a retried firing never sends a participant a second event. While a fan-out runs, the automation reports progress:
With a participant_filter or guard_condition, a finished run can show participants_processed below participants_total. Read execution_status, not the ratio, to know when the run is done.

Filters and guards

participant_filter and guard_condition apply to every PARTICIPANTS-scoped automation (cron, one-time, and participant state). The two optional CEL expressions run at different phases. participant_filter runs during evaluation and controls who is in. A birthday automation only makes sense for participants who have a birthday attribute:
Participants where the expression returns false are skipped. If a participant who qualified earlier no longer matches on re-evaluation, their subscription is cancelled. guard_condition runs at trigger time, right before the event fires. Use it when state may have changed between evaluation and trigger:
If the guard returns false, the event is skipped for that participant. For the recurring schedule types (ATTRIBUTE_DATE, INTERVAL, CRON) the subscription remains active for future firings. For the one-shot THRESHOLD type the subscription is cancelled, and a later re-evaluation re-subscribes the participant only if they still qualify. Both expressions use the same participant vocabulary as rule conditions: the participant.counter/tag/attribute.<name> shorthand, program.counter/tag/attribute.<name> accessors, the groups list, and participant identity fields (participant.id, participant.external_id, participant.status, participant.enrolled_at, participant.created_at). Two differences from rule conditions:
  • now is the wall-clock time when the expression runs, not an event timestamp. There is no event here.
  • event.* references and balance references (participant.balance.<symbol>, participant.balances) are rejected with a 400 when the automation is saved.
A create or update that sets participant_filter or guard_condition can return a warnings array. Warnings never block the save. The common one is unknown_state_key: the expression reads a counter, tag, or attribute that no rule in the program writes, which is often a typo. Each warning names the key and, when a close match exists, a suggestion:
filter_hints narrow the candidate set with indexed lookups before any CEL runs, which matters for large programs. Each hint names a type (HAS_TAG, HAS_ATTRIBUTE, or HAS_COUNTER) and a value (the tag, attribute key, or counter key):
Hints are an optimization, not a second filter: pair them with a participant_filter that states the actual condition.

Lifecycle

An automation carries two status fields that answer different questions. status describes the automation definition: may it fire at all. execution_status, present on PARTICIPANTS-scoped automations, describes the current fan-out run: is one in progress right now. The two fields overlap in vocabulary but not in meaning. status: COMPLETED is forever: the one-time automation has done its job. execution_status: COMPLETED only closes one cycle of a recurring automation. Likewise status: FAILED means the definition is broken and needs your intervention, while execution_status: FAILED means one run went wrong and the next scheduled firing starts fresh. A cron automation keeps status: ACTIVE through transient failures and records last_error; see Cron. By default the list endpoint hides terminal statuses (COMPLETED, FAILED, ARCHIVED); filter by status explicitly to see them. A FAILED automation therefore disappears from the default list even though it is recoverable.

Cancel behavior

Cancelling an executing fan-out sets execution_status to FAILED. Participants already processed keep their events; remaining participants are skipped. The automation stays ACTIVE and fires again on its next schedule. Cancelling a program-scoped one-time before it fires archives the automation. Both return 200 with the automation. An automation with nothing to cancel returns 400 validation_error.

Testing an automation

To test an automation, simulate its event_type and event_data, then run a real copy. Testing walks through both steps. Create the copy with the same event_type and event_data, trigger.type: ONE_TIME with trigger_at omitted, and a participant_filter that selects a test participant:
The API returns 201 Created. The copy starts within seconds, delivers one real event to the test participant, and moves to COMPLETED. Verify the outcome the same way you verify any processed event.

Managing automations

Updates go through PATCH with the same nested trigger object as create. There is no DELETE: archive an automation with {"status": "ARCHIVED"}. The trigger must support the chosen scope. Scrip rejects scheduling fields that do not belong to that trigger type. The list endpoint returns the newest automations first, 50 per page by default and up to 200 with limit. It filters by trigger (the trigger.type), scope, status, source, and search (part of the name). Every automation carries a source: An automation’s source says who created it. It is separate from the source of the events it fires, which is SYSTEM for every automation. The default list returns API and RULE_ACTION rows only. Pass source=SYSTEM to inspect automations Scrip creates, for example when investigating a tier expiration.

Writing rules

Write the rule that matches the automation’s event_type.

Testing

Simulate the event, then run a real copy.

Common patterns

Worked automations paired with the rules they feed.