Admin Endpoints Reference¶
This page documents the admin API surface — endpoints that require elevated permissions (tenant:manage, graph:rebuild, audit:read, super_admin). These endpoints are not visible in the patient-facing Swagger UI.
All admin endpoints are under /api/v1/admin/ and require a valid Clerk JWT with the appropriate Clerk organisation role mapped to an internal permission. See Auth & Privacy for the RBAC mapping.
Graph Management¶
Rebuild Neo4j projection¶
Triggers a full or scoped re-projection of PostgreSQL data into Neo4j. Use after bulk imports, schema migrations, or when node counts diverge.
Request body:
scope options: "all" | "providers" | "doctors" | "procedures"
Response:
{
"success": true,
"data": {
"counts": {
"doctors": 172,
"providers": 42,
"procedures": 30
},
"duration_ms": 4210
}
}
Source: app/routers/admin_graph.py. See Graph Projection architecture for the projection contract.
Feature Flags¶
Get effective flags for a tenant¶
Returns the resolved flag values for a tenant, merging Flagsmith environment defaults with any per-identity overrides. Useful for debugging flag state without accessing Flagsmith cloud.
Response:
{
"success": true,
"data": {
"flags": {
"matching_strategy_version": "v2.1",
"enable_mso_booking": true,
"triage_risk_threshold": 0.65
},
"overrides_applied": ["triage_risk_threshold"]
}
}
Set a per-tenant flag override¶
Sets a Flagsmith per-identity override for a tenant. This is the only supported path for per-tenant overrides — never use the Flagsmith dashboard UI for tenant-specific values (see feedback_flagsmith_identity_overrides.md).
Request body:
Every override is audit-logged as EventType.ADMIN_FLAG_IDENTITY_OVERRIDE.
Source: app/routers/admin_flags.py.
Matching Dashboard¶
Get parameter registry status¶
Returns all 147 matching parameters from the registry (config/matching/parameters/*.yaml) with their current status, coverage, and source.
Response:
{
"success": true,
"data": {
"parameters": [
{
"id": "jci_accreditation",
"domain": "provider_capability",
"status": "active",
"source": "postgres",
"coverage_pct": 0.82,
"last_refresh": "2026-05-07T08:00:00Z"
}
],
"total": 147,
"active": 14,
"seeded": 12,
"unseeded": 89,
"not_implemented": 32
}
}
Get domain weight configuration¶
Returns current domain-level weight configuration — either from Flagsmith override (per tenant) or the YAML default.
Source: app/routers/admin_matching.py. See ADR-0026 for the parameter registry design.
MSO Session Management¶
List MSO sessions¶
Query parameters:
| Parameter | Type | Description |
|---|---|---|
status |
string | Filter by session status |
tenant_id |
UUID | Filter by tenant |
from_date |
ISO 8601 | Sessions on or after this date |
to_date |
ISO 8601 | Sessions on or before this date |
limit |
int | Page size (default 50) |
offset |
int | Pagination offset |
Refund a session¶
Triggers a refund via the original payment provider (Stripe or Razorpay) and sets MSOSession.status = refunded. Idempotent — calling twice does not double-refund.
Source: app/routers/admin_mso_sessions.py.
MSO Doctor Management¶
List MSO doctors¶
Query parameters: specialty, language, available_from, tenant_id.
Onboard MSO doctor¶
Update MSO doctor¶
Source: app/routers/admin_mso_doctors.py.
Triage Management¶
The triage admin UI is at /admin/triage. Thresholds are set via Flagsmith per-identity overrides — see Triage Tuning Runbook for the step-by-step procedure.
Audit Log¶
Query audit log¶
Queries the append-only audit_logs table. Supports filtering by action, actor_id, tenant_id, case_id, patient_id, and date range.
Immutability guarantee
Audit logs are append-only. Even super admins cannot delete entries. This is enforced at the repository layer — there is no DELETE method on AuditLogRepository. See ADR-0022.
Source: app/routers/admin_audit_log.py.
Tenant Management¶
Create provider tenant¶
Legacy 2-step path: creates a tenant for an existing provider. For new providers, prefer the unified POST /api/v1/admin/providers endpoint which creates provider + tenant atomically.
List tenants¶
Update tenant settings¶
Source: app/routers/admin_portal.py, app/routers/admin_tenants.py.
User & Role Management¶
List users for a tenant¶
Assign role to user¶
Assigns a Clerk org role (mapped to internal permission set) to a user. The Clerk user ID is verified against the Clerk API before the role is applied. See feedback_verify_user_id_against_clerk.md.
Source: app/routers/admin_users.py, app/routers/admin_roles.py.
System Health¶
External dependency health¶
Returns health status of all external services: Daily.co, Stripe, Razorpay, Neo4j, Qdrant, Redis, Anthropic, Langfuse.
Error Codes¶
Admin endpoints use the standard AUTH_*, TENANT_*, and GRAPH_* error code namespaces. See Error Codes for the full list.
Common admin errors:
| Code | Meaning |
|---|---|
AUTH_INSUFFICIENT_PERMISSION |
JWT present but role lacks required permission |
TENANT_NOT_FOUND |
tenant_id does not exist |
GRAPH_REBUILD_FAILED |
Neo4j unreachable or projection error during rebuild |