Dev Save Points Example

Saving Player Points with devBatchSavePoints

Once you've registered your game and obtained a gameApiKey, you can save player points to the play.fun platform. Like other protected endpoints, this request requires an HMAC signature. See API Reference - Authentication for the full signing spec.

The devBatchSavePoints endpoint lets you batch save player points in the context of your game. At minimum, you must provide:

  • gameApiKey – Your game owner/creator API key (UUID).

  • points – An array of objects containing a playerId and points value.

Player ID Formats

The playerId field accepts multiple formats:

Format
Example
Description

Solana wallet

sol:9qdvVLY3v...

Looks up/creates user by Solana address

Ethereum wallet

eth:0x123...

Looks up/creates user by ETH address

Email

Looks up/creates user by email

Twitter/X

twitter:username or x:username

Looks up/creates user by Twitter/X handle

Privy ID

did:privy:abc123

Direct Privy user ID

OGP User ID (UUID)

550e8400-e29b-41d4-...

Raw internal user ID (fastest)

Understanding the playerIdToOgpId Response

Every successful response includes a playerIdToOgpId object that maps each input identifier you sent to the player's internal OGP user UUID:

{
  "savedCount": 3,
  "playerIdToOgpId": {
    "sol:9qdvVLY3vLhmvV7uBkLJsQKcHDjxhoUWJ9uZASYEfwwC": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "email:[email protected]": "e5f6g7h8-i9j0-1234-klmn-opqrstuvwxyz",
    "550e8400-e29b-41d4-a716-446655440000": "550e8400-e29b-41d4-a716-446655440000"
  },
  "message": "For higher throughput on existing players, please store and use the known playerId => ogpId mappings in subsequent requests."
}

Why this matters: When you use identifiers like sol: or email:, the server must resolve them to an internal user on every request. This adds latency and external API calls. By caching the returned OGP UUIDs and using them directly in future requests, you skip that resolution entirely.

circle-info

Note that if a raw OGP UUID is passed, it maps to itself (no resolution needed). This is the fastest path — always prefer using cached OGP UUIDs for repeat players.

JavaScript Example

Using the Server SDK

If you're using Node.js, the @playdotfun/server-sdk handles HMAC signing automatically:

Last updated