> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stash.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Loyalty Program

> Overview of the Stash loyalty program: how programs, campaigns, tiers, milestones, and rewards fit together, and how your backend receives loyalty state on webshop webhooks.

The Stash loyalty program rewards players for webshop spend. Players earn Loyalty XP on every purchase, progress through tiers as their XP grows, and claim milestone rewards you configure. Stash is the source of truth for all program state: XP balances, tier status, and claim history. Your backend only grants the rewards Stash tells it to grant, and receives a consistent view of loyalty state on every XP-affecting webhook.

You configure the program in [Stash Studio](https://studio.stash.gg/) under the **Loyalty** section of your shop. It runs on your existing webshop with no additional client integration for accrual.

## The model

A shop has one loyalty program. The program is organized as a hierarchy:

```mermaid theme={null}
graph TD
  P[Loyalty Program<br/>one per shop] --> C[Campaign<br/>the active season generation]
  C --> T[Tiers<br/>progression levels]
  T --> B["Tier earn rates<br/>spend-based rewards: reward per USD spent"]
  B --> RT1[Loyalty XP]
  B --> RT2["Core Currency<br/>(in-game/virtual currency)"]
  T --> M["Milestones<br/>one-time checkpoints, nested under each tier"]
  M --> MR["Milestone rewards<br/>currency, XP, or catalog items"]
```

| Concept | What it is |
| - | - |
| **Program** | The loyalty system on your shop. One per shop, configured in Studio. |
| **Campaign** | A generation of the program, scoped to a season. Every loyalty value your backend receives is stamped with a `campaignId` so you can reconcile XP and tier across season boundaries. See [Refunds & XP adjustments](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/refunds-and-xp.md#campaign-and-season-boundaries). |
| **Reward Type** | A reward players can earn, defined once on the **Reward Types** surface in Studio: Loyalty XP or an in-game currency (Core Currency in Studio). Reward types are applied as per-tier earn rates for spend (reward per USD spent); catalog products can also be granted as milestone rewards. See [Reward types](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/reward-types.md). |
| **Tier** | A named progression level unlocked when the player's XP crosses its threshold. Each tier carries its own spend-based earn rates and contains its own milestones. See [Tiers](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/tiers.md). |
| **Milestone** | A one-time reward checkpoint at a specific XP value, nested under the tier it belongs to. See [Milestones](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/milestones.md). |

## How players earn and claim

Two reward mechanics run in parallel, and the distinction drives the whole integration:

* **Accrual is automatic.** At checkout, Stash updates the player's Loyalty XP and reports the per-USD Core Currency reward on the purchase webhook for your backend to grant. No player action or extra client integration is involved.
* **Milestone claims are player-initiated.** When XP crosses a milestone threshold the reward becomes claimable in the loyalty hub. The player clicks **Claim**, and Stash delivers the reward to your backend to grant.

```mermaid theme={null}
sequenceDiagram
actor Player
participant Hub as Loyalty Hub
participant Stash
participant Backend as Your backend

Player->>Hub: Purchase on webshop
Hub->>Stash: Process payment
Stash->>Stash: Update Loyalty XP balance (earn rate x spend)
Stash->>Backend: PURCHASE_SUCCEEDED webhook (with loyalty state)
Backend->>Player: Grant purchase contents + Core Currency reward
Note over Player,Stash: Player's XP crosses a milestone threshold
Player->>Hub: Claim milestone reward
Hub->>Stash: Claim request
Stash->>Backend: LOYALTY_MILESTONE_CLAIMED webhook
Backend->>Backend: Grant the reward
```

## Loyalty state on webhooks

Every webhook that can change or reflect a player's XP carries a shared `loyalty` sub-payload (the loyalty snapshot, type `PlayerLoyaltyState`): the current XP balance, the signed XP delta, the current and previous tier IDs, the current tier's `pointsMultiplierPermille` (its XP earn rate relative to the base tier, in permille: `2000` = 2x), progress to the next tier and milestone, and the `campaignId`. It rides on four events:

* `PURCHASE_SUCCEEDED`
* `PURCHASE_REFUNDED`
* `LOYALTY_MILESTONE_CLAIMED`
* `FREE_ITEM_REDEEMED`

Refunds are delivered as genuine XP-update events: Stash debits XP proportional to the refunded amount and reports the new balance and tier. See [Analytics & app integration](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/analytics-app-integration.md) for the full contract.

The same loyalty snapshot is also included in the `RegisterPayment` and `ConfirmPayment` purchase requests Stash sends to a real-time-catalog backend, so your backend has the player's tier and XP context in-band at purchase time. See [Loyalty snapshot on purchase requests](https://docs.stash.gg/guides/stash-webshop/catalog/real-time-catalog/endpoints.md#loyalty-snapshot-on-purchase-requests).

## The loyalty hub

Players view their tier status, XP progress, and claimable milestones through the Stash loyalty hub, a hosted UI embedded in your webshop. No additional integration is required for the hub itself.

To deep-link a player directly into the hub, call [Generate authenticated URL](https://docs.stash.gg/api/ingress/server-urls/generateauthenticatedurl.md) from your backend with the target set to `LOYALTY`. The endpoint returns an authenticated URL that opens the player straight to the loyalty hub.

## Next steps

> [card] [Reward types](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/reward-types.md)
>
> Define Loyalty XP, in-game currency, and catalog rewards your program grants.

> [card] [Tiers](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/tiers.md)
>
> XP thresholds, string tier IDs, and per-tier earn rates.

> [card] [Milestones & rewards](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/milestones.md)
>
> One-time XP checkpoints, the claim flow, and reward delivery.

> [card] [Configure in Stash Studio](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/configuration.md)
>
> The end-to-end setup walkthrough, validation, and publishing.

> [card] [Analytics & app integration](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/analytics-app-integration.md)
>
> Consume loyalty via webhooks for analytics, and the read-only API for in-app integration.

> [card] [Refunds & XP adjustments](https://docs.stash.gg/guides/stash-webshop/how-tos/loyalty/refunds-and-xp.md)
>
> Proportional refund reversal, tier downgrades, and free-gift XP.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.