> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nozle.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Entitlements Overview

> Enforce feature access and usage limits from a trusted backend

Entitlements control what a customer can do based on subscription and usage state.

## Two decision types

1. **Feature gates** — boolean access, such as analytics or SSO.
2. **Usage limits** — numeric caps, such as monthly requests or generated reports.

## Server-side enforcement

```ts theme={null}
const check = await nozle.can('customer_123', 'api_calls')

if (!check.allowed) {
  return Response.json(
    { error: check.reason ?? 'not_allowed', remaining: check.remaining },
    { status: check.overage ? 429 : 403 },
  )
}

return performProtectedWork()
```

Call `can()` immediately before protected work. The response can include usage and margin context in addition to the allow/deny decision.

## React presentation

Fetch entitlement state through your authenticated backend and pass it into presentational gates:

```tsx theme={null}
<FeatureGate
  allowed={entitlement.allowed}
  loading={entitlement.loading}
  fallback={<UpgradePrompt planName="Growth" />}
>
  <Dashboard />
</FeatureGate>
```

The React component improves the interface; your backend check remains the authorization boundary.

## Updates

Refresh entitlement state after checkout, subscription, or usage changes. For push-based updates, issue a separate server-authorized realtime token or publish through your own authenticated channel. Never send `pk_` or `sk_` credentials to a browser WebSocket connection.

## Margin-aware decisions

`can()` can return unit cost, revenue, margin, thresholds, and warnings. Use those fields for observability or merchant-defined policy without exposing them to customers unless required.

<CardGroup cols={2}>
  <Card title="The can() endpoint" href="/guides/entitlements/can-endpoint" />

  <Card title="React feature gates" href="/sdks/react/gates" />

  <Card title="Node.js entitlements" href="/sdks/node/entitlements" />

  <Card title="Python entitlements" href="/sdks/python/entitlements" />
</CardGroup>
