Skip to content
Last updated December 3, 2026

Management API

PromptGate’s own state and changes over plain HTTP and JSON — for scripts, CI jobs and dashboards that don’t speak MCP. It serves the same tools as the MCP control tools, with the same rule: a pg_ key with control: read reads, one with control: write also changes. Every field of every answer: resources and actions, generated from the API itself; as OpenAPI 3.1 at GET /control/v1/openapi.json.

resource what it answers parameters
GET /control/v1 the resources with their paths —
stats requests, errors, p50/p95 latency, tokens, cost since (1h, 24h default, 7d), by (provider, model, key, endpoint, server, tool, api, method), surface (ai, mcp, api)
logs recent requests, newest first, in pages limit (≤ 100), before, since, provider, model, key, endpoint, status (429, 5xx), surface
budgets spend against every budget, today and this month —
anomalies endpoint anomalies the gateway recorded since (default 24h)
config the running config without secrets: providers (whether a key is set, never the key), aliases, MCP servers, limits, budgets, guardrails, mounts —
endpoints AI Gateway endpoints with model, input, version, state —
keys keys with their restrictions — never secrets or hashes —
apis the API Gateway’s APIs — never header values —
oauth-connections OAuth connections: state, expiry, why a reconnect is needed — never tokens —
webhooks webhooks: state, queue, deliveries in the last 24 h — URLs without credentials —
webhook-deliveries deliveries, newest first, in pages; one with its event webhook, state, limit, before, id
audit the audit trail, newest first, in pages since, actor, action (key.*), limit, before

| actions (POST, control: write) | | | | key-create, key-rotate | a new key, or a new secret for one — returned once | name, restrictions | | key-disable, key-enable | revoke or restore a key (a key can’t revoke itself) | name | | endpoint-disable, …-enable, …-update | switch an endpoint off or on, change its model or prompt | name, fields | | limit-set, limit-remove | a rate limit in any scope | scope, name, requests, burst | | budget-set | budget caps; 0 removes one | scope, name, amounts | | api-set, api-delete | an API Gateway API | name, fields | | webhook-test | a signed test event to a webhook now, with the answer | name | | webhook-redeliver | deliveries queued again | ids, or failed_of | | GET /control/v1/openapi.json | the whole API as OpenAPI 3.1 | — |

Every tool of the control plane is here too, read tools as resources and write tools as actions; GET /control/v1 lists what this version has.

Everything in one config:

surfaces:
management:
mount: /control # default; the API is at /control/v1
keys:
- name: dashboard
hash: sha256:…
control: read # none (default) | read | write
- name: deploy-bot
hash: sha256:…
control: write # also the actions
Terminal window
promptgate keys create dashboard --control read # prints the pg_ key once
export PG_KEY=pg_…
curl -s -H "Authorization: Bearer $PG_KEY" http://127.0.0.1:7878/control/v1/stats?since=7d\&by=model
curl -s -H "Authorization: Bearer $PG_KEY" "http://127.0.0.1:7878/control/v1/logs?status=5xx&limit=50"

Answers are JSON objects, never cached (Cache-Control: no-store). A parameter the resource doesn’t know, or one given twice, is refused rather than ignored — a typo never returns unfiltered data.

An action takes a JSON object of arguments and answers with the result:

Terminal window
promptgate keys create deploy-bot --control write # a key that may change things
export PG_WRITE_KEY=pg_…
curl -s -X POST -H "Authorization: Bearer $PG_WRITE_KEY" -H "Content-Type: application/json" \
-d '{"scope":"keys","name":"ci","requests":"120/m"}' http://127.0.0.1:7878/control/v1/limit-set

A change goes through the same checked path as the web UI: the new file is validated as the gateway would load it, written with a backup, applied within seconds, and recorded in the audit trail as api:<key>. A change that would make the config invalid is refused (422) and nothing is written.

Every GET sends an ETag: the version of the configuration files (config, keys file, endpoint files). Send it back as If-Match and the change is refused with 412 if anyone — the web UI, the CLI, another script — changed them since you looked:

Terminal window
etag=$(curl -sI -H "Authorization: Bearer $PG_WRITE_KEY" http://127.0.0.1:7878/control/v1/keys | grep -i '^etag' | cut -d' ' -f2 | tr -d '\r')
curl -s -X POST -H "Authorization: Bearer $PG_WRITE_KEY" -H "If-Match: $etag" -H "Content-Type: application/json" \
-d '{"name":"old-laptop"}' http://127.0.0.1:7878/control/v1/key-disable

logs, webhook-deliveries and audit return at most limit rows (20, 50 and 50 by default, 100 at most). When there may be more, the answer carries next_before; pass it as before for the next page:

Terminal window
curl -s -H "Authorization: Bearer $PG_KEY" "http://127.0.0.1:7878/control/v1/logs?limit=100&before=48211"

One shape for every error:

{"error": {"type": "invalid_request", "message": "since: \"soon\" is not a duration like 1h or 7d"}}
status type when
400 invalid_request a parameter is unknown, repeated or has the wrong form
401 unauthorized no pg_ key, or an unknown one (provider keys never open the API)
403 forbidden the key has no control access, or only read for an action
404 not_found no such resource or action, or the key, endpoint, limit or API to change doesn’t exist
405 method_not_allowed a resource with POST, an action with GET, anything else
409 unavailable the resource reads the request log and logging.store is off
409 conflict the name is taken, or the files changed while the action ran
412 precondition_failed If-Match named an older version of the configuration
415 invalid_request the arguments aren’t application/json
422 rejected the change was refused: the config would be invalid, nothing to change, a key revoking itself
500 saved_with_problem saved, but the audit trail or loading it failed — the message says which
500 internal the gateway couldn’t answer
  • The API is on the gateway’s port and answers nothing without a key that has control access; keys without it get 403, so creating keys for apps never opens it.
  • control: read can’t change anything. Give dashboards read; keep write for the few automations that need it. A key can’t revoke itself, so an automation can’t lock itself out by mistake.
  • Nothing it returns contains a secret: provider keys, pg_ keys, key hashes, header values and OAuth tokens are never in an answer.
  • Reads aren’t written to the request log or the audit trail; every change is, as api:<key>, like changes from the web UI and the CLI.
Was this page helpful?