The proxy provides two administration surfaces:
- A loopback-only local route used by the bundled admin CLI.
- An optional remote management API protected by
admin-api-key.
Both surfaces call the same user, usage, and Codex auth management handlers.
Management responses use Cache-Control: no-store.
The CLI connects to http://127.0.0.1:8317 by default:
codex-oauth-proxy admin users listIt calls /v0/local-admin/*. The server accepts this route only when the
request's remote address is loopback (127.0.0.1 or ::1). It does not require
or send admin-api-key.
Use --url for another port or path on the same local service:
codex-oauth-proxy admin users list \
--url http://127.0.0.1:8318Use --json with any admin command for machine-readable output:
codex-oauth-proxy admin users list --jsonGlobal admin flags may appear after the leaf command.
codex-oauth-proxy admin users list
codex-oauth-proxy admin users list --enabled true
codex-oauth-proxy admin users list --enabled falsecodex-oauth-proxy admin users create aliceUser names are required and unique without regard to case. A new user is enabled by default and receives one active generated API key.
The create output includes the plaintext key once.
codex-oauth-proxy admin users get usr_xxxcodex-oauth-proxy admin users update usr_xxx --name alice2codex-oauth-proxy admin users enable usr_xxx
codex-oauth-proxy admin users disable usr_xxxA disabled user cannot authenticate proxy or user API requests. The stored API key remains present and works again if the user is re-enabled.
codex-oauth-proxy admin users reset-key usr_xxxResetting a key:
- Disables every previously active key for the user.
- Creates one new active key.
- Returns the new plaintext key once.
- Does not delete historical usage attributed to older key IDs.
codex-oauth-proxy admin usage snapshot
codex-oauth-proxy admin usage snapshot --user-id usr_xxx
codex-oauth-proxy admin usage snapshot --api-key-id key_xxxHuman-readable output shows request and token totals for the rolling 5-hour and 7-day windows.
codex-oauth-proxy admin usage timeseries \
--window 7d \
--step 1h \
--group-by userAvailable flags:
| Flag | Values |
|---|---|
--window |
5h, 24h, 7d, 30d, today |
--step |
auto, 10m, 30m, 1h, 6h, 1d |
--group-by |
Comma-separated user, api_key, model, reasoning_effort, service_tier |
--fill |
none or zero |
--user-id |
One user ID |
--api-key-id |
One API key ID |
The default window is 7d; the default grouping is user. Automatic step size
depends on the selected window.
The local route sees the host-side CLI connection as non-loopback when the server runs in a container. Run the CLI inside the proxy container:
docker exec codex-oauth-proxy \
/codex-oauth-proxy/codex-oauth-proxy admin users listFor scripts or Grafana outside the container, enable and use the remote management API instead.
Set a non-empty key:
admin-api-key: "replace-with-a-long-random-secret"Then authenticate /v0/management/* requests with either:
Authorization: Bearer <admin-api-key>or:
X-API-Key: <admin-api-key>When admin-api-key is empty, remote management routes return 404. Local
admin routes remain available to loopback clients.
Example:
curl http://127.0.0.1:8317/v0/management/users \
-H 'Authorization: Bearer admin-change-me'See API Reference for request and response shapes.
Codex auth status and recovery actions are exposed through the management APIs. The bundled CLI does not add a separate auth command group.
List safe auth status locally:
curl http://127.0.0.1:8317/v0/local-admin/authsForce refresh through the remote API:
curl -X POST http://127.0.0.1:8317/v0/management/auths/refresh \
-H 'Authorization: Bearer admin-change-me' \
-H 'Content-Type: application/json' \
-d '{"account_id":"acct_xxx"}'Enable, disable, and clear a time-based cooldown by replacing the final path with:
/auths/enable
/auths/disable
/auths/cooldown/clear
Enable and disable update every source file for the account. Enable is local validation only; it does not refresh tokens or clear health. Disable affects new selection but does not terminate active HTTP, SSE, or WebSocket traffic and does not delete bindings.
Clear one user's exact session binding:
curl -X POST http://127.0.0.1:8317/v0/management/session-bindings/clear \
-H 'Authorization: Bearer admin-change-me' \
-H 'Content-Type: application/json' \
-d '{"user_id":"usr_xxx","session_key":"raw-session-key"}'Omit session_key to clear all bindings for that user, or send only
account_id to clear bindings targeting one auth. No global clear or
administrator-selected target migration is available.
Unidentified auths remain visible in status but are read-only. Management logs include action, safe account/user identity, outcome, and deleted counts. They do not include OAuth tokens, admin keys, raw session keys, source paths, or raw upstream response bodies.
A managed user API key can access:
- Current user and key metadata.
- API key reset.
- Today's UTC usage.
Resetting through the user API invalidates the credential used for the request and returns a new plaintext key. The caller must switch to the new key.
- Managed keys use the
cop_prefix. - Only the SHA-256 hash is persisted for authentication.
- List and detail responses include
key_prefixandmasked_key, not plaintext. - Creation and reset are the only operations that return plaintext.
- One user can have only one enabled API key at a time.
- A key reset disables the old key immediately.