# v3.0

We have added new events to the webhook to bring you a deep understanding of your customers behavior and help you trigger powerful automations.

We have separated transactional and marketing events to make access control management as simple as a switch button. Additionally over 20 events are now available to you to track and understand you subscribers lifecycle. We also changed the attributes attached to the events to ease integration and give you more context and understanding of your subscription system.

## 1. Migrate transactional events

Transactional events are declaring a subscription start and stop. You shall be using them to store the subscriber state in the database and grant/revoke access to contents or features of your app.

Prior to this version you were using 3 events to control the access:

* `PURCHASE_VALIDATED` used to grant access
* `SUBSCRIPTION_RENEWED` used to grant access (after a pause period) or confirm (renewal)
* `SUBSCRIPTION_EXPIRED` used to revoke access

They are replaced by 2 simple events:

* `ACTIVATE` use to grant access immediately (will be triggered at each renewal)
* `DEACTIVATE` use to revoke access immediately

![](/files/CPdVUxBfBh7kNXcr2JWt)

`PURCHASE_VALIDATED` *and* `SUBSCRIPTION_EXPIRED` will no longer be triggered. `SUBSCRIPTION_RENEWED` **must** only be used for marketing purposes.

If you want to keep track of the start and end of a subscription (e.g. for your analytics or CRM) you can use `SUBSCRIPTION_STARTED` *and* `SUBSCRIPTION_TERMINATED`. Once again, you must not use them to handle access control as there might be other subscription terminated events such as `SUBSCRIPTION_REFUNDED_REVOKED`.

Learn more and find the full list of events [here](https://docs.purchasely.com/subscription-events).

## 2. Attributes

Event attributes give you deep context about the subscription such as plan, product, store, country, currency...

Prior to this version we provided a structure with nested attributes like:

```
{
  "name": "PURCHASE_VALIDATED",
  "user": {
    "vendor_id": "<user id you provided through the sdk>"
  },
  "properties": {
    "app": {
      "platform": "ANDROID",
      "package_id": "<app bundle id defined in the store console>"
    },
    "store": "GOOGLE_PLAY_STORE",
    "product": {
      "plan": {
        "type": "RENEWING_SUBSCRIPTION",
        "vendor_id": "<plan vendorID defined in the Purchasely console>",
        "store_product_id": "<store product id defined in the store console>"
      },
      "vendor_id": "<product vendorID define in the Purchasely console>"
    },
    "expires_at": "2021-05-21T12:58:55.097Z",
    "period_type": "NORMAL",
    "purchase_id": "subs_XFJFJEBFFU757FUJH",
    "purchased_at": "2021-05-21T12:51:59.066Z",
    "original_transaction_id": "GPA.100000099999999"
  },
  "api_version": 2,
  "received_at": "2021-05-21T12:52:03.968Z"
}
```

This structure has been flattened to ease integration and match what we sent to third parties tools (Braze, Amplitude...).

```
{
  "api_version": 3,
  "content_id": "<content id you provided through the sdk>",
  "environment": "SANDBOX",
  "event_created_at": "2021-11-22T09:23:38.559Z",
  "event_created_at_ms": 1637573018559,
  "event_name": "ACTIVATE",
  "is_family_shared": false,
  "offer_type": "NONE",
  "original_purchased_at": "2021-11-22T09:23:36.000Z",
  "original_purchased_at_ms": 1637573016000,
  "plan": "<plan vendorID defined in the Purchasely console>",
  "product": "<product vendorID define in the Purchasely console>",
  "purchased_at": "2021-11-22T09:23:36.000Z",
  "purchased_at_ms": 1637573016000,
  "purchasely_one_time_purchase_id": "otp_XXXXXXXFFFFFFFFF",
  "store": "APPLE_APP_STORE",
  "store_app_bundle_id": "<app bundle id defined in the store console>",
  "store_country": "US",
  "store_original_transaction_id": "100000099999999",
  "store_product_id": "<store product id defined in the store console>",
  "store_transaction_id": "100000099999999",
  "user_id": "<user id you provided through the sdk>"
}
```

Learn more and find the full list of attributes [here](https://docs.purchasely.com/subscription-events/attributes).

If you have any question reach us on our [help center](https://help.purchasely.com/en/) .


---

# 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://purchasely.gitbook.io/purchasely/2.8/faq/migration-guides/webhooks/v3.0.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.
