Skip to main content
Answer

Granting Entitlements API not functioning as expected

  • February 1, 2025
  • 1 reply
  • 210 views

Forum|alt.badge.img+4

Our user journey may allow users to experience multiple trials of our subscription product. We are using the RevenueCat API to grant users an entitlement for a custom time frame. Unfortunately after one successful request, subsequent requests no longer create a new entitlement for the user. Instead it returns successfully with the old entitlement that was granted.

 

Request 1 that grants the initial enitlement

 const resp = await fetch(
`https://api.revenuecat.com/v1/subscribers/${userId}/entitlements/premium/promotional`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${REVENUECAT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
end_time_ms: Date.now() + 1000 * 60 * 60 * 24,
}),
}
);

Returns 

{
"entitlements":
{"premium":
{
"expires_date":"2025-02-01T04:57:50Z",
"grace_period_expires_date":null,
"product_identifier":"rc_promo_premium_custom",
"purchase_date":"2025-02-01T04:47:51Z"
}
}
}

After expiration, if we repeat the same request, I would expect a NEW entitlement with a new expiration to be created and activated. However, the same response comes back.

 

We would love to get this resolved, if possible! Thanks!

Best answer by Ryan Glanz

We discussed this in a support ticket, but for others looking at this:

The example request is a granted entitlement with a 24-h expiration (all good)

The example response was from a test using a 10-s expiration. Our API has limitations for short-term granted entitlements like this (i.e., if you try to grant an entitlement with an expiration within a couple hours of an existing granted entitlement’s expiration, it won’t be granted, and the API will respond with the previous granted entitlement’s info). For real-world applications of granted entitlements (i.e., more than a couple hours), this won’t be a problem.

This post has been closed for comments

1 reply

Ryan Glanz
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • Answer
  • February 5, 2025

We discussed this in a support ticket, but for others looking at this:

The example request is a granted entitlement with a 24-h expiration (all good)

The example response was from a test using a 10-s expiration. Our API has limitations for short-term granted entitlements like this (i.e., if you try to grant an entitlement with an expiration within a couple hours of an existing granted entitlement’s expiration, it won’t be granted, and the API will respond with the previous granted entitlement’s info). For real-world applications of granted entitlements (i.e., more than a couple hours), this won’t be a problem.