What's the correct way to not allow free
# 🗣general-chat
s
What's the correct way to not allow free users $5 from running my actor?
f
you can block or limit them in your Actor code.
Detect if the user is on a free plan Use the APIFY_USER_IS_PAYING env var (or SDK helper) in your Actor
s
using the sdk I get an error
f
import { Actor } from 'apify'; await Actor.init(); const { userIsPaying } = Actor.getEnv(); // true = paying plan, false = free [[User paying env](https://docs.apify.com/platform/actors/development/permissions/migration-guide#the-actor-needs-to-know-whether-the-user-is-paying)] if (!userIsPaying) { // Block free users completely throw new Error('This Actor is only available for paying Apify users.'); } // …rest of your logic… await Actor.exit();
s
do I need to configure the settings of the actor as full permissions or limited permissions?
Also is this snippet outdated?
Copy code
const user = await Actor.apifyClient.user().get();
isPayingUser = user.isPaying || false;
f
instead of blocking free users entirely, you can still allow them to run the Actor but with limits.
s
yes I want to allow them to run the actor with a limited set of filters and if they are paying they can fully use all the filters
but I need a proper way to detect free users
f
You can 100% do that. The proper, supported way to detect free vs paying users is to use Apify’s built-in flag: APIFY_USER_IS_PAYING → accessible via Actor.getEnv().
const { userIsPaying } = Actor.getEnv();
This works even with limited permissions and doesn’t require calling the user API.
s
got it, nice is userIsPaying a string or a boolean
f
userIsPaying is a boolean not a string.
You can also create a small dummy Actor to test this before adding it to your main one.
That way you can confirm how userIsPaying behaves for free vs paying accounts without publishing or affecting your real product Actor. After you verify the behavior, just move the same logic into your main Actor.