Admin API Reference
Protected endpoints for tenant and token management. Requires x-admin-key header.
Authentication
x-admin-key: {admin_key}
The admin key is validated against the SHA-256 hash stored in the ADMIN_API_KEY Wrangler secret.
Tenant Management
GET /admin/tenants/TENANT_ID
Read tenant configuration.
PUT /admin/tenants/TENANT_ID
Create or update tenant configuration.
{
"name": "Kahuna Workforce Solutions",
"status": "active",
"providers": {
"hubspot": {
"accounts": [{"id": "default", "label": "Production"}],
"default": "default"
}
}
}
POST /admin/auth
Register a new tenant bearer token.
{"tenant_id": "kahuna", "token": "your-secret-bearer-token-min-16-chars"}
Token Management
PUT /admin/tokens/TENANT_ID/PROVIDER/ACCOUNT_ID
Store a token directly.
{
"access_token": "...",
"expires_at": 1712764800,
"token_type": "Bearer"
}
POST /admin/seed-oauth
Configure a Durable Object with OAuth credentials for automatic token refresh.
{
"tenant_id": "ascend",
"provider": "google",
"account_id": "default",
"client_id": "...",
"client_secret": "...",
"token_endpoint": "https://oauth2.googleapis.com/token",
"refresh_token": "..."
}
Billing
GET /admin/usage/TENANT_ID
Get usage summary for a tenant.
PUT /admin/billing/TENANT_ID
Update billing configuration.
Audit Log
GET /admin/audit
Query KV audit log. Supports filters: tenant, action, source, key, since, limit.
GET /admin/audit/stats
Aggregated audit statistics (24h, 7d, 30d breakdowns).
Autoresearch
GET /admin/suggestions
Get AI-generated suggestions for the last N days.
PUT /admin/suggestions/SUGGESTION_ID/resolve
Mark a suggestion as resolved.
System
POST /admin/run-cron
Manually trigger a cron job. Body: {"cron": "*/5 * * * *"}.
GET /admin/system-health
Returns the latest system health snapshot from KV.