# API overview

Find operations by business task and learn the API endpoint, headers, credentials, idempotent retries and error format.

Last updated: 2026-11-06

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

<a id="api-overview"></a>

## API Reference

Browse HTTP operations by business domain, or search the complete directory by method, path and permission. Each operation page includes requests, responses, SDK calls and recovery guidance.

- [All operations](https://www.longplayai.com/docs/api/operations.md): Every HTTP operation with its path, credential, scope, SDK methods and purpose, plus Funnel commands and public endpoints.
- [Funnel decision HTTP reference](https://www.longplayai.com/docs/api/funnel-decisions.md): HTTP headers, JSON payloads, response statuses, and recovery for campaign_decide, read_decision, and report_used.
- [Error codes and recovery](https://www.longplayai.com/docs/api/errors.md): Server error codes, recovery actions, reasons and SDK client errors.

<a id="api-domains"></a>

## Operation groups

- **Customer messaging and installations**: 7 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#messaging)
- **Customers, Guests and Sessions**: 10 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#identity)
- **Entitlements and product presentation**: 4 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#access)
- **Balances, usage and ledger**: 16 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#credits)
- **Seats**: 2 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#seats)
- **Subscriptions and payments**: 20 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#commerce)
- **Invoices, refunds and billing**: 20 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#invoices)
- **Coupons, rewards and referrals**: 8 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#offers)
- **Feature flags, evaluation and events**: 3 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#features)
- **Native purchases**: 1 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#native)
- **AI pricing**: 1 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#ai)
- **CLI and CI**: 3 operations [Browse operations](https://www.longplayai.com/docs/api/operations.md#integration)

<a id="api-common-operations"></a>

## Common operations

- [Find or create a customer](https://www.longplayai.com/docs/api/create-customer.md) (`createCustomer` · `getOrCreateCustomer` · `get_or_create_customer` · `GetOrCreateCustomer`): Find or create a Customer by externalUserId or email; an existing profile is never overwritten.
- [Check Feature access](https://www.longplayai.com/docs/api/check-entitlement.md) (`checkEntitlement` · `check_entitlement` · `CheckEntitlement`): Check whether a Feature requirement is met; observes access without consuming usage.
- [Confirm or cancel a purchase](https://www.longplayai.com/docs/api/attach.md) (`attach` · `Attach`): Confirm or cancel a quoted purchase; the transaction and signed callbacks decide the result.

<a id="endpoint"></a>

## Endpoint and path

These protocol-0.10 examples use production API https://api.longplayai.com with that deployment's Sandbox credentials. Every operation lives under `/api/v1/`; ordinary operations each have a path, and Funnel commands share `POST /api/v1/funnels`.

**request.http**

```bash
POST https://api.longplayai.com/api/v1/customers/get
Authorization: Bearer <SERVER_KEY>
X-Indiana-Protocol: 0.10
Content-Type: application/json

{ "lookup": { "type": "externalUserId", "value": "user-42" } }
```

The `X-Indiana-*` headers and credential prefixes such as `gg_sk_` are fixed protocol names that keep earlier internal names for Longplay. They belong to the same product as the `LONGPLAY_` variables in SDK and CLI examples; send them exactly as written here and do not substitute the prefix.

<a id="headers"></a>

## Headers

**Headers**

| Header | Requirement |
| --- | --- |
| `Authorization` | Exactly one `Bearer <credential>`. |
| `X-Indiana-Protocol` | Required: `0.10`. Missing or unsupported values return 400 `UNSUPPORTED_PROTOCOL_VERSION`. |
| `Content-Type` | Use `application/json` for non-GET requests. |
| `X-Indiana-Project` / `X-Indiana-Environment` | Optional scope assertions, sent together: the App UUID and `sandbox`/`live`. They must match the credential and cannot select another tenant. |
| `X-Indiana-SDK-Version` | Optional; sent by the SDKs. |
| `Origin` | Must be absent on Server Key requests; browser origins must be registered in Console. |

- GET operations accept no body or query parameters; other operations reject query parameters too.
- Successful responses include `requestId` and `scope`, with `X-Request-Id` and `Cache-Control: no-store`. Success is normally HTTP 200; `submitUsageBatch` and pending Funnel decisions return 202.

<a id="credentials"></a>

## Credentials

**Credential types**

| Credential | Prefix | Holder | Use |
| --- | --- | --- | --- |
| Server Key | `gg_sk_` | Your backend | Server operations within the Key's App, environment and scopes. |
| Customer Token | `gg_ct_` | Browser / app | Customer-allowed operations as exactly one Customer. |
| Refresh Token | `gg_rt_` | Browser / app | Only `refreshSession`, to obtain a new Access/Refresh pair. |
| Run Token | `gg_fr_` | Browser / app / backend | Only its own Funnel Run, with the original identity proof: either `customerToken` in the JSON body or the issuing Server Key in the `X-Indiana-Server-Key` header, never both. A mismatched proof returns 403. |
| Environment UUID | — | Public | Read published public configuration and website experiments; authenticates nothing. |

Every call checks the credential, scope, App/environment/Customer and origin. A Customer Token cannot select another Customer; a Server Key proves backend access, not end-user identity.

- [Scope list](https://www.longplayai.com/docs/guides/server-auth.md#scopes)

<a id="names"></a>

## Header and prefix names

`X-Indiana-*` headers (such as `X-Indiana-Protocol`) and the `gg_` credential prefixes (such as `gg_sk_` for Server Keys) are fixed technical names in the protocol. They come from the platform's internal code names and do not refer to another product or service. Send, store and match them exactly as written; do not rename them to Longplay or anything else. Other API pages use them without repeating this note.

<a id="idempotency"></a>

## Idempotency and retries

- Writes carry a business ID: `requestId`, `eventId` or `idempotencyKey`. Generate and persist it before the first send, and replay the same ID with identical input after an unknown result; reusing an ID with different input returns `CONFLICT` (`IDEMPOTENCY_CONFLICT`).
- The response `requestId` and `X-Request-Id` identify one HTTP attempt for diagnostics; never use them as the business ID. Exception: in Funnel decision responses (`campaign_decide`, `read_decision`), `requestId` is the decision's original business requestId.
- Asynchronous work (purchases, changes, refunds, invoices, usage batches, Funnel decisions) returns an operation ID; after a timeout, read the original operation rather than creating a second one.

<a id="error-shape"></a>

## Error format

**error.json**

```json
{
  "requestId": "<HTTP_ATTEMPT_ID>",
  "error": {
    "code": "FORBIDDEN",
    "message": "This credential cannot perform this operation.",
    "retryable": false,
    "recovery": "check_permissions"
  }
}
```

Handle failures by `error.code`, `retryable` and `recovery`; never parse `message`. `error.reason` is optional; when you should wait, the response sets the `Retry-After` header and `error.retryAfterSeconds` (seconds).

- [Error codes and recovery](https://www.longplayai.com/docs/api/errors.md)
