Publisher-Managed Access API
Publisher-managed access lets your site decide exactly what subscribers can see. Ezoic Subscriptions handles checkout, payment infrastructure, subscriber sessions, and access verification. Your code checks an access key and shows the right content.
Access Keys 🔗
An access key is the stable identifier your site checks. The key is authored in your Ezoic offer and belongs to your site.
Access keys are:
- Domain-scoped.
- Case-insensitive.
- Stored lowercase.
- Limited to letters, numbers, hyphens, and underscores.
Examples:
premiumpremium-accesspremium_membershippro
Use keys that describe the access level, not the current price or promotion.
Basic Access Check 🔗
<div data-premium-content hidden>
Premium content goes here.
</div>
<script>
window.ezsubscriptions = window.ezsubscriptions || {};
ezsubscriptions.cmd = ezsubscriptions.cmd || [];
ezsubscriptions.cmd.push(async function () {
const access = await ezsubscriptions.hasAccess("premium");
if (access.decision === "allowed") {
document.querySelector("[data-premium-content]").hidden = false;
return;
}
ezsubscriptions.showPaywall({ offer: "premium-plan" });
});
</script>
<script src="https://sm.ezoic.com/min.js" async defer></script>
hasAccess("premium") checks whether the current visitor has an active entitlement that grants the premium access key.
showPaywall({ offer: "premium-plan" }) opens Ezoic's pre-built paywall and checkout experience for the products in the premium-plan offer. The access key (premium) is what you check; the offer key (premium-plan) is what you sell.
Access Decisions 🔗
hasAccess(...) returns an access decision:
allowed: The visitor has active access.login_required: The visitor is not signed in to Ezoic Subscriptions on this site.denied: The visitor is signed in but does not have access.expired: The visitor had access, but it is no longer active.revoked: Access was removed.
For most integrations, show subscriber-only content only when the decision is allowed. Treat every other decision as no current access, then call showPaywall({ offer: "your-offer-key" }) or show your own message before opening checkout.
Anonymous Visitors 🔗
Anonymous visitors do not require a network request for access checks:
hasAccess(...)returnslogin_required.getAccessTiers()returns an empty list.
This keeps pages responsive while still letting the paywall offer checkout or passwordless login.
Checking Multiple Features 🔗
Use getAccessTiers() when your site has several subscriber-only features:
const tiers = await ezsubscriptions.getAccessTiers();
if (tiers.includes("pro")) {
enableProTools();
}
if (tiers.includes("premium")) {
showPremiumNavigation();
}
Implementation Notes 🔗
hasAccesstakes the access key;showPaywall({ offer })takes the offer key. They are different identifiers authored on the same offer.- Use
showPaywall({ offer })afterhasAccess(...)returns anything other thanallowed. - Do not pass a config object for normal publisher-managed offers. The widget loads the correct paywall configuration from the offer key.
- Keep access keys and offer keys stable after launch.
- Show teaser content to everyone, then reveal or fetch the protected body only after access is allowed.
For method options, callback hooks, and return values, see JavaScript API Reference.