Examples
Sending custom game event data to the Playfull platform using the REST API. It demonstrates how to structure requests for tracking in-game actions such as scores, NPC kills, and match results, helping developers integrate event reporting for analytics, rewards, and mission tracking.
Track game score
This example shows how to send a custom event when a game ends and a score is recorded.
[CLIENT_ID]
: Unique identifier for the client application, provided by Playfull[GAME_ID]
: Unique identifier for the game sending the event, provided by Playfull[GENERATED_SIGNATURE]
: A signature that verifies the integrity of the request (see Signature Generation)[USER_ID]
: The game's own internal user identifier
POST /v2/custom-events
x-client-id: "[CLIENT_ID]",
x-timestamp: "1698306156387",
x-signature: "[GENERATED_SIGNATURE]",
Content-Type: "application/json"
{
"gameId": "[GAME_ID]",
"events": [
{"userId": "[USER_ID]", "event": "GAME_OVER", "value": 1000, "time": "2023-10-24T03:42:12.650Z"},
],
}
NPC Kills
This example demonstrates sending a custom event when a player kills a non-player character (NPC) in the game.
[CLIENT_ID]
: Unique identifier for the client application, provided by Playfull[GAME_ID]
: Unique identifier for the game sending the event, provided by Playfull[GENERATED_SIGNATURE]
: A signature that verifies the integrity of the request (see Signature Generation)[USER_ID_*]
: The game's own internal user identifiers for each player in the match
POST /v2/custom-events
x-client-id: "[CLIENT_ID]",
x-timestamp: "1698306156387",
x-signature: "[GENERATED_SIGNATURE]",
Content-Type: "application/json"
{
"gameId": "[GAME_ID]",
"events": [
{"userId": "[USER_ID_1]", "event": "KILL_NPC", "traits": {"weapon": "BASEBALL_BAT", "type": "ZOMBIE"}, "time": "2023-10-24T03:45:00.000Z"},
],
}
Match Ended
This example shows how to send a custom event when a match has ended, including the status of each player in the match.
[CLIENT_ID]
: Unique identifier for the client application, provided by Playfull[GAME_ID]
: Unique identifier for the game sending the event, provided by Playfull[GENERATED_SIGNATURE]
: A signature that verifies the integrity of the request (see Signature Generation)[USER_ID_*]
: The game's own internal user identifiers for each player in the match[GROUP_ID]
: The game's own internal identifier of the match
POST /v2/custom-events
x-client-id: "[CLIENT_ID]",
x-timestamp: "1698306156387",
x-signature: "[GENERATED_SIGNATURE]",
Content-Type: "application/json"
{
"gameId": "[GAME_ID]",
"events": [
{"groupId": "[GROUP_ID]", "userId": "[USER_ID_1]", "event": "MATCH_END", "traits": {"isSurvivor": true}, "time": "2023-10-24T03:49:00.000Z"},
{"groupId": "[GROUP_ID]", "userId": "[USER_ID_2]", "event": "MATCH_END", "traits": {"isSurvivor": false}, "time": "2023-10-24T03:49:00.000Z"},
{"groupId": "[GROUP_ID]", "userId": "[USER_ID_3]", "event": "MATCH_END", "traits": {"isSurvivor": false}, "time": "2023-10-24T03:49:00.000Z"},
],
}