Rewards

getRewards, hasReward, and claimReward — reading and claiming the current user's reward ledger

The SDK reads the current user's reward ledger — the same records the reward webhook delivers and the dashboard shows. One source of truth, two consumption styles: pull-based reads here, or push via the webhook.

Grant anything valuable — free access, currency, unlocks — from your server via the signed reward webhook. Client-side reads and claims are for display and low-stakes grants: a compromised client can lie to itself. On mobile, keep reward flows framed as product benefit — never cash-for-install, which app review rejects.

getRewards

The current user's full reward ledger, optionally filtered.

ParameterTypeDescription
filter.statusRewardStatusOptional. pending, available, claimed, fulfilled, or expired.
filter.campaignIdstringOptional. Limit to one campaign.
filter.kindstringOptional. Limit to a reward kind, e.g. free_month.

Returns a list of Reward records — { id, kind, status, campaignId, title, payload, createdAt, claimedAt }, with title display-ready.

invitebase.getRewards(filter?: RewardFilter): Promise<Reward[]>
const rewards = await invitebase.getRewards({ status: 'available' });
rewardsList.render(rewards);

hasReward

Render-time availability check for one reward — cheaper and clearer than filtering the full ledger.

ParameterTypeDescription
kindOrIdstringA reward kind (super_referrer_badge) or reward ID (8f3a2b1c-6d94-4e07-9a58-1b7c4d2e9f30).

Returns true if the user has this reward available and unclaimed.

invitebase.hasReward(kindOrId: string): Promise<boolean>
if (await invitebase.hasReward('super_referrer_badge')) {
  profileBadge.show();
}

claimReward

Claims a client-granted reward, exactly once. Claims are recorded server-side and transition the reward available → claimed; a second claim throws, so you can grant from the client without double-granting.

ParameterTypeDescription
rewardIdstringThe reward to claim.

Returns the updated Reward with status: claimed.

invitebase.claimReward(rewardId: string): Promise<Reward>
const reward = await invitebase.claimReward('8f3a2b1c-6d94-4e07-9a58-1b7c4d2e9f30');
unlockFeature(reward.kind);

What's next

On this page