Skip to content

Studio, admin and relay API

These endpoints are for the studio, not for agents. Agents use the MCP endpoint (/mcp) with an OAuth bearer token. Everything under /v1/studio is signed with the same HMAC-SHA256 scheme the gateway uses toward the backend (see docs/PROTOCOL.md). The signed X-AG-Player header is the player (or, for admin calls, the acting admin). Every response to a signed call carries Cache-Control: no-store.

The same API as an OpenAPI 3.1 file: studio.yaml. This page is generated from it.

studioSignature. HMAC-SHA256 request signing with the studio key. The five headers X-AG-Key-Id, X-AG-Timestamp, X-AG-Player, X-AG-Idempotency-Key and X-AG-Signature are all required. The signed string and the verifier rules are in docs/PROTOCOL.md. The timestamp must be within 5 minutes, and each (key id, idempotency key) pair is accepted once. Go callers can use pkg/agentsig.

adminSignature. The same scheme, signed with the admin key (--admin-key-id, secret GAMEWARDEN_ADMIN_SECRET), which must differ from the studio key. X-AG-Player names the acting admin.

Headers on every signed call:

Header Meaning
X-AG-Key-Id Which shared secret signed the request (supports rotation).
X-AG-Timestamp Unix seconds when the request was signed.
X-AG-Player The player the call is for. For admin calls, the acting admin.
X-AG-Idempotency-Key Unique per request. A repeated pair of key id and idempotency key is refused as a replay.
X-AG-Signature Lowercase hex HMAC-SHA256 of the signed string.

Let a player link an agent, and let the game show and revoke linked agents. Signed with the studio key.

Mint a link ticket for a player. The game shows the returned code to a logged in player. The player types it on the consent page to link an agent. A ticket is single use and valid for 5 minutes. The signed X-AG-Player is the player the ticket belongs to.

Auth: studioSignature.

Status Meaning Body
201 The ticket. Ticket
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
413 The body is over the endpoint’s limit. Error, error too_large
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"ticket": "K7QF-9M2X",
"expires_at": "2026-01-02T03:09:05Z"
}

List the player’s linked agents. Lists the player’s active grants, oldest first. client_name is empty if the client is gone.

Auth: studioSignature.

Status Meaning Body
200 The grants. object
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"grants": [
{
"id": "9f2c0a",
"client_id": "c1",
"client_name": "Claude on the laptop",
"scope": "operator",
"resource": "https://gw.example/mcp",
"created_at": "2026-01-02T03:04:05Z"
}
]
}

Revoke all of the player’s grants. A “log out all agents” button. Repeating it returns {"revoked":0}.

Auth: studioSignature.

Status Meaning Body
200 How many grants were revoked. object
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"revoked": 2
}

Revoke one grant. Revokes the grant and every token of it, effective on the next token lookup. A grant that does not exist, is already revoked or belongs to another player gives the same 404, so ids cannot be probed.

Auth: studioSignature.

Parameter In Type Required Meaning
id path string yes The grant id from the list.
Status Meaning Body
204 Revoked.
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
404 Does not exist, expired, or belongs to someone else. The three look the same so ids cannot be probed. Error, error not_found
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

The player approves or denies a pending action in the game’s own UI. Signed with the studio key.

List the player’s pending confirmations. Live pending confirmations, oldest first. The list is empty when there are none.

Auth: studioSignature.

Status Meaning Body
200 The confirmations. object
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"confirmations": [
{
"id": "3f1a77",
"tool": "build_structure",
"state": "pending",
"created_at": "2026-01-02T03:04:05Z",
"expires_at": "2026-01-02T03:14:05Z",
"args_sha256": "9b7e00"
}
]
}

POST /v1/studio/confirmations/{id}/approve

Section titled “POST /v1/studio/confirmations/{id}/approve”

Approve a pending confirmation. Idempotent: approving an approved confirmation is also 204. The approval stays bound to one exact tool call and expires with the confirmation (10 minutes). A confirmation that does not exist, has expired or belongs to another player gives 404.

Auth: studioSignature.

Parameter In Type Required Meaning
id path string yes The confirmation id.
Status Meaning Body
204 Approved.
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
404 Does not exist, expired, or belongs to someone else. The three look the same so ids cannot be probed. Error, error not_found
409 The confirmation cannot make that move, for example approving a denied one. Error, error wrong_state
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Deny a pending confirmation. Idempotent: denying a denied confirmation is also 204.

Auth: studioSignature.

Parameter In Type Required Meaning
id path string yes The confirmation id.
Status Meaning Body
204 Denied.
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
404 Does not exist, expired, or belongs to someone else. The three look the same so ids cannot be probed. Error, error not_found
409 The confirmation cannot make that move, for example approving a denied one. Error, error wrong_state
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Upload, read and roll back the tool manifest. Signed with the admin key.

Upload and activate a manifest. Validates the body, stores it as a new version, activates it and serves it from the next request on. An invalid manifest changes nothing. Other replicas pick the new version up within --manifest-poll. X-AG-Player names the acting admin and is recorded as the version’s actor. Not mounted unless an admin key is configured.

Auth: adminSignature.

Request body (application/json, application/yaml): The manifest, at most 1 MiB. JSON, or YAML with Content-Type of application/yaml.

Status Meaning Body
201 The new, active version. ManifestVersion
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
413 The body is over the endpoint’s limit. Error, error too_large
422 The manifest failed validation. Nothing changed. Error, error invalid_manifest
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"id": 3,
"sha256": "ab12cd",
"actor": "ci",
"created_at": "2026-01-02T03:04:05Z",
"tools": 12,
"active": true
}

Read the active manifest.

Auth: adminSignature.

Status Meaning Body
200 The active version and its manifest. object
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
404 Does not exist, expired, or belongs to someone else. The three look the same so ids cannot be probed. Error, error not_found
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

List manifest versions. All versions, newest first. Exactly one has active set.

Auth: adminSignature.

Status Meaning Body
200 The versions. object
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

POST /v1/studio/manifest/versions/{id}/activate

Section titled “POST /v1/studio/manifest/versions/{id}/activate”

Roll back (or forward) to a version. Makes an existing version active again. The stored document is validated again with the current rules. If it no longer passes the answer is 422 and nothing changes.

Auth: adminSignature.

Parameter In Type Required Meaning
id path integer (int64) yes The version id.
Status Meaning Body
200 The version, now active. ManifestVersion
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
404 Does not exist, expired, or belongs to someone else. The three look the same so ids cannot be probed. Error, error not_found
422 The manifest failed validation. Nothing changed. Error, error invalid_manifest
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Turn a tool, a player or the whole game off and on during an incident. Signed with the admin key.

List the switches that are on. Signed with the admin key. Not mounted unless an admin key is configured.

Auth: adminSignature.

Status Meaning Body
200 The switches that are on, ordered by tenant, tool, player. object
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"switches": [
{
"tenant": "tinycity",
"tool": "build_structure"
}
]
}

Turn a switch on. Blocks every tier the switch matches, reads included, from the next call on. Turning on a switch that is already on is not an error. With no tool and no player the whole game is switched off. The tenant is always the gateway’s own. X-AG-Player names the acting admin and is recorded in an audit event (tool admin.switch.on). The reason is logged, not stored in the audit event.

Auth: adminSignature.

Request body (application/json): What to switch. An empty body switches the whole game. At most 4 KiB.

Field Type Required Meaning
tool string no A tool name. Omit for every tool.
player string no Printable ASCII, no spaces. Omit for every player.
reason string no Free text for the logs. Not stored in the audit event.
Status Meaning Body
200 The switch and its new state. SwitchResult
400 A query parameter is malformed. Error, error invalid_request
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
413 The body is over the endpoint’s limit. Error, error too_large
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"switch": {
"tenant": "tinycity",
"tool": "build_structure"
},
"on": true
}

Turn a switch off. Same body as turning one on. Turning off a switch that is not on is not an error. Recorded in an audit event (tool admin.switch.off).

Auth: adminSignature.

Request body (application/json): What to switch back on. An empty body clears the whole-game switch.

Field Type Required Meaning
tool string no A tool name. Omit for every tool.
player string no Printable ASCII, no spaces. Omit for every player.
reason string no Free text for the logs. Not stored in the audit event.
Status Meaning Body
200 The switch and its new state. SwitchResult
400 A query parameter is malformed. Error, error invalid_request
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
413 The body is over the endpoint’s limit. Error, error too_large
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"switch": {
"tenant": "tinycity",
"tool": "build_structure"
},
"on": false
}

What a player’s agents did, read from the audit log.

The player feed. What the signed player’s agents did, newest first. Sign it with the studio key. A player or tenant query parameter is ignored, so a player can only read their own events. When more remain, next_before is the value to pass as before for the next page.

Auth: studioSignature.

Parameter In Type Required Meaning
tool query string no Only events of this tool.
outcome query string: ok, denied, error no Only events with this outcome.
since query string (date-time) no Only events at or after this time (RFC 3339).
limit query integer no Page size. Default 50, at most 200, larger values are clamped.
before query integer (int64) no A cursor: only events with a smaller id. Use next_before from the previous page.
Status Meaning Body
200 A page of events. Feed
400 A query parameter is malformed. Error, error invalid_request
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"events": [
{
"id": 42,
"time": "2026-03-01T10:05:00Z",
"tool": "sell_resource",
"tier": "medium",
"outcome": "denied",
"code": "daily_amount_cap",
"args_sha256": "9f2c00"
}
],
"next_before": 41
}

The admin feed. Events of any player of the gateway’s tenant. Sign it with the admin key. X-AG-Player is the acting admin and is not a filter, use the player query parameter for that. Rows name the player.

Auth: adminSignature.

Parameter In Type Required Meaning
player query string no Only this player’s events.
tool query string no Only events of this tool.
outcome query string: ok, denied, error no Only events with this outcome.
since query string (date-time) no Only events at or after this time (RFC 3339).
limit query integer no Page size. Default 50, at most 200, larger values are clamped.
before query integer (int64) no A cursor: only events with a smaller id. Use next_before from the previous page.
Status Meaning Body
200 A page of events. Feed
400 A query parameter is malformed. Error, error invalid_request
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Connect a game client that holds its own game state.

Mint a relay ticket for a player’s game client. The studio backend hands the ticket to the game client, which opens the WebSocket with it. The signed X-AG-Player is the player. The ticket is signed with the relay secret and valid for --relay-ticket-ttl (60 seconds by default). It can be reused until it expires, and a newer socket for the same player replaces the older one. Not mounted unless GAMEWARDEN_RELAY_SECRET is set.

Auth: studioSignature.

Status Meaning Body
201 The ticket. RelayTicket
401 The signature is missing, wrong, stale, or the signed request was already used. Error, error invalid_client
413 The body is over the endpoint’s limit. Error, error too_large
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

Example response:

{
"ticket": "eyJ0Ijoi",
"expires_at": "2026-01-02T03:05:05Z"
}

Open the game client’s WebSocket. A WebSocket upgrade. The ticket is checked before the upgrade. One socket per player: a new connection closes the old one with close code 4000. After the upgrade the gateway sends {"type":"hello","protocol":1} and then call frames. The client answers each with a result frame, see the relay section of docs/PROTOCOL.md.

Auth: relayTicket.

Parameter In Type Required Meaning
ticket query string no The ticket, for clients that cannot set a header. The header wins when both are given.
Status Meaning Body
101 Switching protocols. The socket is open.
401 The ticket is missing, tampered with or expired. Error, error invalid_ticket

The embedded OAuth 2.1 authorization server that agents use to link. Agents and MCP clients call these, not the studio.

GET /.well-known/oauth-authorization-server

Section titled “GET /.well-known/oauth-authorization-server”

Authorization server metadata (RFC 8414). An MCP client finds the rest from here. The protected resource metadata at /.well-known/oauth-protected-resource/mcp is served next to the MCP endpoint.

Auth: none.

Status Meaning Body
200 The metadata. object

Dynamic client registration (RFC 7591). Registers a public client. Rate limited per client address (--register-per-hour), and the number of clients is capped (--max-clients).

Auth: none.

Request body (application/json):

Field Type Required Meaning
client_name string yes
redirect_uris array of string yes
Status Meaning Body
201 The registered client. object
400 invalid_client_metadata or invalid_redirect_uri. Error
429 Too many registrations from this address. Retry-After says when. Error
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable

The consent page. Shows the consent page where the player enters the link code and picks coach or operator. Needs PKCE S256 and response_type=code. Errors are shown on the page or redirected to a verified redirect URI.

Auth: none.

Parameter In Type Required Meaning
response_type query string yes Must be code.
client_id query string yes
redirect_uri query string yes
code_challenge query string yes The S256 challenge.
code_challenge_method query string yes Must be S256.
state query string no
scope query string no Space separated, coach or operator.
resource query string no The MCP resource URL the token is bound to.
Status Meaning Body
200 The consent page (HTML).
400 The request is invalid (HTML or a redirect with an error).

Submit the consent page. The player allows or denies, with a link code. Wrong, used and expired codes look the same. Every submission counts against a per-address limit.

Auth: none.

Request body (application/x-www-form-urlencoded):

Field Type Required Meaning
decision string yes allow to grant, anything else denies.
scope_choice string no coach or operator.
ticket string no The link code from the game.
Status Meaning Body
302 Redirect to the client’s redirect URI with a code (or an error).
401 The link code did not work (HTML).
429 Too many attempts (HTML). Retry-After says when.

Start sign-in with the studio’s identity provider. The consent page’s “Sign in with your game account” button. The form carries the same authorization parameters as POST /authorize plus scope_choice. The gateway validates them, stores them in an encrypted session cookie, and redirects to the identity provider (authorization code with PKCE, state and nonce). Answers 404 when the gateway has no identity provider configured. See docs/design/oidc-consent.md.

Auth: none.

Request body (application/x-www-form-urlencoded):

Field Type Required Meaning
client_id string yes
redirect_uri string yes
response_type string no
code_challenge string yes
code_challenge_method string yes
state string no
resource string no
scope string no
scope_choice string yes coach or operator.
Status Meaning Body
303 Redirect to the identity provider, with the session cookie set.
400 The request is invalid (HTML). Nothing is redirected.
404 No identity provider is configured.
429 Too many attempts (HTML). Retry-After says when.
503 The identity provider could not be reached (HTML).

Where the identity provider sends the player back. Register this URL, on the gateway’s public address, as the redirect URI at the identity provider. It needs the session cookie set by POST /authorize/oidc, a matching state, and a code the gateway can exchange for an ID token that verifies (signature, issuer, audience, nonce, expiry). On success it records the grant for the player named by the configured claim and redirects to the client’s redirect URI with a code. A failure after the session is known redirects there with error; a missing, expired or replayed session shows an error page and redirects nowhere.

Auth: none.

Parameter In Type Required Meaning
state query string yes
code query string no
error query string no Set by the identity provider when the player refused.
iss query string no RFC 9207 issuer, checked when present.
Status Meaning Body
303 Redirect to the client’s redirect URI with a code or an error.
400 No trustworthy session: nothing is redirected (HTML).
404 No identity provider is configured.
429 Too many attempts.

Exchange a code or refresh a token. authorization_code exchanges the code with the PKCE verifier. refresh_token rotates the refresh token. Reusing a rotated refresh token revokes the grant. Access tokens are opaque.

Auth: none.

Request body (application/x-www-form-urlencoded):

Field Type Required Meaning
grant_type string yes authorization_code or refresh_token.
client_id string yes
code string no
redirect_uri string no
code_verifier string no
resource string no
refresh_token string no
Status Meaning Body
200 The tokens. Token
400 invalid_request, invalid_grant or unsupported_grant_type. Error
503 A store failed or the replay cache is full. Nothing changed. Retry with a new idempotency key. Error, error temporarily_unavailable
Field Type Required Meaning
error string yes A short code, see the errors reference.
error_description string no Added by the OAuth endpoints and the link ticket endpoint.
detail string no Added to invalid_manifest. Lists every problem.
Field Type Required Meaning
ticket string yes The code the player types on the consent page.
expires_at string (date-time) yes
Field Type Required Meaning
ticket string yes Opaque signed ticket.
expires_at string (date-time) yes
Field Type Required Meaning
id string yes
client_id string yes
client_name string no Empty if the client is gone.
scope string: coach, operator yes
resource string yes The MCP resource the grant is bound to.
created_at string (date-time) yes
Field Type Required Meaning
id string yes
tool string yes
state string yes The confirmation’s state, pending while it waits for the player.
created_at string (date-time) yes
expires_at string (date-time) yes
args_sha256 string yes Hex SHA-256 of the validated arguments with keys sorted. Not for display: the gateway stores only the hash.
Field Type Required Meaning
tenant string no
tool string no Empty means every tool.
player string no Empty means every player.
Field Type Required Meaning
tool string no A tool name. Omit for every tool.
player string no Printable ASCII, no spaces. Omit for every player.
reason string no Free text for the logs. Not stored in the audit event.
Field Type Required Meaning
switch Switch yes
on boolean yes
Field Type Required Meaning
id integer (int64) yes
sha256 string yes Of the canonical JSON document.
actor string yes Who uploaded it (the signed X-AG-Player of the admin call).
created_at string (date-time) yes
tools integer yes Number of tools.
active boolean yes
Field Type Required Meaning
id integer (int64) yes
time string (date-time) yes
player string no Admin feed only.
tool string yes
tier string yes
outcome string: ok, denied, error yes
code string no The result code of a denial or error.
args_sha256 string yes Hex SHA-256 of the validated arguments. The arguments are never stored.
Field Type Required Meaning
events array of FeedEvent yes
next_before integer (int64) no Pass as before for the next page. Omitted on the last page.
Field Type Required Meaning
access_token string yes
token_type string: Bearer yes
expires_in integer yes Seconds.
refresh_token string yes
scope string: coach, operator yes