XP and Levels
Auto-award XP based on engagement events with configurable rules, daily caps, and cooldowns.
XP (experience points) automatically accrue when users track events. Define rules that map events to XP amounts, and Amba handles the rest.
How it works
- Admin creates XP rules that map event names to XP amounts
- When a user tracks a matching event, XP is awarded automatically
- XP accumulates in the user's XP balance with total, level, and period tracking
- Every XP award is logged for a full audit trail
SDK usage
Get current XP
Use xp_this_period to drive weekly/monthly leaderboards or "earn 500 XP this week" challenges — the window is defined by the project's XP rules and rolls over server-side, so the client just reads the current value.
Get XP history
Admin API reference
| Method | Path | Description |
|---|---|---|
POST | /admin/xp | Create XP rule |
GET | /admin/xp | List XP rules |
Client API reference
| Method | Path | Description |
|---|---|---|
GET | /client/xp | Get user's XP, level, and period XP |
GET | /client/xp/history | Get XP ledger entries (paginated) |
GET | /client/xp/rules | Get active XP rules |
MCP tools
| Tool | Description |
|---|---|
amba_xp_rules_create | Create an XP rule with event trigger, amount, daily cap, and cooldown |
amba_xp_rules_list | List all XP rules for a project |
amba_users_get_xp | Get a specific user's XP and level |
Example: Set up XP rules
Rule options
| Field | Type | Description |
|---|---|---|
name | string | Display name for the rule |
event_name | string | Event that triggers the XP award |
xp_amount | number | XP to award per trigger |
max_per_day | number | Max triggers per user per day (null = unlimited) |
cooldown_seconds | number | Min seconds between awards for same user (default 0) |