# Work with Entitlements In-Game

## Get Single Entitlement

When getting a single entitlement, you can use the Status field to check where the purchase is in it's current stage.

1. canceled means that the purchase was canceled either by the player or an issue was encountered.
2. pending means that the purchase is currently still being processed, at this time it would be smart to invoke the method again to check for updates. It would also be a good idea to limit number or rate of attempts to avoid spamming the function.
3. active means that the purcahse has completed.

{% tabs %}
{% tab title="Unity" %}

```csharp
string entitlementID = "";
LootLockerSDKManager.GetSingleEntitlementHistory(entitlementID, (response)=>
{
    if(!reponse.success)
    {
        Debug.Log(response.errorData.ToString());
        return;
    }

    if(response.Status == LootLockerEntitlementHistoryListingStatus.canceled)
    {
        //canceled or issue encountered.
        Debug.Log(response.errorData.ToString());
        return;
    }

    if(response.Status == LootLockerEntitlementHistoryListingStatus.pending)
    {
        //retry the process
    }

    if(response.Status == LootLockerSDKManager.GetSingleEntitlementHistory.active)
    {
        //Purchase successful, handle the expected outcome.
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

{% endtab %}

{% tab title="REST" %}

```bash
curl --location --request GET 'https://api.lootlocker.io/game/entitlements/{entitlement_id}' \
--header 'x-session-token: {{session_token}}' \
--header 'Content-Type: application/json' \
```

{% endtab %}
{% endtabs %}

## List Entitlements

Each entitlement in the response has multiple entries of information, such as Type, Store, and the Rewards and Items which were given to the player.

{% tabs %}
{% tab title="Unity" %}

```csharp
int count = 10;
string after = "";
LootLockerSDKManager.ListEntitlements(count,after,(response) => {
    if (!response.success) {
        Debug.Log("Could not get entitlements");
        return;
    }
    //Handle entitlement list
});
```

{% endtab %}

{% tab title="Unreal" %}

{% endtab %}

{% tab title="REST" %}

```bash
curl --location --request GET 'https://api.lootlocker.io/game/entitlements/' \
--header 'x-session-token: {{session_token}}' \
--header 'Content-Type: application/json' \
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lootlocker.com/commerce/entitlements/how-to/work-with-entitlements.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
