Question

How to check active entitlements using API

  • 23 April 2024
  • 2 replies
  • 13 views

Badge +1

Is there any way using the v1 (or v2) API to check more directly whether an entitlement is active? 

 

The SDK has something like

 

if !customerInfo!.entitlements.active.isEmpty 
 

but it seems like the API just returns something like:

 

      "entitlements" : {          "premium" : {             "expires_date" : "2024-04-23T14:43:37Z",             "grace_period_expires_date" : null,             "product_identifier" : "monthly",             "purchase_date" : "2024-04-23T14:38:37Z"          }

 

when hitting the GET /subscriber endpoint. 

This means I have to check the expires_date against Date.now() or something like that which feels clunky rather than having the attribute calculated directly on the API.

 

 


2 replies

Userlevel 4
Badge +8

Hi, at this time our recommended way is to use our GET subscriber endpoint and to check the entitlement object. We do have in our APIv2 beta an endpoint to get a list of customer's active entitlements which sounds like it would work for your use case. You can enroll in our APIv2 beta here to use this endpoint: https://www.revenuecat.com/docs/api-v2#tag/Overview-(v2)/Beta-Interest

Badge +1

What about the subscriptions billing period? I need to know for an entitelment when the billing period started and ended.

I’ve noticed that the purchase_date and expires_at when you hit the v1 subscriptions endpoint doesn’t seem to update correctly when I, for instance, grant a promotional three day access to the entitlement via the revenue cat dashboard. I see the subscription, but the entitlement doesnt have the updated date values. This seems like a bug, or just possibly very confusing access patterns. 

Reply