Skip to content

Session Management

Session management is at the core of the Gameye Session API. These endpoints allow you to create new game sessions, list active sessions, and stop sessions when they’re no longer needed.

To start a new game session, you’ll need to make a POST request to the /session endpoint.

POST /session

The request requires a JSON body with the following fields:

FieldTypeRequiredDescription
locationstringYesThe region where you want to host the session (e.g., “eu-west-1”, “eu-central-1”)
imagestringYesThe name of the game image to run in the container
idstringNoA unique identifier for the session. If omitted, the system will generate an RFC4122-compliant UUID
envobjectNoEnvironment variables to pass to the container
argsarrayNoCommand-line arguments to pass to the game server
restartbooleanNoWhether to automatically restart the session on failure
labelsobjectNoCustom metadata key-value pairs for the session
versionstringNoTag of the image to run (defaults to highest priority tag)
{
"location": "eu-central-1",
"image": "my-game-server",
"env": {
"MAX_PLAYERS": "16",
"MAP_ROTATION": "de_dust2,de_inferno,de_nuke"
},
"args": [
"--tickrate=128",
"--competitive=true"
],
"labels": {
"game_mode": "competitive",
"tournament_id": "spring_cup_2023"
},
"restart": false
}

On success, you’ll receive a 201 Created response with details about the new session:

{
"id": "c5c7c507-f5de-443e-b772-af4b444cfc21",
"host": "203.0.113.42",
"ports": [
{
"type": "tcp",
"container": 80,
"host": 25159
},
{
"type": "tcp",
"container": 80,
"host": 25160
}
]
}

Note: Host ports are now allocated from the dedicated range of 20000-30000 to prevent conflicts with the Linux kernel’s ephemeral port range, improving server startup reliability.

Status CodeDescription
401Unauthorized - Invalid bearer token
404Not Found - Requested location, image, or organization doesn’t exist
409Conflict - Session ID already exists
420Enhance Your Calm - Location temporarily unavailable or too many requests
422Unprocessable Entity - Invalid request syntax
{
"statusCode": 404,
"code": "RESOURCE_NOT_FOUND",
"message": "Unable to start session.",
"details": "Please make sure the correct image is specified.",
"identifier": "3bc545b7-4750-47e6-a918-c93debc58663",
"path": "/session",
"timestamp": "2023-04-01T12:00:00Z"
}

🔍 Tip: Always include the identifier when contacting support about errors. This helps us quickly trace the exact issue in our systems.

To get a list of your active sessions, use the GET request to the /session endpoint.

GET /session
ParameterTypeRequiredDescription
allbooleanNoWhether to return all sessions regardless of status (default: false, only returns running sessions)
filterobjectNoFilter sessions to include only those matching specific criteria (e.g., ?filter[tag]=v1.2.3)
filterNotobjectNoFilter sessions to exclude those matching specific criteria (e.g., ?filterNot[status]=exited)
  1. Include Filter (filter):
GET /session?filter[location]=eu-central-1&filter[tag]=latest
  1. Returns sessions matching ALL specified criteria.
  2. Exclude Filter (filterNot):
GET /session?filterNot[status]=exited&filterNot[tag]=beta
  1. Excludes sessions that match the specified criteria.
  2. Historical Sessions (all):
GET /session?all=true
  1. Include non-running sessions (like exited ones) in the results.

You can combine these filters for precise querying:

GET /session?all=true&filter[location]=eu-central-1&filterNot[status]=dead

This would return all sessions (including exited ones) in eu-central-1, excluding dead sessions.

{
"sessions": [
{
"id": "c595bc6f-8522-4a62-95cd-8742136643ea",
"image": "my-game-server",
"tag": "v1.2.3",
"location": "eu-central-1",
"host": "203.0.113.42",
"created": 1648472895000,
"port": {
"80/tcp": 25160
},
"status": "running",
"labels": {
"env": "{\"GAMEYE_SESSION_ID\":\"c595bc6f-8522-4a62-95cd-8742136643ea\",\"GAMEYE_HOST\":\"a.b.c.d\"}",
"tags": "{\"my-example-tag\":\"1\",\"another-example-tag\":\"3\"}"
}
}
]
}

When a game session is over, you can stop it using the DELETE request.

DELETE /session/{id}
ParameterTypeRequiredDescription
idstringYesThe unique ID of the session you want to stop

On success, you’ll receive a 204 No Content response, indicating the session was successfully terminated.

Status CodeDescription
401Unauthorized - Invalid bearer token
404Not Found - Session doesn’t exist
409Conflict - Session already terminated

A typical session lifecycle looks like this:

  1. Creation - You create a session with POST /session
  2. Running - The session runs until you stop it or it crashes
  3. Termination - You stop the session with DELETE /session/{id}
  4. Cleanup - You can download artifacts if needed

When listing sessions, the status field will be one of:

StatusDescription
createdSession container is created but not started
runningSession is running normally
restartingSession is restarting after a failure
exitedSession has exited (gracefully or by error)
deadSession container is dead/unresponsive
drainingHost is preparing to shut down, session will be migrated
shuttingdownSession is gracefully shutting down
server_unreachableCannot reach the server running this session
  • Let the system generate session IDs when possible
  • Use labels to organize and filter your sessions
  • Always stop sessions when they’re no longer needed to free up resources
  • Check session status before performing operations on them
  • Use the combined filtering capabilities to efficiently manage many sessions