Skip to main content
The Admin API lets you query request history and account stats programmatically. It is the same data that powers the built-in admin UI at /admin, accessible as JSON so you can integrate it into your own scripts or monitoring tools.

Access control

Access rules differ based on where requests originate:
OriginRequirement
Loopback (localhost, 127.0.0.1, ::1)No token required
Remote (any other hostname or IP)Requires ADMIN_TOKEN set on the server
When ADMIN_TOKEN is set on the server, pass it in one of these headers:
HeaderFormat
x-admin-tokenx-admin-token: <token>
AuthorizationAuthorization: Bearer <token>
Tokens in URL query parameters are not supported.
If you see 403 Forbidden, the admin API is restricted to localhost and ADMIN_TOKEN is not set. If you see 401 Unauthorized, ADMIN_TOKEN is set but the request did not include a valid token.

GET /api/admin/meta

Returns metadata about the request history database, including the database file path and retention settings.
curl http://localhost:4141/api/admin/meta
Example response:
{
  "dbPath": "/home/user/.local/share/copilot-api/admin.sqlite",
  "retentionDays": 14,
  "maxRows": 200000
}

GET /api/admin/accounts

Lists accounts with their runtime status. Pass include_stats=1 to include aggregated request statistics for each account.
# Basic account list
curl "http://localhost:4141/api/admin/accounts"

# Include aggregated stats
curl "http://localhost:4141/api/admin/accounts?include_stats=1"
Example response with include_stats=1:
{
  "items": [
    {
      "account_id": "octocat",
      "account_type": "individual",
      "runtime": {
        "entitlement": 300,
        "remaining": 212,
        "unlimited": false,
        "failed": false
      },
      "stats": {
        "since_ms": 1735000000000,
        "request_count": 84,
        "error_count": 2,
        "tokens_total": 48200,
        "avg_duration_ms": 1340,
        "last_request_at_ms": 1735080000000
      }
    }
  ]
}

GET /api/admin/requests

Queries request logs with optional filters and cursor-based pagination.

Query parameters

ParameterTypeDefaultDescription
limitnumber50Number of results to return. Maximum is 200.
cursor_idnumberPagination cursor. Use next_cursor_id from the previous response.
account_idstringFilter by account ID.
upstream_modelstringFilter by the model ID sent upstream to Copilot.
client_modelstringFilter by the model ID requested by the client.
upstream_endpointstringFilter by upstream endpoint (e.g. /v1/messages).
pathstringFilter by request path.
statusnumberFilter by HTTP status code.
has_error1 or 0Filter to requests that have (1) or do not have (0) an error.
from_msnumberFilter to requests at or after this Unix timestamp in milliseconds.
to_msnumberFilter to requests at or before this Unix timestamp in milliseconds.

Response fields

FieldDescription
itemsArray of request log entries.
next_cursor_idCursor to pass as cursor_id to retrieve the next page.
has_moretrue if additional pages exist.

Examples

curl "http://localhost:4141/api/admin/requests?limit=50"

GET /api/admin/requests/:requestId

Returns a single request log entry by its ID.
curl "http://localhost:4141/api/admin/requests/abc123"
Example response:
{
  "item": {
    "request_id": "abc123",
    "account_id": "octocat",
    "path": "/v1/messages",
    "upstream_endpoint": "/v1/messages",
    "client_model": "claude-opus-4-6",
    "upstream_model": "claude-opus-4-6",
    "http_status": 200,
    "duration_ms": 1243,
    "started_at_ms": 1735080000000
  }
}


GET /api/admin/config

Returns the current server configuration. You can also use POST /api/admin/config to update configuration values without restarting the server. Changes made via the API are validated and applied immediately.
# Read current config
curl http://localhost:4141/api/admin/config

# Update a config value (example: change logLevel)
curl -X POST http://localhost:4141/api/admin/config \
  -H "Content-Type: application/json" \
  -d '{"logLevel": "debug"}'
Unknown keys are rejected. Only fields documented in the configuration reference are accepted.

Data storage and retention

Request history is stored in admin.sqlite in the app data directory:
  • Linux / macOS: ~/.local/share/copilot-api/admin.sqlite
  • Windows: %USERPROFILE%\.local\share\copilot-api\admin.sqlite
The proxy stores metadata only — no GitHub or Copilot tokens, and no request or response content. Logs are retained for 14 days and the database is capped at 200,000 rows. Older entries are cleaned up automatically.