Skip to main content
POST
Create a rule
Creates a rule in a program (ACTIVE by default, or SUSPENDED). Omit rule_set_id to place it in the program’s default set, and omit position to append it at the end (ACTIVE and SUSPENDED rules are numbered 1..N with no gaps in each set).
  • stop_after_match: When true and the rule’s actions succeed, remaining rules in the same rule set do not run, while later rule sets still evaluate. Skipped runs (such as BUDGET_EXCEEDED) do not stop the set.
  • Time windows: active_from (inclusive) and active_to (exclusive) are evaluated against event_timestamp (now in CEL), recording OUTSIDE_TIME_WINDOW when skipped.
  • Budgets: Optional PROGRAM (shared) or PARTICIPANT (per-recipient) budgets cap how much of an asset the rule can credit. Exceeding a budget skips the entire rule.
For rule authoring, budgets, and ordering patterns, see the Writing rules and Rule sets guides.

Authorizations

Authorization
string
header
default:sk_...
required

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

Headers

Idempotency-Key
string

Unique key (1-255 printable ASCII characters) to make retries safe. Repeating the same request with the same key within 24 hours replays the original response (Idempotent-Replayed: true).

Maximum string length: 255

Body

application/json

Rule with CEL condition and actions array

Request body for creating a new rule with CEL condition and actions

actions
CREDIT action · object · DEBIT action · object · HOLD action · object · RELEASE action · object · RELEASE action · object · FORFEIT action · object · VOID_PENDING action · object · TAG action · object · UNTAG action · object · COUNTER action · object · SET_ATTRIBUTE action · object · SET_TIER action · object · SCHEDULE_EVENT action · object · BROADCAST action · object[]
required

Actions to execute when the condition matches (must be non-empty). Each action has a type field that determines which other fields are relevant.

Minimum array length: 1

Credit an asset to the target. reference_id, expires_at, expires_in, matures_at, and matures_in require a LOT-mode asset (expires_at/expires_in and matures_at/matures_in are each mutually exclusive).

Example:
condition
string
required

CEL expression that determines when the rule fires

Minimum string length: 1
Example:

"event.type == 'purchase'"

name
string
required

The name people see for the rule.

Required string length: 1 - 255
Example:

"Purchase Reward"

program_id
string<uuid>
required

Program to attach this rule to

Example:

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

active_from
string<date-time>

Start of the rule's active window (RFC 3339). Null means immediately active. Checked against the event's event_timestamp, inclusive.

Example:

"2027-01-01T00:00:00Z"

active_to
string<date-time>

End of the rule's active window (RFC 3339). Null means no end date. Checked against the event's event_timestamp, exclusive.

Example:

"2027-12-31T23:59:59Z"

budgets
(Lifetime budget · object | Cron budget · object | Interval budget · object)[]

Optional budget constraints for this rule. Omit or pass null for no budgets.

Never resets. schedule_type, cron_expression, and interval are all rejected.

description
string

Human-readable summary of what this rule does

Maximum string length: 1000
Example:

"Awards 10 points per dollar spent"

position
object

Where to place the rule in its rule set. Omit position to add it at the end.

rule_set_id
string<uuid>

Rule set to attach this rule to. Omit to use the program's default set.

Example:

"d4735e3a-265e-4f16-b1a5-4c8e9d6f0a04"

status
enum<string>

Initial lifecycle status (ACTIVE or SUSPENDED). Defaults to ACTIVE.

Available options:
ACTIVE,
SUSPENDED
Example:

"ACTIVE"

stop_after_match
boolean

When true, no subsequent rules in this set evaluate after this one matches; other sets continue

Example:

false

Response

Rule created

A rule: a condition and the actions Scrip takes when an event matches it.

actions
object[]

Actions to execute when the condition matches

Example:
active_from
string<date-time>

Start of the rule's active window (RFC 3339, null if always active). Checked against the event's event_timestamp, inclusive.

Example:

"2027-01-01T00:00:00Z"

active_to
string<date-time>

End of the rule's active window (RFC 3339, null if no end date). Checked against the event's event_timestamp, exclusive.

Example:

"2027-12-31T23:59:59Z"

budgets
object[]

Budget constraints applied to this rule

condition
string

CEL expression that determines when the rule fires

Example:

"event.type == 'purchase' && event.amount > 0"

created_at
string<date-time>

When this rule was created (RFC 3339)

Example:

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

deleted_at
string<date-time>

When this rule was archived (null if not archived)

Example:

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

description
string

Human-readable summary of what this rule does

Example:

"Awards 10 points per dollar spent"

id
string<uuid>

Unique identifier for this rule

Example:

"c9f0f895-fb98-4b39-9f86-1e5a0d3e2b03"

name
string

The name people see for the rule.

Example:

"Purchase Reward"

order
integer

Evaluation position within the containing rule set (lower = first; ACTIVE and SUSPENDED rules occupy unique positions)

Example:

1

program_id
string<uuid>

Program this rule belongs to

Example:

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

rule_configuration_version
integer

Resulting program rule-configuration revision. Present on mutation responses.

Example:

4

rule_set_id
string<uuid>

Rule set that contains this rule and scopes its order and stop_after_match behavior

Example:

"d4735e3a-265e-4f16-b1a5-4c8e9d6f0a04"

status
enum<string>

The rule's lifecycle state.

Available options:
ACTIVE,
SUSPENDED,
ARCHIVED
Example:

"ACTIVE"

stop_after_match
boolean

When true, no subsequent rules in this set evaluate after this one matches; other sets continue

Example:

false

updated_at
string<date-time>

When this rule was last modified (RFC 3339)

Example:

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

warnings
object[]

Non-blocking advisories about the rule's condition or action expressions, such as unknown state-key typos, deprecated CEL aliases, or an event field that no recent event has. Present on create/update only; never blocks the save.