Game Servers API
Complete reference for game server endpoints, SDK methods, params, and response shapes
Overview
The Game Servers API lets you list, get, create, update, and delete game servers. All endpoints are organization-scoped.
Scope
All endpoints are organization-scoped. You only see and manage servers owned by your organization.
Base route
| Base path | Description |
|---|---|
/v1/game-servers | All game server endpoints |
list()
List game servers with optional pagination and filters.
HTTP API
| Method | Path | Description |
|---|---|---|
GET | /v1/game-servers | List game servers |
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
page | number | No | Page number (1-indexed). Default 1. |
pageSize | number | No | Items per page. Default 20. |
includeDeleted | boolean | No | Include soft-deleted servers. |
onlyDeleted | boolean | No | Return only soft-deleted servers. |
Headers: Authorization: Bearer <your-api-key>
Example (cURL)
curl -X GET "https://api.sweathost.com/v1/game-servers?page=1&pageSize=20" \
-H "Authorization: Bearer YOUR_API_KEY"SDK
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
params | object | No | page, pageSize, includeDeleted, onlyDeleted. |
options | RequestOptions | No | Optional request config. |
Return type: Promise<ListGameServersResponse<GameServer['configuration']>>
Example
const response = await client.gameServers.list();
console.log(`Found ${response.total} servers`);
const page2 = await client.gameServers.list({ page: 2, pageSize: 50 });Response structure
ListGameServersResponse: { page, pageSize, total, items }. Each item is GameServer:
| Field | Type | Description |
|---|---|---|
id | string | Unique server ID. |
name | string | Server name. |
gameType | string | e.g. cs2. |
region | string | Region code. |
organizationId | string | Organization ID. |
status | string | running, stopped, pending, allocating, starting, provisioning, failed, error. |
queuedAt | string | null | When server was queued (if no capacity at creation). |
allocationAttempts | number | Number of allocation attempts (for queued servers). |
lastAllocationError | string | null | Last error message if allocation failed. |
ip | string | null | Public IP when running. |
port | number | null | Game port when running. |
connectUrl | string | null | Full connect URL when running. |
additionalPorts | Record<string, number> | null | e.g. rcon, sourcetv. |
rconPassword | string | null | RCON password. |
serverPassword | string | null | Server password. |
configuration | object | Game-specific config (e.g. CS2). |
autoStop | boolean | Auto-stop enabled. |
autostopMinutes | number | Minutes idle before auto-stop. |
createdAt | string | ISO 8601. |
updatedAt | string | ISO 8601. |
deletedAt | string | null | Soft-delete timestamp. |
deletedBy | string | null | Soft-delete actor. |
get()
Get a single game server by ID.
HTTP API
| Method | Path | Description |
|---|---|---|
GET | /v1/game-servers/:id | Get server by ID |
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Server ID. |
Headers: Authorization: Bearer <your-api-key>
Example (cURL)
curl -X GET "https://api.sweathost.com/v1/game-servers/SERVER_ID" \
-H "Authorization: Bearer YOUR_API_KEY"SDK
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Server ID. |
options | RequestOptions | No | Optional request config. |
Return type: Promise<GameServer>
Example
const server = await client.gameServers.get('server_abc123');
console.log(`${server.name}: ${server.ip}:${server.port}`);
console.log(`Status: ${server.status}`);getStatus()
Get lightweight server status for polling. Use this when you have pending servers and want to check allocation progress without fetching the full server object.
HTTP API
| Method | Path | Description |
|---|---|---|
GET | /v1/game-servers/:id/status | Get server status |
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Server ID. |
Response: { id, status, ip?, port?, lastError?, queuedAt?, updatedAt }
SDK
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Server ID. |
options | RequestOptions | No | Optional request config. |
Return type: Promise<ServerStatusResponse>
Example
const status = await client.gameServers.getStatus('server_abc123');
if (status.status === 'running') {
console.log(`Ready: ${status.ip}:${status.port}`);
} else if (status.status === 'failed') {
console.error(`Failed: ${status.lastError}`);
}waitForServer()
Poll until a server reaches running or failed. Useful when create() returns pending and you want to block until the server is ready.
SDK only (no direct HTTP equivalent)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Server ID. |
pollIntervalMs | number | No | Poll interval in ms. Default 5000. |
options | RequestOptions | No | Optional request config. |
Return type: Promise<GameServer>
Throws: Error if server reaches failed status.
Example
const server = await client.gameServers.create({ /* ... */ });
if (server.status === 'pending') {
const ready = await client.gameServers.waitForServer(server.id, 5000);
console.log(`Server ready: ${ready.ip}:${ready.port}`);
}create()
Create a new game server. The API tries immediate allocation; if no capacity is available, the server is queued for background provisioning and returns with status: 'pending'.
Provisioning flow
- Immediate success: If capacity is available, the server is allocated and returns with
status: 'running'. - Queued: If no capacity, the server is created with
status: 'pending'and processed by a background job (every 30 seconds). You'll receive the server object immediately; pollget()orgetStatus()for updates. - Failed: After 3 allocation attempts, the server is marked
status: 'failed'withlastAllocationErrorset.
No more 503 errors
When no capacity is available, the API now returns 200 with status: 'pending' instead of throwing 503. Your server is queued and will be allocated when capacity becomes available.
HTTP API
| Method | Path | Description |
|---|---|---|
POST | /v1/game-servers | Create server |
Headers: Authorization: Bearer <your-api-key>, Content-Type: application/json
Request body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Server name. |
gameType | string | Yes | e.g. cs2. |
region | string | Yes | Region code (e.g. AWS region). |
configuration | object | Yes | Game-specific config (e.g. CS2). |
autoStop | boolean | No | Enable auto-stop. |
autostopMinutes | number | No | Idle minutes before auto-stop. |
organizationId | string | No | Omitted in SDK; inferred from API key. |
Example (cURL)
curl -X POST "https://api.sweathost.com/v1/game-servers" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"My CS2 Server","gameType":"cs2","region":"us-east-1","configuration":{...}}'SDK
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
dto | CreateGameServerDto | Yes | Name, gameType, region, configuration, optional autoStop/autostopMinutes. |
options | RequestOptions & { wait?: boolean; pollInterval?: number } | No | Optional request config. wait: true blocks until server is running or failed. pollInterval (ms) for polling when waiting. |
Return type: Promise<GameServer>
Example (async mode – default)
const server = await client.gameServers.create({
name: 'My CS2 Server',
gameType: 'cs2',
region: 'us-east-1',
configuration: {
gameMode: 'competitive',
maxPlayers: 10,
tickrate: 128,
rconPassword: 'secure-rcon',
enableVAC: true,
mapPool: ['de_dust2', 'de_mirage'],
startingMap: 'de_dust2',
enableBots: false,
tournamentMode: true,
warmupTime: 60,
freezeTime: 15,
roundTime: 115,
bombTimer: 40,
buyTime: 20,
},
});
if (server.status === 'pending' || server.status === 'allocating') {
const ready = await client.gameServers.waitForServer(server.id, 5000);
console.log(`Ready: ${ready.ip}:${ready.port}`);
} else {
console.log(`Created: ${server.id} at ${server.ip}:${server.port}`);
}Example (blocking mode)
const server = await client.gameServers.create(
{ name: 'My Server', gameType: 'cs2', region: 'us-east-1', configuration: { /* ... */ } },
{ wait: true, pollInterval: 5000 }
);
console.log(`Ready: ${server.ip}:${server.port}`);CS2 configuration (Cs2ServerConfiguration): gameMode, maxPlayers, tickrate, serverPassword?, rconPassword, enableVAC, mapPool, startingMap, enableBots, botDifficulty, tournamentMode, warmupTime, freezeTime, roundTime, bombTimer, buyTime, customCvars?.
update()
Update an existing game server.
HTTP API
| Method | Path | Description |
|---|---|---|
PATCH | /v1/game-servers/:id | Update server |
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Server ID. |
Request body: Partial { name?, configuration?, autoStop?, autostopMinutes? }.
Headers: Authorization: Bearer <your-api-key>, Content-Type: application/json
Example (cURL)
curl -X PATCH "https://api.sweathost.com/v1/game-servers/SERVER_ID" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Updated Name","configuration":{...}}'SDK
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Server ID. |
dto | UpdateGameServerDto | Yes | Partial: name, configuration, autoStop, autostopMinutes. |
options | RequestOptions | No | Optional request config. |
Return type: Promise<GameServer>
Example
const server = await client.gameServers.update('server_abc123', {
name: 'Updated Server Name',
configuration: { maxPlayers: 12 },
});delete()
Delete (soft-delete) a game server.
HTTP API
| Method | Path | Description |
|---|---|---|
DELETE | /v1/game-servers/:id | Delete server |
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Server ID. |
Headers: Authorization: Bearer <your-api-key>
Example (cURL)
curl -X DELETE "https://api.sweathost.com/v1/game-servers/SERVER_ID" \
-H "Authorization: Bearer YOUR_API_KEY"SDK
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Server ID. |
options | RequestOptions | No | Optional request config. |
Return type: Promise<{ ok: true }>
Example
await client.gameServers.delete('server_abc123');events (HTTP only)
Poll for server provisioning events (e.g. when a queued server becomes ready). Used by the dashboard for in-app notifications.
| Method | Path | Description |
|---|---|---|
GET | /v1/game-servers/events | List recent provisioning events |
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
since | string | No | ISO 8601 timestamp. Return events after this time. Default: last 1 minute. |
Response: { events: [{ id, serverId, eventType, eventData, createdAt }] }
Event types: provisioning_completed, provisioning_failed
Errors
| HTTP | Code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Invalid or missing API key. |
| 403 | FORBIDDEN | No access to this server. |
| 404 | NOT_FOUND | Server not found. |
| 400 | INVALID_PARAMS | Invalid request body or query. |
Note: When no capacity is available, create() returns 200 with status: 'pending' instead of 503. The server is queued for background allocation.
Ensure your API key has the appropriate scopes for game server management.