Link
✎

Licensing a SaaS Application: Plans, Tenants and Entitlements

In a SaaS application the license check runs on your server, not on the customer’s machine, which makes life a lot easier. Each tenant (a customer account, workspace or organization) is one NetLicensing licensee, identified by a stable tenant ID. Your back end validates the tenant, caches the result until its ttl, and switches plans, features and limits on or off from there. Plans are modelled with Pricing Table; seats and usage limits with Quota, Floating or Pay-per-Use.

How SaaS concepts map to NetLicensing

In your SaaS In NetLicensing
Tenant, account, organization Licensee, with your tenant ID as its number (or as an alias)
Plan (free, pro, business) A plan in a Pricing Table module
Feature that comes with a plan A SKU or feature in the Pricing Table, or a Multi-Feature module
Seat limit Quota for named seats you count yourself, or Floating for concurrent sessions
Metered usage Pay-per-Use credits
Free trial The trial option of a Pricing Table plan, or an automatic free license in Subscription
Billing and checkout NetLicensing Shop, or your own billing system via integrations
Customer self-service Customer Portal

The request flow

When a user signs in, your back end already knows the tenant ID. It looks for a cached validation result for that tenant. If there isn’t one, or its ttl has passed, it calls validate with the tenant ID, plus productNumber if tenants are created automatically on first validation. The back end then hands the plan, features and limits to the rest of the application, for example as an entitlements object in the session.

When a tenant upgrades, throw away its cached result so the very next request sees the new plan.

The API key lives on your server here, so you can use a role with more rights, such as ROLE_APIKEY_OPERATION, and create licensees and licenses straight from your sign-up and billing flows. See API key roles.

Upgrades, downgrades and renewals

You can send the tenant to NetLicensing Shop with a shop token, or put a permanent shop token for a particular plan behind a button on your pricing page. If billing happens in your own system, create or deactivate licenses through the License Services API whenever a payment succeeds or fails. Either way, subscribe to webhook notifications (LICENSE_CREATED, PAYMENT_TRANSACTION_PROCESSED, WARNING_LEVEL_CHANGED) so you know when to clear caches or send an email.

Performance and availability

One validation per tenant per TTL is plenty; don’t call the API on every page view. If DNS fails, retry against the backup host netlicensing.labs64.com. And if NetLicensing can’t be reached at all, keep serving from the cached entitlements while their TTL is valid, then decide how your service should behave after that.

Last updated · Edit this page on GitHub