Entitlements
How Amba tracks user subscription state from RevenueCat and Superwall, and how to check it from your app.
An entitlement is Amba's abstraction for "does this user have access to a feature". For the utility apps Amba targets, entitlements mostly come from RevenueCat (the subscription truth) with paywall metadata from Superwall — both sync into Amba via verified webhooks, and both end up in the same user_entitlements table.
Data model
user_entitlements:
| Column | Purpose |
|---|---|
app_user_id | The user who owns the entitlement |
entitlement_id | Logical identifier (e.g. "premium") |
product_id | Store product identifier |
is_active | Whether the entitlement is currently valid |
store | "app_store" / "play_store" / "stripe" / ... |
period_type | "trial" / "intro" / "normal" / ... |
purchase_date | First purchase timestamp |
expiration_date | When the current period ends (NULL for lifetime) |
The columns are whitelisted for segment targeting — see Segment operators.
Sync from RevenueCat
When RevenueCat fires a subscription event, the webhook route verifies the bearer token and Amba upserts the user_entitlements row in the background. Event mapping:
| RevenueCat event | Effect |
|---|---|
INITIAL_PURCHASE | Upsert active entitlement row |
RENEWAL | Extend expiration_date |
CANCELLATION | Mark for expiry at period end |
EXPIRATION | is_active = false |
BILLING_ISSUE | Flag on the entitlement for UI to surface |
Sync is push-only (RevenueCat → Amba). Amba is not the source of truth for purchases; RevenueCat is.
Sync from Superwall
Superwall webhooks primarily carry paywall events (shown, dismissed, purchased). Amba mirrors these as engagement_events rows named superwall_<event> so streaks, XP rules, and segments can target paywall behavior alongside first-party events. Full subscription state still flows through RevenueCat.
Checking entitlements in the SDK
Both methods hit GET /client/entitlements:
UserEntitlement shape:
Example: gate a premium feature
Targeting by entitlement
Entitlement fields can drive segment rules, which in turn drive push campaigns and remote-config overrides:
See Segment operators for the full list of supported entitlement fields.
Local caching
The SDK does not cache entitlements client-side beyond the fetch lifetime. For performance-sensitive gates, fetch once on launch (after Amba.init() resolves) and keep the result in React state / a context.
Do not persist entitlement state to local storage and trust it later — subscription state can change server-side (cancellations, billing issues). Always confirm against the server before granting access to paid content.
Routes reference
| Method | Path | Description |
|---|---|---|
GET | /client/entitlements | List the current user's entitlements (active) |
POST | /webhooks/revenuecat | Inbound subscription events (see Webhooks) |
POST | /webhooks/superwall | Inbound paywall events |
Next
- RevenueCat setup — webhook and API key wiring.
- Superwall setup — paywall event sync.
- Webhooks — signature verification and retry contract.