# Read memberships, purchases and balances

Operation / SDK: `readHoldings` · `read_holdings` · `ReadHoldings`

Read a Customer or Entity's memberships, purchases and balances.

Last updated: 2026-11-06

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

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

## Request

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

The response shows example data.

**cURL: request.sh**

```bash
curl -X POST "$LONGPLAY_API_URL/api/v1/customer-holdings" \
  -H "Authorization: Bearer $LONGPLAY_SERVER_KEY" \
  -H "X-Indiana-Protocol: 0.10" \
  -H "Content-Type: application/json" \
  -d '{
  "customerId": "8b258f8b-4228-40fa-8d24-5b16428e686d"
}'
```

**TypeScript: readHoldings.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 readHoldings() {
  return longplay.readHoldings({
    customerId: "8b258f8b-4228-40fa-8d24-5b16428e686d",
  });
}
```

**Request body: request.json**

```json
{
  "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"
  },
  "holdings": {
    "customerId": "8b258f8b-4228-40fa-8d24-5b16428e686d",
    "snapshotAt": "2026-10-03T12:00:00.000Z",
    "memberships": [
      {
        "id": "5c22044b-a5dd-49fe-83bf-c52eff327451",
        "productId": "1Example",
        "productVersionId": "8c489a1a-5542-44fe-8e80-da2f6a319d01",
        "billingProductVersionId": "aaef229f-4c54-455a-868b-3194e5e1c641",
        "version": 1,
        "key": "1Example",
        "name": "Pro",
        "groupId": null,
        "membershipType": "main",
        "status": "trial",
        "cancelAtPeriodEnd": true,
        "accessEnabled": true,
        "renewalChange": null,
        "period": null
      }
    ],
    "membershipsLimited": true,
    "balances": [
      {
        "internal_feature_id": "f317c851-0ef2-4d7a-8e3c-e8a29df676ed",
        "key": "1Example",
        "name": "Pro",
        "kind": "access",
        "usageType": null,
        "accessible": true,
        "unlimited": true,
        "available": "1",
        "held": "1",
        "debt": "1",
        "nextExpiresAt": null,
        "usage": null
      }
    ],
    "balancesLimited": true
  }
}
```

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

## Body parameters

**application/json**

- `customerId` (uuid, optional): The Customer's UUID.
- `entityId` (uuid, optional): Entity ID within the current customer scope, for configured Entity and license Features.

<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"`.
- `holdings` (object, required): The Customer's holdings at `snapshotAt`, scoped to `entityId` when given: memberships and per-Feature balances.
- `holdings.customerId` (uuid, required): The Customer's UUID.
- `holdings.snapshotAt` (date-time, required): Statement snapshot time; pass the first page's value when paging, `null` for the first page.
- `holdings.memberships` (array, required): membership; fields below. maxItems: 100
- `holdings.memberships.id` (uuid, required): The membership's ID.
- `holdings.memberships.productId` (string, required): Product ID. minLength: 1 · maxLength: 255
- `holdings.memberships.productVersionId` (uuid, required): Product Version ID.
- `holdings.memberships.billingProductVersionId` (uuid, required): UUID of the Product Version this membership is billed under; it equals `productVersionId`.
- `holdings.memberships.version` (integer, required): Version number. max: 9007199254740991
- `holdings.memberships.key` (string, required): The Product key (its public ID), the same value as `productId`. minLength: 1 · maxLength: 64
- `holdings.memberships.name` (string, required): Display name; not a unique identifier. minLength: 1 · maxLength: 120
- `holdings.memberships.groupId` (string | null, required): The Product's group: main Products in the same group are mutually exclusive. `null` means the default group.
- `holdings.memberships.membershipType` (enum, required): `main` is a main Product, which replaces other main Products in its group; `addon` is an add-on held alongside other Products. Values: `"main"`, `"addon"`.
- `holdings.memberships.status` (enum, required): Status; see the allowed values. Values: `"trial"`, `"active"`, `"past_due"`, `"ended"`, `"expired"`, `"trialing"`, `"paused"`, `"pending"`, `"scheduled"`, `"unknown"`.
- `holdings.memberships.cancelAtPeriodEnd` (boolean, required): Whether it cancels at the end of the current period.
- `holdings.memberships.accessEnabled` (boolean, required): Whether the membership grants its Product's access right now: it has started, has not ended, and is active, past due or in an unexpired trial.
- `holdings.memberships.renewalChange` (object | null, required): A pending or scheduled change to this membership (another Product Version, a seat quantity or a Feature quantity) with its timing and status; `null` when none is pending.
- `holdings.memberships.renewalChange.productVersionId` (uuid, required): Product Version ID.
- `holdings.memberships.renewalChange.name` (string, required): Display name; not a unique identifier. minLength: 1 · maxLength: 120
- `holdings.memberships.renewalChange.version` (integer, required): Version number. max: 9007199254740991
- `holdings.memberships.renewalChange.effectiveAt` (date-time, required): Timestamp (ISO 8601).
- `holdings.memberships.renewalChange.benefitsAppliedAt` (date-time | null, required): Timestamp (ISO 8601).
- `holdings.memberships.renewalChange.timing` (enum, required): Immediate or end-of-cycle timing, only for supported plan-change actions. Values: `"immediate"`, `"renewal"`.
- `holdings.memberships.renewalChange.changeKind` (enum, required): `plan` switches to another Product Version; `seats` changes a seat quantity (see `seat`); `quantity` changes a Feature's purchased quantity (see `feature`). Values: `"plan"`, `"seats"`, `"quantity"`.
- `holdings.memberships.renewalChange.feature` (object, optional): Feature; fields below.
- `holdings.memberships.renewalChange.seat` (object | null, required): For a `seats` change, the seat `key` with its quantity before (`fromQuantity`) and after (`toQuantity`); `null` for other change kinds.
- `holdings.memberships.renewalChange.status` (enum, required): Status; see the allowed values. Values: `"prepared"`, `"quoted"`, `"confirmed"`, `"pending"`, `"scheduled"`.
- `holdings.memberships.period` (object | null, required): The membership's current period: `phase`, `startsAt` and `endsAt` (ISO 8601; `endsAt` is `null` when open-ended). `null` when the membership has no start time.
- `holdings.memberships.period.phase` (enum, required): `trial` while a free trial is running; otherwise `paid`. Values: `"paid"`, `"trial"`.
- `holdings.memberships.period.startsAt` (date-time, required): Timestamp (ISO 8601).
- `holdings.memberships.period.endsAt` (date-time | null, required): Timestamp (ISO 8601).
- `holdings.membershipsLimited` (boolean, required): Whether the Customer has more than 100 memberships, in which case `memberships` lists only the 100 most recently created.
- `holdings.balances` (array, required): One entry per Feature the Customer (or the requested Entity) currently holds, combining all current sources and sorted by Feature name; at most 500. maxItems: 500
- `holdings.balances.internal_feature_id` (uuid, required): Feature ID.
- `holdings.balances.key` (string, required): The Feature key. minLength: 1 · pattern: ^[a-zA-Z0-9_-]+$
- `holdings.balances.name` (string, required): Display name; not a unique identifier. minLength: 1 · maxLength: 120
- `holdings.balances.kind` (enum, required): Kind; see the allowed values. Values: `"access"`, `"metered"`, `"credit"`.
- `holdings.balances.usageType` (enum | null, required): For metered Features: `consumable` when usage is spent from the balance (such as requests), `non_consumable` for allocated capacity such as seats, reported in `usage`. `null` when `kind` is `access` or `credit`.
- `holdings.balances.accessible` (boolean, required): Whether the balance can be used now; when `false`, `available` and `held` are `0`.
- `holdings.balances.unlimited` (boolean, required): Whether it is unlimited.
- `holdings.balances.available` (string, required): Available quantity. pattern: ^(0|[1-9]\d{0,17})(\.\d{1,12})?$
- `holdings.balances.held` (string, required): Holdings. pattern: ^(0|[1-9]\d{0,17})(\.\d{1,12})?$
- `holdings.balances.debt` (string, required): Outstanding debt on this balance as a decimal string, settled by later payments or refunds; `0` when nothing is owed. pattern: ^(0|[1-9]\d{0,17})(\.\d{1,12})?$
- `holdings.balances.nextExpiresAt` (date-time | null, required): Timestamp (ISO 8601).
- `holdings.balances.usage` (object | null, required): Usage.
- `holdings.balances.usage.internal_feature_id` (uuid, required): Feature ID.
- `holdings.balances.usage.entityId` (uuid | null, required): Entity ID within the current customer scope, for configured Entity and license Features.
- `holdings.balances.usage.operationId` (uuid | null, required): Business operation UUID. Subscription execution references operationId from previewAttach; balance refunds reference the original consumption.
- `holdings.balances.usage.usage` (string, required): Usage. pattern: ^(0|[1-9]\d{0,11})(\.\d{1,6})?$
- `holdings.balances.usage.capacity` (string | null, required): Capacity.
- `holdings.balances.usage.remaining` (string | null, required): Remaining allowance at evaluation time. It is not reserved and does not guarantee later consumption.
- `holdings.balances.usage.withinLimit` (boolean, required): Whether it is within the limit.
- `holdings.balances.usage.revision` (integer, required): Revision of the specific versioned resource; Customer profile updates have no revision. min: 0 · max: 9007199254740991
- `holdings.balances.usage.updatedAt` (date-time | null, required): ISO 8601 UTC time of the last record update.
- `holdings.balancesLimited` (boolean, required): Whether more than 500 balances exist, in which case `balances` lists only the first 500 by Feature name.

<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)
