Feature · Customer lifecycle
Virtual currencies
Consumables done right. Define a currency (gems,credits, tokens), grant or spend by any integer delta, audit the full history via an immutable ledger.
Data model
| Table | Shape |
|---|---|
| consumable_currencies | One row per (app, code). Name, emoji, description. |
| consumable_balances | One row per (app, user, currency). Never negative. |
| consumable_ledger | Append-only log: delta, balance_after, reason, source, ts. |
REST endpoints
GET/POST /v1/admin/consumables/currenciesPATCH/DELETE /v1/admin/consumables/currencies/:id— delete refuses if any user has a non-zero balance.POST /v1/admin/consumables/transactions— grant or spend (signed int delta, 0 rejected). Insufficient balance returns 400.GET /v1/admin/consumables/balances?app_id=¤cy_code=&user_id=GET /v1/admin/consumables/ledger?app_id=&user_id=