Start Session

The Start Session endpoint is used to initiate a new game session for a player. This is essential for tracking player activity and engagement within the game. When a session is started, it allows the game to monitor the player’s playtime.

Endpoint

POST https://cratebytes.com/api/game/gameplay/start
authorization (header)
string
required

Bearer [token]

Example Response

{
    "statusCode": 201,
    "data": { "message": "Session Started" }
}
{
    "statusCode": 400,
    "error": {
        "message": "Session already active"
    }
}

Heartbeat

The Heartbeat endpoint is used to keep an active game session alive. This is crucial for ensuring that the session does not expire due to inactivity. By sending periodic heartbeat requests, the game can maintain the session’s active state and continue tracking the player’s playtime. A session will end after 10 minutes of inactivity, so it is recommended to send a heartbeat every 5 minutes.

Endpoint

POST https://cratebytes.com/api/game/gameplay/heartbeat
authorization (header)
string
required

Bearer [token]

Example Response

{
    "statusCode": 200,

    "data": { "message": "Heartbeat" }
}
{
    "statusCode": 403,
    "error": {
        "message": "Session has expired"
    }
}
{
    "statusCode": 404,
    "error": {
        "message": "No active session found"
    }
}

End Session

The End Session endpoint is used to terminate an active game session for a player. This is important for accurately tracking the total playtime of the player. When a session is ended, it stops the tracking of the player’s playtime and finalizes the session data.

Endpoint

POST https://cratebytes.com/api/game/gameplay/end
authorization (header)
string
required

Bearer [token]

Example Response

{
    "statusCode": 200,

    "data": {
        "message": "Session ended successfully",
        "sessionDuration": 325 // in seconds
    }
}
{
    "statusCode": 404,
    "error": {
        "message": "No active session found"
    }
}