# Create a Server Key

Create a backend credential for one App and environment.

Last updated: 2026-11-06

[Web version](https://www.longplayai.com/docs/guides/server-auth)

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

## Credentials and identity

**Who holds each credential**

| Caller | Credential | Purpose |
| --- | --- | --- |
| Longplay console member | Better Auth account session | Sign in to Console and the CLI and create Apps and Keys; not an SDK API credential |
| Your backend | Server Key / gg_sk_ | Call APIs within the Key's App, environment, and scopes |
| Your user | externalUserId | Verified by your own login system; not a Longplay login credential |
| Browser or app | Access Token / gg_ct_ | Call business APIs as the verified Customer |
| Browser or app | Refresh Token / gg_rt_ | Refresh the same session only; cannot call business APIs |

A Server Key proves backend access, not end-user identity. Verify the user in your backend before sending a stable user ID to Decide.

<a id="open-console"></a>

## Open the creation flow

- Open https://console.longplayai.com/workspace/developers?tab=keys and select the App and Sandbox.
- In the sidebar, choose Integrations → Server keys, then click Create Key.
- The account needs apiKeys:write for the App. An Owner, or an Admin or Developer with App access, can do this.

<a id="generate-key"></a>

## Generate and store

Enter a name and expiry, and select only the scopes you use (see the scope list below). A first request needs only customers:write; Funnel server decisions need customers:write, sessions:create, funnels:run. A Run uses the permissions of the Key that started it: Paywall and Offering steps need entitlements:read; buying from a Paywall also needs billing:write (quote, confirm and cancel) and billing:read (settlement and recovery reads); claiming or showing Coupons needs offers:resolve. In the Console's Create Key dialog, "Use Funnel start permissions" selects all of them: funnels:run, sessions:create, customers:write, entitlements:read, offers:resolve, billing:read, billing:write.

A Key is bound to one App and environment, expires in 1–365 days, and counts toward a limit of 20 active Keys per App/environment. Click Generate Key. The complete Key appears once. Save it in your backend secret store or a Git-ignored local .env as LONGPLAY_SERVER_KEY; never put it in browser code or public docs.

- [Open Server keys in Console](https://console.longplayai.com/workspace/developers?tab=keys)
- [Install SDKs and CLI](https://www.longplayai.com/docs/install.md)
- [Environments](https://www.longplayai.com/docs/guides/environments.md)

<a id="scopes"></a>

## Scope list

**Scopes a Server Key can hold**

| Scope | Allows |
| --- | --- |
| `messaging:write` | Manage Customer messaging preferences and devices; send and read messages from a trusted server. |
| `customers:read` | Read Customers, lists and seats. |
| `customers:write` | Create, update and claim Customers. |
| `sessions:create` | Issue, renew and revoke Customer/Guest sessions; also required to start Funnels. |
| `content:read` | Read standalone Page, Popup and Banner content by resource or fixed version for the verified Customer or Guest. |
| `entitlements:read` | Check access, read holdings, resolve Offerings and Paywalls; also required when a Funnel Run started with the Key reaches a Paywall or Offering step. |
| `credits:read` | Read balances, usage, ledger, statements, analytics and AI pricing. |
| `credits:consume` | Report usage and consume or reserve balance. |
| `credits:manage` | Grant and adjust balances, set usage and manage Entities. |
| `billing:read` | Read payments, subscriptions, trials, invoices and refunds; also required when a Funnel Run started with the Key reads a Paywall purchase's settlement or recovery. |
| `billing:write` | Purchases, subscription changes, refunds, invoices, billing controls, seats and native purchases; also required when a Funnel Run started with the Key quotes, confirms or cancels a Paywall purchase. |
| `offers:resolve` | Customer coupon redemption, claims and lists, referral codes and rewards; also required when a Funnel Run started with the Key claims or shows Coupons. |
| `offers:grant` | Grant coupons to Customers from your backend. |
| `features:read` | Download and evaluate feature flags. |
| `events:write` | Report behavior, exposure and feature-flag usage events. |
| `funnels:run` | Start and advance Funnels, server decisions and adoption reports. |
| `code-references:read` | CLI/CI reads the code-reference scan configuration. |
| `code-references:write` | CLI/CI uploads code-reference scan reports. |
| `app-manifests:write` | Upload the App page map (IAM) from builds; must be the Key's only permission. |

The Key that issues a Customer session bounds what that session can call in the browser: for example, to let the browser read access, buy and redeem coupons, the issuing Key needs sessions:create plus entitlements:read, billing:read, billing:write and offers:resolve. CI code-reference scanning uses a separate Key with only code-references:read and code-references:write.

<a id="rotation"></a>

## Rotate and revoke

If scopes change or a Key is lost or near expiry, create a replacement for the same App/environment. Update backend configuration, confirm successful requests, then revoke the old Key. Revocation or expiry affects later authentication; it does not roll back committed operations.
