# Reward mailbox

**URL:** https://heroiclabs.com/docs/hiro/unity/reward-mailbox/
**Summary:** Use Hiro's reward mailbox in Unity to list, claim, and delete the rewards waiting in a player's reward mailbox.
**Keywords:** Unity reward mailbox SDK, RewardMailboxSystem, claim mailbox reward, list mailbox entries, delete mailbox entries, deferred rewards C#
**Categories:** hiro, unity, mailbox

---


# Reward mailbox

The reward mailbox holds rewards for a player to claim later. For how it works, see [Reward Mailbox](../../concepts/mailbox/). For a team's shared mailbox, see [Teams](../teams/).

## Initializing the reward mailbox system

The reward mailbox system relies on the [Nakama System](../getting-started/nakama-system) and an `ILogger`. Pass both to the constructor:

```csharp
var rewardMailboxSystem = new RewardMailboxSystem(logger, nakamaSystem);
systems.Add(rewardMailboxSystem);
```

The Nakama System must be initialized first. Otherwise, initializing the reward mailbox system throws an `InvalidOperationException`.

## Listing mailbox entries

List the rewards in the player's mailbox. Results are paginated: pass the returned `Cursor` to get the next page.

```csharp
var mailbox = await rewardMailboxSystem.ListAsync(100, "");

foreach (var entry in mailbox.Entries)
{
    Debug.Log($"{entry.Id}: can claim {entry.CanClaim}, expires {entry.ExpiryTimeSec}");
}

if (!string.IsNullOrEmpty(mailbox.Cursor))
{
    var nextPage = await rewardMailboxSystem.ListAsync(100, mailbox.Cursor);
}
```

## Claiming a reward

Claim a reward by its entry ID. Set `delete` to `true` to remove the entry from the mailbox after it's claimed:

```csharp
var claimed = await rewardMailboxSystem.ClaimAsync(entryId, true);
Debug.Log($"Claimed {claimed.Id} at {claimed.ClaimTimeSec}");
```

## Deleting mailbox entries

Delete one or more entries without claiming them:

```csharp
await rewardMailboxSystem.DeleteAsync(new[] { entryId });
```

## The mailbox entry object

| Attribute       | Type     | Definition                                                   |
| --------------- | -------- | ------------------------------------------------------------ |
| `Id`            | `string` | Unique identifier for this mailbox entry                     |
| `Reward`        | `Reward` | Reward object containing currencies, items, and other assets |
| `CreateTimeSec` | `long`   | Unix timestamp when this entry was created                   |
| `UpdateTimeSec` | `long`   | Unix timestamp when this entry was last modified             |
| `ExpiryTimeSec` | `long`   | Unix timestamp when this entry expires and becomes invalid   |
| `ClaimTimeSec`  | `long`   | Unix timestamp when this entry was claimed, 0 if unclaimed   |
| `CanClaim`      | `bool`   | Whether this entry's reward can currently be claimed         |
