# Managing entitlements

## Determining which user is concerned by the ***Event***

When receiving an event on the Webhook, you can parse the attributes `user_id` or `anonymous_user_id` to determine which user is concerned by the **Event**.

The attribute `user_id` will only be populated if a user identifier was set within the app, using the `setUserId` method of Purchasely SDK.

If the user is not signed-in inside the application, you can rely on the property `anonymous_id` which will be automatically populated by the Purchasely Cloud Platform.

## Determining if new entitlements should be set or removed

The **Event** name carries the information about the event signification.

* If the name is `ACTIVATE`, this means that a new purchase has been made or the subscription has renewed. The corresponding user shall be entitled.<br>
* If the name is `DEACTIVATE`, this means that the user subscription has expired. Entitlements shall thus be removed immediately.<br>

Entitlements can be seen as an on/off switch.

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMlt1wKorebNvASzHZKUN%2Fuploads%2FlKSnjnLa6Ia4yWK6hNTK%2FFrame%204.png?alt=media\&token=74549730-98bc-4c61-a03f-8ff0377c4b61)

## Determining which entitlements shall be granted to the user

The **Event** is also carrying the information related to the **Product** and **Plan** purchased by the user. These object are carrying an identifier that you can set yourself in the Purchasely Console (called `vendor_id` see [Configuring Products & Plans](https://purchasely.gitbook.io/purchasely/2.8/quick-start/console-configuration/create-your-products/products-and-plans)).

Sample payload for a user that has purchased the `PURCHASELY_PLUS_MONTHLY` **Plan** attached to the `PURCHASELY_PLUS` **Product**.

```
{
  "event_name": "ACTIVATE",
  "user_id": "<user id you provided through the sdk>",
  "plan": "PURCHASELY_PLUS_MONTHLY",
  "product": "PUCHASELY_PLUS",
}
```
