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
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.
Daily cap
Prevent farming with max_per_day. The cap is enforced per user per UTC day.
Once a user reaches the daily cap, further events for that rule grant 0 points until UTC midnight resets the counter.
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.