.NET SDK — enforce entitlements
Once you hold a session, enforcing entitlements is a
local check against the signed license — no network call on the hot path. license.FeatureValidation
answers “is this feature licensed right now?” and “is there room under this limit?”.
Gate a feature
Section titled “Gate a feature”var license = await session.AccessLicenseAsync();if (license is null || !license.FeatureValidation.IsValidFeature("advanced-export")){ return Results.Forbid(); // not licensed for this feature}IsValidFeature returns true only when the feature is present in the license and the
license is operational — an expired license fails every feature check, so you don’t have
to combine the two yourself. It accepts a feature code, or an ActivatedFeatureDto from
LicensedFeatures.
Enumerate what the customer has
Section titled “Enumerate what the customer has”To drive UI — show which capabilities are on, grey out the rest — read the licensed features directly:
foreach (var feature in license.FeatureValidation.LicensedFeatures){ // feature.Code, feature.Name, and its enablement flags}GetLicenseFeature(code) returns a single feature (or null) when you need its detail.
Check a usage limit before acting
Section titled “Check a usage limit before acting”For features carrying a quota, ValidateUsageQuota tells you whether a limit still has
headroom, so you can block before doing the work rather than reconciling after:
if (!license.FeatureValidation.ValidateUsageQuota("api-calls.total", 1)){ return Results.StatusCode(429); // quota exhausted}This is a read against the license’s known limits. Enforcing consumption that actually draws down a metered balance or credit is covered in report usage — that path is authoritative and handles concurrent draw-down on the server.
Trials and grace behave like licensed
Section titled “Trials and grace behave like licensed”Because IsValidFeature keys off IsOperational, features stay available during a valid
trial and during the grace window after expiry. When
the trial or grace ends, the same checks start returning false with no code change on your
side. Read license.LicenseValidation.TrialStatus if you want to show a “trial ends in N
days” banner.