Skip to main content
Build a cashback credit card program with two named rule sets alongside the program’s automatic default set. Tracking rules update monthly calendar counters and award the retroactive threshold bonus, while earning rules choose one cashback rate.

What you’ll build

The end result is 3 rule-set resources (the automatic default set plus 2 named sets) and 7 rules.

Assumptions

This guide assumes you already have:
  • A program created
  • An asset linked to that program (CASHBACK, scale 2, UNLIMITED, SIMPLE)
See the quickstart if you need help with setup.

Create the rule sets

Every program already has a default rule set in the first position. This example leaves it empty and creates two named sets because tracking and earning have separate responsibilities: Send one request per set:
Each request returns 201 Created with the set. The response to the first request:
The rule requests below use each set’s returned id: d4735e3a-265e-4f16-b1a5-4c8e9d6f0a05 for tracking and d4735e3a-265e-4f16-b1a5-4c8e9d6f0a06 for earning. Because they are created in that order, tracking runs first and earning runs second.

Tracking set

Each rule request below assigns its rule via rule_set_id to one of the two named sets. Create the rules in the order shown; Scrip numbers them within each set as they are added, so creation order is execution order. stop_after_match on any rule is scoped to that rule’s containing set.

1. Track monthly spend

Every rule in this program needs to know how much the participant has spent this month. We track two calendar counters: total spend (for the threshold check) and non-category spend (for the retroactive bonus). Setting "reset_period": {"type": "MONTH"} keeps one total per UTC calendar month (add "timezone": "America/Chicago" for a local calendar), filing each purchase by its event_timestamp so every new month starts at 0 with no midnight reset race:

2. Track non-category spend

monthly_base_spend tracks only non-category purchases. This is what the retroactive bonus pays out on. A purchase’s category comes from its merchant category code (MCC), the four-digit code a card network assigns to each kind of business, which your backend sends as event.mcc.
Counter values in conditions come from the event-start snapshot: they reflect the state before the current event’s actions execute. These rules increment the counters in the database, but later rules in the tracking set and every later set still see the pre-event values. This matters for threshold detection.

3. Retroactive bonus at $2,500

When a participant crosses the $2,500 monthly threshold, they should retroactively earn an extra 2% on their non-category spend so far. This makes up the difference between the 1% they already earned and the 3% high-spender rate.
Two checks in the condition make it fire at most once per month:
  • snapshot < 2500: hasn’t crossed yet
  • (snapshot + event.amount) >= 2500: this event crosses it
The last check, monthly_base_spend > 0.0, skips the bonus when there is no non-category spend to pay on. An amount of 0 would fail the whole purchase event. The credit amount uses monthly_base_spend (not monthly_spend) so the retroactive bonus only applies to purchases that earned the 1% base rate. Dining and grocery purchases already earned their full 5%/3%. Paying an extra 2% on those would overshoot.
Do not use stop_after_match here. It would skip later rules in the tracking set. The earning set would still run, but future tracking rules in this set would not.

Earning set

The earning rules are mutually exclusive. A matching category or high-spender rule stops only the rest of this set; tracking remains independent.

4. Dining: 5%

MCCs: 5812 (restaurants), 5813 (bars), 5814 (fast food). stop_after_match: true ensures a dining purchase earns 5% and only 5%. It skips the later grocery, high-spender, and base rules in the earning set. It does not stop another set.

5. Groceries: 3%

MCCs: 5411 (grocery stores), 5422 (freezer/meat lockers). The same set-local stop prevents the high-spender and base rules from also firing.

6. High-spender: 3% on everything else

After crossing the $2,500 monthly threshold, all remaining non-category purchases earn 3% instead of 1%.
This uses (snapshot + event.amount) >= 2500 so the threshold-crossing purchase itself earns at the higher rate.

7. Base: 1% on everything else

The catch-all for purchases below the threshold that don’t match a category.
Only fires when no earlier rule in the earning set matched: the dining, grocery, and high-spender rules all use stop_after_match.
Because monthly_spend and monthly_base_spend use "reset_period": {"type": "MONTH"}, you do not need a monthly CRON automation or reset rule. Each purchase reads and updates the bucket for the calendar month of its event_timestamp (a late-arriving March 31 purchase processed on April 1 still counts toward March). See Calendar counters and Processing order is not guaranteed.

Rule evaluation flow

Here is the effective execution sequence for a purchase. The empty default set contributes no rule evaluations in this walkthrough:
The named sets run after the empty default set. If default contained an applicable ACTIVE rule, that rule would participate first, before any named set. The tracking set then evaluates before the earning set. Its counter writes persist first, but earning conditions and dynamic action expressions still read the shared event-start snapshot. The earning rules are mutually exclusive through set-local stop_after_match.

Example event

Your backend sends a purchase event when a card transaction settles:
Only type, amount, and mcc are used by rule conditions. Include whatever else you need for your own analytics. The API returns 202 Accepted with the event’s id. Rules run after that. Once the event’s status is COMPLETED (see Wait for the result), read it:
For a new participant’s first purchase, rule_evaluations lists two rules. track_monthly_spend adds 85 to monthly_spend, and dining_cashback credits 4.25 and stops the earning set. No other rule matches, so no other rule is listed:
The cashback lands in the participant’s CASHBACK balance:

Edge cases and watchouts

Rounding

Scrip automatically rounds computed rule amounts half-up to the asset’s scale, so you do not need to call round() in your amount formulas. This walkthrough uses scale: 2 (dollars) to keep the numbers readable; to avoid binary floating-point rounding on fractional cents, track cashback in integer cents (scale: 0) as shown in Money amounts end to end.

The threshold-crossing purchase

The event that pushes monthly_spend past $2,500 earns at the 3% rate (high-spender), not 1%. This is because high_spender_cashback checks (snapshot + event.amount) >= 2500, which is true for the crossing purchase. The retroactive bonus also fires on the same event, covering all prior spend.

Category purchases don’t care about the threshold

A dining purchase always earns 5% whether the participant has spent $500 or $5,000 this month. The stop_after_match on dining_cashback (the first rule in the earning set) fires before the high-spender and base rules in that set are evaluated. The threshold only affects non-category purchases.

The second counter

monthly_base_spend exists so the retroactive bonus only pays out on purchases that earned 1%. Without it, a participant who spent $2,000 on dining before crossing the threshold would get an extra 2% on those dining purchases, bumping them from 5% to 7%, which isn’t intended. The retroactive bonus should only upgrade 1% purchases to 3%.

Counter resets and tier status

Each new calendar month automatically starts with fresh 0 totals for monthly_spend and monthly_base_spend. There is no “tier” to maintain: the high-spender rate is purely counter-driven, so a participant who spent $10,000 last month starts fresh at 1% the next month.

Refund handling

The seven rules above do not handle refunds. Refunds and clawbacks compares the ways to take cashback back. Two points apply to this card:
  • The reversal endpoint needs a LOT-mode asset. With the SIMPLE asset this walkthrough assumes, it returns 422 nothing_reversible, so send a refund event that a DEBIT rule handles instead. Create the asset as LOT if you want to use reversal, because inventory mode cannot change later.
  • A refund should also reduce monthly_spend, so the threshold stays accurate. Neither a reversal nor a DEBIT changes counters, so the refund rule needs its own COUNTER action with the same reset_period.
A refund rule that does both (placed in the tracking set or a dedicated refunds set):
Your backend would include original_cashback and original_amount from the original transaction record. allow_negative lets the debit succeed even if the participant has already spent the cashback; without it, a DEBIT against an insufficient available balance fails and the refund event is marked FAILED. To keep the balance at or above zero instead, see Claw back without a negative balance.

Excluded transaction types

The base rule doesn’t exclude any MCCs. In practice, you’d want to block non-qualifying transactions: cash advances and ATM withdrawals (6010, 6011, 6012), quasi-cash such as money orders (6051), wire transfers (4829), and gambling (7995):

Large MCC lists

The CEL in operator works well for short lists (5-20 entries). If you need to match against hundreds of merchants or categories, move the classification into your backend and pass a flag like event.is_dining: true in the event payload instead.

Next steps

Rule sets

Control which set runs first and what stop_after_match stops.

Refunds and clawbacks

Take back cashback when a purchase is refunded.

Email referral program

Track invites, signups, and qualifying purchases across two participants.