Skip to content
Skip the menu

API reference

Players API

Create and update players, read them back, and issue the tokens your game client needs, with the server API.

View as Markdown

On this page

A player is someone who plays your game. Most games identify players by their own user id: GameCoin accepts it as ext:<your id> and creates the player the first time you write to it, so there is nothing to register in advance. A player id is the {player} of every path in this reference: see Referencing a player. The examples on this page continue from the setup.

Create or update a player

Creates the ext: player if it does not exist, otherwise updates the profile fields you send. Use it when a player signs up or changes their profile; you do not need it before a grant, a spend or a checkout, which create the player themselves.

PUT/players/{player}

Authentication: secret key. Idempotency: not needed: sending the same profile twice gives the same result.

Path parameters

ParameterTypeDescription
playerstringA GameCoin player id, or ext:<your id> URL-encoded once. A GameCoin id that does not exist answers 404.

Body (JSON; every field is optional, and an empty body means {})

FieldTypeRequiredRules
displayNamestring or nullnoName shown in your game: 1 to 80 characters once trimmed. null clears it.
emailstring or nullnoA valid e-mail address of at most 254 characters. Stored, never returned by the API. null clears it.
countrystring or nullnoISO 3166-1 alpha-2 code such as BE: two letters, upper-cased for you. It is the default country of the player's checkouts. null clears it.
birthYearinteger or nullnoA whole year between 1900 and the current year. Stored, never returned by the API. null clears it.

A field you leave out keeps its value; null erases it. Any other field is refused.

LangageLanguage
curl -X PUT "https://gamecoin.apilow.com/api/v1/players/ext%3Auser-42" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"displayName": "Alice", "country": "BE"}'

Response 200 OK: a Player. The status is 200 whether the player was created or updated.

JSON
{
  "id": "665f1c2e8a3b4d5e6f708192",
  "externalId": "user-42",
  "kind": "external",
  "displayName": "Alice",
  "country": "BE",
  "blocked": false,
  "createdAt": "2026-10-05T22:14:34.808Z"
}

Errors

StatusCodeWhenWhat to do
400VALIDATION_FAILEDAn unknown field; displayName empty or longer than 80 characters; email not an address; country not two letters; birthYear not a whole year in range; a player reference that is neither a GameCoin id nor an ext: reference (PLAYER_REF_INVALID); your own id empty, longer than 128 characters or with leading or trailing whitespaceRead details.fieldErrors, fix the field.
404NOT_FOUNDA GameCoin id that does not existUse ext:<your id>, which is created on the fly, or an id you got from GameCoin.
JSON
{
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "Invalid player profile",
    "details": { "fieldErrors": { "birthYear": ["Too small: expected number to be >=1900"] } }
  }
}

Notes

  • It is an upsert: the first call creates the player, later calls change the fields you send. To create a player with no profile, send {} or nothing.
  • To erase a field, send it as null: {"displayName": null}. An empty string is refused, not treated as null.
  • country is not checked against the list of countries. Checkouts only sell to European Union countries; a player with another country gets the default country BE unless you pass country to Order a currency pack.
  • The ext: id of a player is permanent: it is the key you will use in every later call.

Get a player

Returns one player. Use it to look a player up by your own id or by GameCoin id, and to check whether they are blocked.

GET/players/{player}

Authentication: secret key. Idempotency: not needed.

Path parameters

ParameterTypeDescription
playerstringA GameCoin player id, or ext:<your id> URL-encoded once.
LangageLanguage
curl "https://gamecoin.apilow.com/api/v1/players/ext%3Auser-42" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY"

Response 200 OK: a Player.

JSON
{
  "id": "665f1c2e8a3b4d5e6f708192",
  "externalId": "user-42",
  "kind": "external",
  "displayName": "Alice",
  "country": "BE",
  "blocked": false,
  "createdAt": "2026-10-05T22:14:34.808Z"
}

Errors

StatusCodeWhenWhat to do
400VALIDATION_FAILEDThe reference is neither a 24-character hexadecimal id nor an ext: reference, or it was URL-encoded twice (PLAYER_REF_INVALID)Encode the ext: reference exactly once.
404NOT_FOUNDThe player does not existFor an ext: player this is normal until your first write: create it with Create or update a player.
JSON
{ "error": { "code": "NOT_FOUND", "message": "Player not found" } }

Notes

  • A read never creates a player. Only writes do.
  • The same player by its GameCoin id (the id of the response) gives the same answer:
Bash
curl "https://gamecoin.apilow.com/api/v1/players/665f1c2e8a3b4d5e6f708192" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY"

Issue a player token

Issues a token that lets one player act on their own wallet and inventory from a browser or a game client, through the client API. Your backend calls it after it has authenticated the player, and hands the token to the client.

POST/players/{player}/tokens

Authentication: secret key. Idempotency: not needed: every call issues a new token. Body: none.

Path parameters

ParameterTypeDescription
playerstringA GameCoin player id, or ext:<your id> URL-encoded once. An unknown ext: player is created.
LangageLanguage
curl -X POST "https://gamecoin.apilow.com/api/v1/players/ext%3Auser-42/tokens" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY"

Response 200 OK: the token and its expiry.

FieldTypeDescription
tokenstringThe player token, gc_pt_…. An opaque string: do not parse it.
expiresAtstringISO 8601 date, one hour after issue.
JSON
{ "token": "gc_pt_…", "expiresAt": "2026-10-05T23:14:35.000Z" }

Errors

StatusCodeWhenWhat to do
400VALIDATION_FAILEDThe player reference is malformed (PLAYER_REF_INVALID)Encode the ext: reference exactly once.
403PLAYER_BLOCKEDThe player is blockedDo not hand out a token to this player.
404NOT_FOUNDA GameCoin id that does not existUse an existing id, or ext:<your id>.

Notes

  • The token is tied to one player, one game and one environment: it is refused on any other. It lasts one hour: issue a new one when it expires, or when the client gets a 401.
  • The client sends it as Authorization: Bearer gc_pt_… next to the publishable key, or gives it to the browser SDK as playerToken. See Players and tokens.
  • A token is a credential for that player: do not log it, and send it only over HTTPS. Issuing a new one does not revoke the previous ones, which stay valid until they expire.