# FAQ and troubleshooting

> Quick answers to the questions developers ask first, and the cause and the fix for the errors you are most likely to meet.

## Keys and access

### Which key do I use where?

The **secret key** (`gc_sk_…`) belongs on your server and opens the server API. The **publishable key** (`gc_pk_…`) belongs in the browser and opens the client API, together with a **player token** (`gc_pt_…`) once a player is involved. The environment is written in the key: `test` or `live`. See [Keys and environments](/docs/concepts/keys-and-environments).

### I get `401 UNAUTHENTICATED`

The key is missing, unknown or revoked, or the player token is invalid or has expired. Check how you send it: the secret key goes in `Authorization: Bearer gc_sk_…`, the publishable key in `X-GameCoin-Key: gc_pk_…`. A player token lasts one hour: ask your server for a new one. A key you revoked in the dashboard stops working at once.

### I get `403 FORBIDDEN` on a route that exists

This kind of key cannot call that route. A publishable key on a server route is the usual cause. The same code is returned when anonymous players are turned off for the game, or when you buy an item that is not sold from the game. See [Security model](/docs/concepts/security-model).

### The browser SDK refuses my key

It refuses any `gc_sk_…` key at startup: a secret key must never run in a browser. Use the publishable key there, and let your server hold the secret key.

### I lost my secret key

A secret key is shown **once**, when it is created, and GameCoin keeps only a fingerprint. Create a new key, deploy it, then revoke the old one.

## Writes, retries and limits

### Do I need an `Idempotency-Key`?

Every `POST` that changes a wallet or an inventory, or that creates a checkout, needs one: granting, spending, consuming, buying with a currency, redeeming a code, starting a payment. A missing key is `400 IDEMPOTENCY_KEY_REQUIRED`. Reads, `PUT`, token creation and the refund of an order do not use one. See [Idempotency](/docs/concepts/idempotency).

### My retry returned the same answer. Did it run twice?

No. The same key with the same request returns the original answer with the header `Idempotent-Replayed: true`, and has no second effect. The same key with a different request is `409 IDEMPOTENCY_CONFLICT`.

### I get `429 RATE_LIMITED`

You went over a limit, for example 600 requests per minute for one secret key. Wait for the number of seconds in the `Retry-After` header and retry. Do not poll balances on a timer. See [Rate limits](/docs/concepts/rate-limits).

## Wallets and orders

### Why is a balance split in `paid` and `bonus`?

Paid coins were bought with euros and are taken back by a refund. Bonus coins are free and are not. `total` is the sum of both. See [Wallets and ledger](/docs/concepts/wallets-and-ledger).

### Can the browser add coins to a player?

No. A browser can read, spend, buy items with a currency, consume and pay for a pack. Only your server (secret key) or a paid order credits a balance. The one exception is a [gift code](/docs/guides/codes) that you issued: it gives free coins once per player.

### I get `409 INSUFFICIENT_FUNDS`

The wallet, or the quantity of an item, is lower than what you asked for. `details.required` and `details.available` give both numbers. Show the player the shop, or the missing amount.

### A balance is negative

A refund took back coins the player had already spent, and the game allows a debt. The player cannot spend until they earn the difference. You choose this behavior in « Réglages » under « Après un remboursement ». See [Refunds](/docs/guides/refunds).

### An order stays `pending`

A pending order is waiting for the payment and expires after one hour. Then it reads `expired`, and the units of stock it held are free again. In `test`, press « Payer » on the payment page to finish it.

### I get `402 PAYMENT_FAILED`

The payment was refused, or the environment has no payment provider. In `test` the simulated provider declines when you press « Refuser ».

### I get `409 PACK_NOT_AVAILABLE` or `PACK_SOLD_OUT`

The pack is outside its sale window (`details.startsAt` and `details.endsAt`), or its total stock is used up. Check the availability of the pack in « Packs ».

### Can I take real payments?

Yes, in the `live` environment, once Apilow has verified your studio. The test environment is open to everyone and its payments are simulated. See [Going live](/docs/guides/going-live).

## Players

### How do I name a player of my own game?

With `ext:` followed by the id you already use, for example `ext:user-42`. GameCoin creates the player the first time your server writes to it. In a URL the player is written `ext%3Auser-42`, **encoded exactly once**. Encoding it twice gives `VALIDATION_FAILED` with `PLAYER_REF_INVALID`. The SDKs do this for you with `ext()`.

### I get `403 PLAYER_BLOCKED`

The player was blocked, from the dashboard (« Bloquer »). Unblock them from the same screen.

## Webhooks

### The signature never matches

Check three things. You must verify the **raw** body of the request, not JSON that your framework parsed and wrote again. You must use the signing secret of the endpoint (`whsec_gc_…`), and each endpoint has its own. And the clock of your server must be within 5 minutes of the time in the signature header. The SDKs verify all of this in one call. See [Webhooks](/docs/guides/webhooks).

### My endpoint receives nothing

An endpoint only receives the events of its own environment, so a `test` endpoint does not receive `live` events. Check that the endpoint is active and subscribed to the event. The delivery log in the dashboard shows each attempt, and « send a test event » checks the whole path.

## SDKs and tools

### Are the SDKs published?

Not yet. The server SDKs are in pre-release and are not on npm, PyPI, Packagist, the Go module proxy or NuGet. The browser SDK is a single file served by GameCoin: `/sdk/gamecoin.js`. You can always call the API directly: see the [API reference](/docs/api).

### Is there an OpenAPI document?

Yes, and it needs no authentication. See [OpenAPI document](/docs/resources/openapi).

### Can an AI assistant read this documentation?

Every page is served as plain Markdown by adding `.md` to its address. `/llms.txt` lists the pages and `/llms-full.txt` holds all of them in one file. The page menu « Copy page » puts the Markdown of the current page on your clipboard.

## Still stuck?

- Search the documentation with `Ctrl K`, or by an error code such as `INSUFFICIENT_FUNDS`.
- Read the [errors](/docs/concepts/errors) page: it lists every code with its cause.
- Write to contact@apilow.com with the order id or the player id, the time of the call, and the code of the error. Never send a secret key.
