Create a rule that evaluates a CEL condition against incoming events and executes actions when matched.
condition that is evaluated against each incoming event and an actions array that executes when the condition matches. Common actions include crediting balances, incrementing counters, and setting tags.
The order field controls evaluation priority: lower values are evaluated first. If order is omitted, it is auto-assigned to 10 above the current highest order in the program. No two active rules in the same program can share the same order value. When setting order manually, leave gaps between values (e.g. 10, 20, 30) so you can insert new rules between existing ones without reordering. Set stop_after_match to true if you want to prevent lower-priority rules from firing when this rule matches.
active_from and active_to define an optional time window for the rule using RFC 3339 timestamps. Outside the window, the rule is skipped during evaluation. Time windows are checked against the current wall-clock time, not the event’s event_timestamp, so historical imports won’t trigger a rule whose window has already passed. Use these to layer promotional rules on top of permanent base rules.
budgets cap how much a rule can issue per asset over a given period. Each budget specifies an asset_id, a limit, and an optional schedule_type (CRON or INTERVAL) that controls automatic resets. Omitting the schedule type creates a lifetime budget that never resets on its own. When a budget is exhausted, the rule still matches but the credit action is suppressed. You can manually reset a budget via the reset budget endpoint.
A rule is created in ACTIVE status by default.
API key passed in the X-API-Key header.
Rule with CEL condition and actions array
Request body for creating a new rule with CEL condition and actions
Actions to execute when the condition matches (must be non-empty). Each action has a type field that determines which other fields are relevant.
1CEL expression that determines when the rule fires
1"event.type == 'purchase'"
Display name for the rule
1 - 255"Purchase Reward"
Program to attach this rule to
"550e8400-e29b-41d4-a716-446655440000"
Start of the rule's active window (RFC 3339). Null means immediately active.
"2024-01-01T00:00:00Z"
End of the rule's active window (RFC 3339). Null means no end date.
"2024-12-31T23:59:59Z"
Optional budget constraints for this rule. Omit or pass null for no budgets.
Human-readable summary of what this rule does
1000"Awards 10 points per dollar spent"
Evaluation sequence (lower = first). Auto-assigned if omitted.
x >= 1100
Initial lifecycle status (ACTIVE or SUSPENDED). Defaults to ACTIVE.
ACTIVE, SUSPENDED "ACTIVE"
When true, no subsequent rules evaluate after this one matches
false
Rule created
Actions to execute when the condition matches
[
{
"amount": "event.amount * 10",
"asset_id": "550e8400-e29b-41d4-a716-446655440002",
"type": "CREDIT"
}
]Start of the rule's active window (RFC 3339, null if always active)
"2024-01-01T00:00:00Z"
End of the rule's active window (RFC 3339, null if no end date)
"2024-12-31T23:59:59Z"
Budget constraints applied to this rule
CEL expression that determines when the rule fires
"event.type == 'purchase' && event.amount > 0"
When this rule was created (RFC 3339)
"2024-01-15T10:30:00Z"
When this rule was archived (null if not archived)
Human-readable summary of what this rule does
"Awards 10 points per dollar spent"
Unique identifier for this rule
"550e8400-e29b-41d4-a716-446655440000"
Display name
"Purchase Reward"
Evaluation sequence (lower = first, must be unique per program)
100
Program this rule belongs to
"550e8400-e29b-41d4-a716-446655440001"
Lifecycle status: ACTIVE, SUSPENDED, or ARCHIVED
"ACTIVE"
When true, no subsequent rules evaluate after this one matches
false
When this rule was last modified (RFC 3339)
"2024-01-15T10:30:00Z"