You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document catalogues every backend endpoint the AgentPay dashboard calls, with
the exact request body and the response shape the UI expects. Shapes are derived
from src/lib/apiClient.ts and the inline TypeScript declarations in each page —
every shape below matches the code at the cited source.
All requests go through the lightweight fetch wrapper in
src/lib/apiClient.ts (reads are usually issued via the
useApi hook). Two call sites — the usage Record and
Query forms in src/app/usage/page.tsx — use raw
fetch directly but follow the same JSON conventions.
Transport conventions
Concern
Behaviour
Source
Base URL
API_BASE resolved once at module load via resolveApiBase(); every path is ${API_BASE}${path}
apiClient.ts, resolveApiBase.ts
Request headers
Content-Type: application/json is sent by default (callers may override)
apiClient.ts
Request body
apiPost/apiPatchJSON.stringify the supplied object
apiClient.ts
Empty response
HTTP 204 resolves to undefined (no body parsed)
apiClient.ts
Timeout
Default 10 000 ms; on expiry the call rejects with ApiTimeoutError
apiClient.ts
Success
2xx JSON body is returned as the generic T
apiClient.ts
Error envelope (ApiError)
Non-2xx responses are expected to carry this JSON envelope; the wrapper throws an
Error whose message (and error/requestId) come from it:
typeApiError={error: string;// machine-readable code, e.g. "validation_error"message: string;// human-readable; surfaced in the UIrequestId?: string;// optional correlation id};
If the body is missing/!ok, the wrapper falls back to error: "http_error" and a
Request failed with status <code> message.
Pause flag
A global pause flag is exposed by GET /api/v1/admin/status ({ paused }) and
GET /api/v1/stats (paused), and toggled from the Admin page via
POST /api/v1/admin/pause / POST /api/v1/admin/unpause. While paused the
backend refuses writes (the Stats page surfaces "writes are refused"). In the
tables below, Write rows are the mutating calls subject to this flag; Read
rows are always available.
Linked from the Docs page as the machine-readable spec
docs/page.tsx
Accuracy note: every request/response shape above was transcribed from the
TypeScript type passed to apiGet/apiPost/apiPatch/useApi (or the raw
fetch body) at the cited source file. If a page's inline type changes, update the
corresponding row here.