# Check Feature access

Operation / SDK: `checkEntitlement` · `check_entitlement` · `CheckEntitlement`

Check whether a Feature requirement is met; observes access without consuming usage.

Last updated: 2026-11-06

[Web version](https://www.longplayai.com/docs/api/check-entitlement)

<a id="request"></a>

## Request

- **Credential**: Server Key (with `customerId`) or Customer Token, scope `entitlements:read`.
- **SDK**: JavaScript `createLongplayServer().checkEntitlement` · JavaScript `createLongplay().checkEntitlement` · Python `check_entitlement` · Go `CheckEntitlement`
- **Success**: HTTP 200

The response shows example data.

**cURL: request.sh**

```bash
curl -X POST "$LONGPLAY_API_URL/api/v1/entitlements/check" \
  -H "Authorization: Bearer $LONGPLAY_SERVER_KEY" \
  -H "X-Indiana-Protocol: 0.10" \
  -H "Content-Type: application/json" \
  -d '{
  "requirement": {
    "internal_feature_id": "f317c851-0ef2-4d7a-8e3c-e8a29df676ed",
    "quantity": "1",
    "properties": {}
  },
  "commerce": {
    "provider": "stripe",
    "currency": "USD"
  },
  "paywallId": "31a2b083-2ecf-4b52-8431-a3141dab0bc1",
  "customerId": "8b258f8b-4228-40fa-8d24-5b16428e686d"
}'
```

**TypeScript: checkEntitlement.ts**

```ts
import { createLongplayServer } from "@tinkerlandai/longplay-sdk/server";

const longplay = createLongplayServer({
  baseUrl: process.env.LONGPLAY_API_URL!,
  apiKey: process.env.LONGPLAY_SERVER_KEY!,
  scope: { projectId: process.env.LONGPLAY_PROJECT_ID!, environment: "sandbox" },
});

export async function checkEntitlement() {
  return longplay.checkEntitlement({
    requirement: {
      internal_feature_id: "f317c851-0ef2-4d7a-8e3c-e8a29df676ed",
      quantity: "1",
      properties: {},
    },
    commerce: {
      provider: "stripe",
      currency: "USD",
    },
    paywallId: "31a2b083-2ecf-4b52-8431-a3141dab0bc1",
    customerId: "8b258f8b-4228-40fa-8d24-5b16428e686d",
  });
}
```

**Request body: request.json**

```json
{
  "requirement": {
    "internal_feature_id": "f317c851-0ef2-4d7a-8e3c-e8a29df676ed",
    "quantity": "1",
    "properties": {}
  },
  "commerce": {
    "provider": "stripe",
    "currency": "USD"
  },
  "paywallId": "31a2b083-2ecf-4b52-8431-a3141dab0bc1",
  "customerId": "8b258f8b-4228-40fa-8d24-5b16428e686d"
}
```

**Response: response.json**

```json
{
  "requestId": "44f5fcb8-6ed8-41b8-818f-7571941c5fd5",
  "scope": {
    "projectId": "df5426d6-b335-403c-8f3e-b0f73d2e3511",
    "environment": "sandbox"
  },
  "check": {
    "internal_feature_id": "f317c851-0ef2-4d7a-8e3c-e8a29df676ed",
    "name": "Export",
    "kind": "access",
    "quantity": "1",
    "allowed": false,
    "reason": "insufficient_balance",
    "preview": {
      "scenario": "feature_flag",
      "candidates": [
        {
          "productId": "2fd314d6-0f91-46cc-8882-ae8b3cc3bd21",
          "productVersionId": "8c489a1a-5542-44fe-8e80-da2f6a319d01",
          "name": "Pro",
          "action": "purchase",
          "membershipId": null,
          "currency": "USD",
          "amountMinor": "1000",
          "interval": "month",
          "intervalCount": 1
        }
      ]
    }
  }
}
```

<a id="parameters"></a>

## Body parameters

**application/json**

- `requirement` (object, required): The requirement to check: Feature, quantity and pricing properties.
- `requirement.internal_feature_id` (uuid, required): Feature ID.
- `requirement.quantity` (string, required): Quantity as a decimal string, avoiding floating-point error. pattern: ^(0|[1-9]\d{0,11})(\.\d{1,6})?$
- `requirement.properties` (object, required): Validated pricing properties used to match dimensions and multipliers.
- `requirement.entityId` (uuid, optional): Entity ID within the current customer scope, for configured Entity and license Features.
- `commerce` (object, optional): Provider and currency, for example `{ "provider": "stripe", "currency": "USD" }`.
- `commerce.provider` (enum, required): Payment provider; see the allowed values. Values: `"stripe"`, `"apple"`, `"google"`, `"merchant"`.
- `commerce.currency` (enum, required): Currency code supported by the published price. Values: `"USD"`, `"EUR"`, `"CNY"`, `"GBP"`, `"JPY"`, `"CAD"`, `"AUD"`, `"NZD"`, `"CHF"`, `"HKD"`, `"SGD"`, `"KRW"`, `"INR"`, `"BRL"`, `"MXN"`, `"TWD"`, `"THB"`, `"IDR"`, `"MYR"`, `"PHP"`, `"VND"`, `"ZAR"`, `"AED"`, `"SAR"`, `"SEK"`, `"NOK"`, `"DKK"`, `"PLN"`, `"CZK"`, `"HUF"`, `"ILS"`, `"TRY"`, `"RON"`.
- `commerce.intent` ("subscription_change", optional): Intent; see the allowed values.
- `paywallId` (uuid, optional): Paywall ID.
- `customerId` (string, optional): The Customer UUID. Required with a Server Key; omit it with a Customer Token. minLength: 1

<a id="response"></a>

## Response fields

Every successful response includes `requestId` (this request's ID, for support) and `scope` (App and environment).

**HTTP 200 · application/json**

- `requestId` (uuid, required): UUID the server generated for this HTTP request; include it when reporting a problem. It is not your business requestId.
- `scope` (object, required): The App and environment of this response. Headers only verify scope; they cannot switch key scope.
- `scope.projectId` (string, required): App ID bound to the credential. minLength: 1
- `scope.environment` (enum, required): Separate data scope: sandbox or live. Values: `"sandbox"`, `"live"`.
- `check` (object, required): Access check result.
- `check.internal_feature_id` (string, required): Feature ID. minLength: 1
- `check.name` (string, required): Display name; not a unique identifier. minLength: 1 · maxLength: 120
- `check.kind` (enum, required): Kind; see the allowed values. Values: `"access"`, `"metered"`, `"credit"`.
- `check.quantity` (string, required): Quantity as a decimal string, avoiding floating-point error. pattern: ^(0|[1-9]\d{0,11})(\.\d{1,6})?$
- `check.allowed` (boolean, required): Whether this Feature is allowed at evaluation time. Use for display; your backend still authorizes business operations.
- `check.observation` (object, optional): Authority, revision and observation time of this check; required when the merchant decides.
- `check.observation.subject` (object, required): App, environment and Customer of this entitlement decision; must match the original request.
- `check.observation.subject.scope` (object, required): The App and environment of this response. Headers only verify scope; they cannot switch key scope.
- `check.observation.subject.customerId` (uuid, required): The Customer's UUID.
- `check.observation.authority` (enum, required): Authority that produced this decision. Values: `"longplay"`, `"merchant"`.
- `check.observation.observedAt` (date-time, required): Timestamp (ISO 8601).
- `check.observation.sourceRevision` (string, required): Authoritative data revision, used to detect a stale result. minLength: 1 · maxLength: 128
- `check.observation.requirementDigest` (string, required): Digest of the original requirement; the response must match it. pattern: ^[a-f0-9]{64}$
- `check.reason` (enum | null, required): Rejection reason or ledger operation description; interpret with accepted and status.
- `check.preview` (object | null, required): Purchase recommendation for denied access, present when the request includes `commerce`. `scenario` is `usage_limit` when the Customer has a balance for the Feature (or the credit Feature that funds it) and `feature_flag` otherwise. `candidates` lists, in order, up to 20 Products that grant that Feature or credit Feature, priced in `commerce.currency`: main Products the Customer does not hold that upgrade its current main Product (every main Product when it holds none), then add-ons it does not hold and one-time add-ons. Products without a single fixed price in that currency are left out, and a `paywallId`, Paywall or Offering limits the list to the Products it presents, so `candidates` can be empty. `null` when `allowed` is `true` or the request has no `commerce`.
- `check.preview.scenario` (enum, required): Scenario; see the allowed values. Values: `"feature_flag"`, `"usage_limit"`.
- `check.preview.candidates` (array, required): Candidate Products. maxItems: 20
- `check.preview.candidates.productId` (string, required): Product ID. minLength: 1
- `check.preview.candidates.productVersionId` (string, required): Product Version ID. minLength: 1
- `check.preview.candidates.name` (string, required): Display name; not a unique identifier. minLength: 1 · maxLength: 120
- `check.preview.candidates.action` (enum, required): Business action. Target fields and quantity requirements vary by action; see the request structure and example. Values: `"purchase"`, `"upgrade"`, `"addon"`, `"topup"`.
- `check.preview.candidates.membershipId` (string | null, required): membership ID.
- `check.preview.candidates.featureQuantities` (object, optional): Prepaid Feature quantities by internal Feature ID.
- `check.preview.candidates.currency` (enum, required): Currency code supported by the published price. Values: `"USD"`, `"EUR"`, `"CNY"`, `"GBP"`, `"JPY"`, `"CAD"`, `"AUD"`, `"NZD"`, `"CHF"`, `"HKD"`, `"SGD"`, `"KRW"`, `"INR"`, `"BRL"`, `"MXN"`, `"TWD"`, `"THB"`, `"IDR"`, `"MYR"`, `"PHP"`, `"VND"`, `"ZAR"`, `"AED"`, `"SAR"`, `"SEK"`, `"NOK"`, `"DKK"`, `"PLN"`, `"CZK"`, `"HUF"`, `"ILS"`, `"TRY"`, `"RON"`.
- `check.preview.candidates.amountMinor` (string, required): Amount in the currency's minor unit, such as cents. pattern: ^(0|[1-9]\d{0,8})$
- `check.preview.candidates.interval` (enum, required): Interval; see the allowed values. Values: `"free"`, `"week"`, `"month"`, `"year"`, `"one_time"`.
- `check.preview.candidates.intervalCount` (integer, required): Charging interval count: up to 156 weeks, 36 months or 3 years; omitted means 1. Not accepted for free or one_time. Allowance resets remain independent. min: 1 · max: 156

<a id="errors"></a>

## Errors

Failures return an error object; handle them by `error.code` and `error.recovery`. The table lists the errors that follow from this operation's credential, scope and idempotency fields; depending on the request it can also return `NOT_FOUND` (a referenced resource doesn't exist), `NOT_CONFIGURED` (a required integration isn't connected) or `PAYLOAD_TOO_LARGE`. Some refusals, such as insufficient balance, are not errors but a `reason` in a successful response.

**Possible errors**

| code | HTTP | When | recovery |
| --- | --- | --- | --- |
| `INVALID_REQUEST` | 400 | The request doesn't match this page's parameters. A missing or malformed protocol header returns `UNSUPPORTED_PROTOCOL_VERSION` or `INVALID_PROTOCOL_VERSION` instead. | `fix_request` |
| `UNAUTHENTICATED` | 401 | The credential is missing, invalid, expired or revoked. | `authenticate` |
| `FORBIDDEN` | 403 | The credential lacks `entitlements:read`. | `check_permissions` |
| `SCOPE_MISMATCH` | 403 | `X-Indiana-Project` or `X-Indiana-Environment` doesn't match the credential's App and environment. | `check_scope` |
| `RATE_LIMITED` | 429 | Too many requests; wait for `Retry-After` and retry the same request. | `retry_same_request` |
| `SERVICE_UNAVAILABLE` | 503 | The service is temporarily unavailable; retry the same request. | `retry_same_request` |
| `INTERNAL_ERROR` | 500 | The outcome is unknown; retry later. | `recover_operation` |

- [Error codes and recovery](https://www.longplayai.com/docs/api/errors.md)
- [Request conventions](https://www.longplayai.com/docs/api.md)
- [All operations](https://www.longplayai.com/docs/api/operations.md#access)
