Solved

Way to bulk apply RevCat entitlements?

  • 14 March 2022
  • 3 replies
  • 117 views

Badge +4

Hi all

Looking at potentially doing a campaign where group of users get X days free access to app. Many of these are previous subscribers or trials that no longer have an active subscription. 

I know on the customer level we can manually apply a single entitlement. Is there a way in the RevCat console to do this in bulk? e.g. all customers in a list (from RevCat customer list) get an entitlement applied? 

Thanks

 

icon

Best answer by tina 18 March 2022, 17:44

View original

3 replies

Userlevel 5
Badge +10

Hey @Kim 

You can write a script that does this for you through our Grant a Promotional Entitlement endpoint. A bulk import for that endpoint is an interesting use case, I’ll add this as an idea for an API overhaul that we have planned on the future roadmap!

Badge +4

Thanks @tina 


Would be benefical if we could create a customer list, then an action is apply entitlement. Right now we can only do it from a single customer. 

 

Keep me posted 

 

Thanks 

 

Kim 

Badge

Thanks Tina!, and Kim for the question

Just wanted to note the +1 here for the request.

We needed to provide an entitlement to all our existing users and that ended up being really time taking. In such cases, we also did not want to just keep issuing requests to revenue Cat and hit the rate limiters.

Also, since I always end up googling bash things, leaving a quick script for the other visitors

 

### Script revCatCommand.sh

user_id=$1

result=$(curl --request POST \
--url https://api.revenuecat.com/v1/subscribers/$1/entitlements/<entitlement_id>/promotional \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <secret>' \
--header 'Content-Type: application/json' \
--data '
{
"duration": "<duration>"
}
')

if [[ "$result" == *"code"* ]]; then
echo $user_id >> failure_cases
else
echo $user_id >> success_cases
fi

exit 0

### Script to_run.sh

counter=1
while IFS= read -r user_id
do
bash revCatCommand.sh $user_id &
counter=$((counter+1))
if [[ $(($counter % 10)) == 0 ]]; then
sleep 1
fi
done < user_list.csv

 

Reply