> For the complete documentation index, see [llms.txt](https://docs.sudoplatform.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sudoplatform.com/guides/digital-account-protection/privacy-interaction-entitlements.md).

# Privacy Interaction Entitlements

The Sudo Platform entitlements system is used to control consumption of Sudo Platform resources and the Privacy Interaction service integrates with this system.

Access to the Privacy Interaction service is controlled at the user level and users are either entitled to use the capability or they are not.

{% hint style="info" %}
Read more about the Sudo Platform entitlements system and how to integrate with it in the [Entitlements](https://docs.sudoplatform.com/guides/entitlements.md) section of the Sudo Platform documentation.
{% endhint %}

The following table describes the entitlements used to control access to the Privacy Interaction service:

| Entitlement                                                     | Description                                                                           |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| `sudoplatform.privacy-interaction.serviceUserEntitled`          | Whether or not user is entitled to use the Sudo Platform Privacy Interaction service. |
| `sudoplatform.privacy-interaction.virtualPresenceMaxPerUser`    | The maximum number of active virtual presences per user.                              |
| `sudoplatform.privacy-interaction.gmailDataHolderDiscoveryRate` | The number of gmail virtual presence scans per month that a user may execute.         |

## Retrieving Entitlements Information

To determine whether a user is entitled or whether they have consumed that entitlement, call the `getEntitlementsConsumption` API in the Entitlements SDK. This will return an `EntitlementsConsumption` object that specifies both the user's entitlements level across all entitled Sudo Platform services and how much of each entitlement has been consumed.

## How Entitlements Are Consumed

| Entitlement                                                     | Consumed or checked when                                                                                                                                                                                                                                                                          |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sudoplatform.privacy-interaction.serviceUserEntitled`          | Checked on every operation. A user who is not entitled is rejected.                                                                                                                                                                                                                               |
| `sudoplatform.privacy-interaction.virtualPresenceMaxPerUser`    | One unit is consumed when a new virtual presence is connected. Reconnecting an existing virtual presence does not consume another. The unit is released when the virtual presence is disconnected.                                                                                                |
| `sudoplatform.privacy-interaction.gmailDataHolderDiscoveryRate` | One unit is consumed each time a Gmail discovery scan starts, whether triggered by connecting or by `rescanVirtualPresence`. A scan that resumes after pausing does not consume another unit. The window the allowance applies to is set when the service is deployed (the default is one month). |

**When an entitlement is exhausted**

* Connecting a new virtual presence fails with an insufficient entitlements error.
* If the discovery rate entitlement is exhausted when a scan starts, the scan does not run and its failure is recorded on the virtual presence (`lastScanFailureReason`). No error is thrown to the caller.
* If a user is found to be over their `virtualPresenceMaxPerUser` entitlement when a scan is requested, the service revokes their stored provider credentials and moves their virtual presences to `NEEDS_REAUTH`. The virtual presences themselves are kept.

{% hint style="info" %}
Read more about the `getEntitlementsConsumptionAPI` available in the Entitlements SDK user API [here](https://docs.sudoplatform.com/guides/entitlements/end-user-api/retrieving-entitlements.md#getentitlementsconsumption).
{% endhint %}
