Skip to content
FiveCord Docs

Gateway control

Gateway control is the Admin view of the running main Gateway cluster. It reads live node state and submits guild reload requests, and it exposes no session, presence, or call payload.

An unanswered Gateway request returns 504 GATEWAY_TIMEOUT. An overloaded or unavailable cluster returns 503 SERVICE_UNAVAILABLE. An invalid Gateway response returns 502 BAD_GATEWAY.

One snapshot of the Gateway cluster, taken across the nodes the request polled. Every top-level counter except uptime_seconds, node_count, and status is a plain sum over those nodes, including each member of memory. The nodes array reports each polled node on its own.

FieldTypeDescription
status1stringThe aggregate health of the cluster
sessionsintegerThe connected client Gateway sessions, summed across nodes
guildsintegerThe live guild processes, summed across nodes
presencesintegerThe tracked presences, summed across nodes
callsintegerThe live calls, summed across nodes
memorynode memory objectThe memory accounting, summed across nodes
process_countintegerThe Erlang processes in use, summed across nodes
process_limitintegerThe Erlang process ceiling, summed across nodes
uptime_seconds2integerThe lowest uptime any polled node reported, in seconds
node_count3integerThe number of nodes the request polled
nodes4array[gateway node object]The per-node breakdown (max 1000 entries)

1 healthy when every polled node reported healthy and degraded when at least one did not

2 The value tracks the most recently started node and drops back whenever any node restarts

3 Includes nodes that did not answer

4 Entries are ordered by node_id ascending. The node that served the request is always polled, so the array is never empty

{
"status": "healthy",
"sessions": 4820,
"guilds": 1913,
"presences": 4611,
"calls": 12,
"memory": {"total": "3221225472", "processes": "1610612736", "system": "1610612736"},
"process_count": 92114,
"process_limit": 2097152,
"uptime_seconds": 84213,
"node_count": 2,
"nodes": []
}

One entry for each node the request polled, including nodes that did not answer within the 10 second per-node deadline.

FieldTypeDescription
node_id1stringThe name the node reports for itself
status2stringThe health this node reported
sessionsintegerThe connected client Gateway sessions on this node
guildsintegerThe live guild processes on this node
presencesintegerThe tracked presences on this node
callsintegerThe live calls on this node
memorynode memory objectThe memory accounting for this node
process_countintegerThe Erlang processes in use on this node
process_limitintegerThe Erlang process ceiling on this node
uptime_secondsintegerThe seconds since this node started

1 A node reports its HOSTNAME environment value when that value is a non-blank string, and its Erlang node name otherwise

2 healthy for a node that answered and unavailable for one that did not. A node that did not answer reports null for every counter here and contributes zero to every cluster total

A node entry can have further diagnostic members. A client treats a member it does not recognise as absent.

Byte counts for one node, or for every polled node summed together. Each count is a decimal string because a JSON number cannot preserve a 64-bit byte count.

FieldTypeDescription
totalstringThe total bytes allocated
processesstringThe bytes allocated to Erlang processes
systemstringThe bytes allocated outside Erlang processes

Memory and activity for one live guild.

FieldTypeDescription
node_idstringThe node that owns the guild process
guild_id?snowflakeThe ID of the guild the process serves, or null when the process state has no guild ID
guild_name1stringThe guild name the process holds in memory
guild_icon?stringThe icon hash the guild process holds in memory, or null when it has none
nsfw_level2?integerThe NSFW level resolved from stored guild data, or null when the guild could not be resolved
memory3stringThe bytes the guild process uses, as a decimal string
member_countintegerThe number of members the guild process holds
session_countintegerThe number of sessions subscribed to the guild process
presence_countintegerThe number of presences the guild process tracks

1 A process whose cached guild data has no name reports Unknown

2 Null for a live process whose guild row could not be loaded and for a process that reports no guild_id

3 The Erlang process memory of the guild process. Entries are ordered by it descending across the whole cluster, with ties broken by guild_id ascending

Cluster voice state totals, with one grouping by voice region and one by voice server.

FieldTypeDescription
total_voice_states1integerThe voice states across the whole cluster
regions2array[region voice state count object]The counts grouped by voice region (max 1000 entries)
servers2array[server voice state count object]The counts grouped by voice server (max 5000 entries)

1 The sum of the totals each node reported, so it can differ from the sum of the entries in regions or servers

2 Entries are ordered by voice_state_count descending, with ties broken by identifier ascending. An identifier with no voice states is absent from the array, so every entry has a count of at least 1

{
"total_voice_states": 318,
"regions": [{"region_id": "europe-north", "voice_state_count": 204}],
"servers": [{"server_id": "europe-north-server-1", "voice_state_count": 204}]
}

One entry for each voice region that holds at least one voice state.

FieldTypeDescription
region_idstringThe ID of the region the count belongs to
voice_state_countintegerThe voice states attributed to the region

One entry for each voice server that holds at least one voice state.

FieldTypeDescription
server_id1stringThe ID of the server the count belongs to
voice_state_countintegerThe voice states attributed to the server

1 The identifier is unique only inside its region

GET/v1/admin/gateway/statsAudit reason

Returns the node statistics object for the whole Gateway cluster. Requires gateway:memory_stats.

StatusBodyCondition
200node statistics objectCluster state was returned

The operation records one Admin audit entry with action get_gateway_stats, target type gateway, target ID 0, and metadata key node_count.

200 requests per minute for each authenticated user, on the admin:lookup bucket.

GET/v1/admin/gateway/memory-statsAudit reason

Returns the heaviest live guild processes as guild memory statistics objects. Requires gateway:memory_stats.

FieldTypeDescription
limit?1integerThe maximum guild processes to return (100-1000, default 100)

1 The Gateway clamps the value it acts on to 500, and each node contributes at most 100 of its own guild processes. A limit of 1000 returns at most 500 entries

FieldTypeDescription
guildsarray[guild memory statistics object]The guild processes in this response (max 1000 entries)
StatusBodyCondition
200response bodyThe guild processes were returned

A node that does not answer within 5 seconds contributes no entries, and the request still returns 200.

The operation records one Admin audit entry with action list_guild_memory_stats, target type guild, target ID 0, and metadata keys limit and result_count for the entries in this response.

200 requests per minute for each authenticated user, on the admin:lookup bucket.

GET/v1/admin/gateway/voice-state-countsAudit reason

Returns the voice state count object. Requires gateway:memory_stats.

StatusBodyCondition
200voice state count objectCounts were returned

The counts cover voice states in guild channels and in calls. A node that does not answer within 10 seconds contributes zero, and the request still returns 200.

The operation records one Admin audit entry with action get_voice_state_counts, target type gateway, target ID 0, and metadata keys total_voice_states, region_count, and server_count.

200 requests per minute for each authenticated user, on the admin:lookup bucket.

POST/v1/admin/gateway/reloadsAudit reason

Fetches the guild data for the supplied guilds from the database again and sends it to each live guild process and returns how many live guild processes were selected. Requires gateway:reload_all.

FieldTypeDescription
guild_ids1array[snowflake]The guilds to reload (max 1000 entries)

1 The field is required. An empty array selects every live guild process on every active node

FieldTypeDescription
count1 2integerThe number of live guild processes selected for reload

1 A supplied guild with no live process is skipped, so the value can be lower than the number of IDs sent. An owner node that fails or does not answer within 15 seconds contributes zero

2 Taken when the processes are selected. A selected process whose guild data cannot be fetched is still counted, so the value is an upper bound on the reloads that succeeded

StatusBodyCondition
200response bodyFiveCord started a reload for every selected guild process

A guild whose owner node cannot be resolved is not counted. Reloads can still be in progress when the response arrives. No guild data is changed.

The operation records one Admin audit entry with action reload_guilds, target type guild, target ID 0, and metadata keys guild_count for the requested guilds and reloaded for the returned count.

5 requests per minute for each authenticated user, on the admin:gateway:reload bucket.