Event-triggered Currency Grants
Grant currency automatically when a user action fires — no admin keys exposed to the client.
Connect user behavior directly to your economy. When Amba.events.track() fires, the server checks for matching grant rules and credits the user's balance automatically — no admin credentials needed on the client side.
Quickstart
Step 1 — Create the currency (if you haven't already)
Step 2 — Provision a grant rule
Every rule sets exactly one of max_per_day or uncapped: true. See
Daily limits.
Step 3 — Track the event from your app
That's it. No server-side code needed.
Grant modes
Flat grant
Grant a fixed amount on every qualifying event.
Property-scaled grant
Scale the grant by a numeric property on the event. Useful for distance, duration, or score-based rewards.
The result is floor(property_value × multiplier). If the property is absent or non-numeric, the grant is skipped silently.
The app supplies the property value on events it tracks with its client key, so
a property-scaled rule applies to those events only when it sets max_per_day.
A property-scaled rule with uncapped: true applies to events recorded by a
server key, the admin events API, or the subscription cascade.
Daily limits
Every rule sets exactly one of these two. A create request with neither answers
400 DAILY_CAP_REQUIRED; one with both answers 400 INVALID_GRANT.
max_per_day
Caps the total the rule grants one user per UTC day. Use it for any event the app tracks itself, since an end user can repeat those.
Once a user reaches the daily cap, further events for that rule grant 0 points until UTC midnight resets the counter.
uncapped: true
Grants with no daily limit. A fixed-amount rule with uncapped: true grants on
every matching event, including events an end user can send from the app as
often as they like, so reserve it for events your server records or events that
can't repeat. A property-scaled rule with uncapped: true grants only on events
recorded by a server key, the admin events API, or the subscription cascade.
Rules created before daily limits were required
A fixed-amount rule created before this requirement, with no max_per_day,
grants on events recorded by a server key, the admin events API, or the
subscription cascade. Events the app tracks with its client key grant nothing
from it. To restore its reach, delete it and create it again with max_per_day
or uncapped: true.
Multiple rules
Multiple rules can target the same event. All matching enabled rules fire independently — their grants are summed.
Managing rules
List rules
Disable a rule (without deleting it)
Rules don't have an update endpoint yet — delete and re-create to change parameters. To pause a rule quickly, delete it; existing ledger history is preserved.
Delete a rule
Deleting a rule stops it from firing on future events. Historical grants in the transaction ledger are not affected.
Read the balance
After events fire, read the updated balance with the currencies SDK:
How it works
Amba.events.track(name, properties)sends the event to the API.- The API writes the event to the database, then checks for enabled grant rules matching the event name.
- For each matching rule, the server runs a serialized transaction:
- Reads the user's current balance with a row-level lock (prevents concurrent grant races).
- Applies the daily cap if configured.
- Credits the balance and writes an audit entry.
- The
getBalances()call reflects the new balance immediately.
Grants are applied server-side — client code never touches admin credentials.
See Virtual Currencies for details on currency definitions, balance caps, and auto-recharge.