Skip to main content
Retrieves all entitlements for a customer along with the overall access state, including reasons for denied access.
To benefit from Stigg’s low-latency capabilities, use the Sidecar — it serves entitlement checks from a local cache without a network round-trip per request, with built-in fallback handling. For Node.js applications, the Node.js SDK provides equivalent low-latency caching natively in-process.

Query

query GetEntitlementsState($query: FetchEntitlementsQuery!) {
  entitlementsState(query: $query) {
    accessDeniedReason
    entitlements {
      feature {
        refId
        displayName
        featureType
        featureUnits
      }
      isGranted
      hasUnlimitedUsage
      usageLimit
      currentUsage
      resetPeriod
      usagePeriodEnd
      accessDeniedReason
    }
  }
}
{
  "query": {
    "customerId": "customer-123"
  }
}
{
  "data": {
    "entitlementsState": {
      "accessDeniedReason": null,
      "entitlements": [
        {
          "feature": {
            "refId": "feature-api-calls",
            "displayName": "API Calls",
            "featureType": "NUMBER",
            "featureUnits": "call"
          },
          "isGranted": true,
          "hasUnlimitedUsage": false,
          "usageLimit": 10000,
          "currentUsage": 4532,
          "resetPeriod": "MONTH",
          "usagePeriodEnd": "2024-02-01T00:00:00Z",
          "accessDeniedReason": null
        },
        {
          "feature": {
            "refId": "feature-sso",
            "displayName": "Single Sign-On",
            "featureType": "BOOLEAN",
            "featureUnits": null
          },
          "isGranted": true,
          "hasUnlimitedUsage": false,
          "usageLimit": null,
          "currentUsage": null,
          "resetPeriod": null,
          "usagePeriodEnd": null,
          "accessDeniedReason": null
        }
      ]
    }
  }
}

Parameters

query
FetchEntitlementsQuery
required
Query parameters for fetching entitlements state

Return Type

Returns an EntitlementsState object with:
FieldTypeDescription
accessDeniedReasonEntitlementsStateAccessDeniedReasonGlobal access denial reason
entitlements[Entitlement]List of entitlements

Global Access Denied Reasons

ReasonDescription
CustomerNotFoundCustomer doesn’t exist
CustomerIsArchivedCustomer is archived
NoActiveSubscriptionNo active subscription

Common Use Cases

Recommended for initial entitlement fetch - provides both entitlements and overall access state.
Global accessDeniedReason helps handle cases where customer has no subscription.

Example: Handling Access State

const { data } = await client.query({
  query: GET_ENTITLEMENTS_STATE,
  variables: {
    query: { customerId: user.customerId }
  }
});

const { accessDeniedReason, entitlements } = data.entitlementsState;

if (accessDeniedReason === 'CustomerNotFound') {
  // Customer doesn't exist in Stigg
  redirectToSignup();
  return;
}

if (accessDeniedReason === 'NoActiveSubscription') {
  // Customer exists but needs a subscription
  showPricingPage();
  return;
}

if (accessDeniedReason === 'CustomerIsArchived') {
  // Customer account is deactivated
  showReactivationPrompt();
  return;
}

// Process entitlements normally
initializeFeatureFlags(entitlements);