Admin API Reference

Internal API documentation for Guardia AI platform administration.
All endpoints require the X-Admin-Key header. These routes are hidden from the public /docs schema.

πŸ”‘
Authentication β€” X-Admin-Key header
Every admin endpoint requires X-Admin-Key: <ADMIN_KEY> in the request headers.
The key is stored in GitHub Secrets as ADMIN_KEY and injected into the Container App at deploy time.
Requests with a missing or incorrect key receive 403 Forbidden.
πŸ“Š Analytics
Revenue, usage, growth, and cost metrics across all tenants.
GET /admin/analytics Full platform analytics snapshot β–Ό
Description

Returns MRR, ARR, active tenants, paying tenants, plan distribution, 30/60/90-day growth cohorts, and top tenant usage.

Response codes
200 OK403 Forbidden
Example response
{
  "revenue": { "mrr": 5998, "arr": 71976, "active_tenants": 2 },
  "growth": { "30d": { "new_signups": 2, "new_activated": 2 } },
  "top_tenants": [...]
}
⚑ Try it
GET /admin/analytics/revenue Revenue breakdown by plan β–Ό
Description

MRR and ARR grouped by plan tier with per-plan tenant count.

200 OK403 Forbidden
⚑ Try it
GET /admin/analytics/usage Per-tenant scan usage β–Ό
Description

Scan counts, framework usage, and quota consumption across all tenants.

200 OK403 Forbidden
⚑ Try it
GET /admin/costs Azure spend by resource β–Ό
Description

Live Azure Cost Management data grouped by resource type. Requires AZURE_SUBSCRIPTION_IDS env var.

Query params
ParamTypeDescription
daysintoptionalLookback window in days (default: 30)
200 OK403 Forbidden
⚑ Try it
🏒 Tenant Management
Create, query, and manage tenant lifecycle across all subscription tiers.
GET /admin/tenants List all tenants β–Ό
Description

Returns all tenant records from Cosmos DB including plan, scan counts, trial status, and masked API key.

Query params
ParamTypeDescription
plan_idstringoptionalFilter by plan: free_trial, starter, professional, enterprise
200 OK403 Forbidden
⚑ Try it
GET /admin/tenants/{tenant_id} Get single tenant β–Ό
Path params
ParamTypeDescription
tenant_idstringrequiredInternal Guardia tenant ID
200 OK403 Forbidden404 Not Found
POST /admin/tenants/provision Manually provision a tenant β–Ό
Description

Creates a tenant outside the Marketplace flow (e.g. direct sales, pilots, internal accounts). Generates an API key automatically.

Request body
FieldTypeDescription
emailstringrequiredPrimary contact email
plan_idstringrequiredfree_trial | starter | professional | enterprise
companystringoptionalCompany or organization name
aad_tenant_idstringoptionalAzure AD tenant ID for the customer
Example request
{
  "email": "cto@example.com",
  "plan_id": "starter",
  "company": "Acme Corp"
}
200 OK400 Conflict403 Forbidden
⚑ Try it
POST /admin/tenants/{tenant_id}/suspend Suspend a tenant β–Ό

Suspends the tenant's API key β€” all scan attempts return 403. Reversible via /reinstate.

200 OK403 Forbidden404 Not Found
POST /admin/tenants/{tenant_id}/reinstate Reinstate a suspended tenant β–Ό

Restores an active status for a previously suspended tenant.

200 OK403 Forbidden404 Not Found
POST /admin/tenants/{tenant_id}/cancel Cancel a subscription β–Ό

Marks the tenant as cancelled and expires their API key. Data is retained in Cosmos DB.

200 OK403 Forbidden
POST /admin/tenants/{tenant_id}/extend-trial Extend trial period β–Ό
Request body
FieldTypeDescription
daysintrequiredNumber of additional days to add to the trial
extra_scansintoptionalExtra scan credits to add
200 OK403 Forbidden404 Not Found
DEL /admin/tenants/{tenant_id} Permanently delete tenant β–Ό

⚠️ Destructive. Permanently removes the tenant record and all associated data from Cosmos DB. Cannot be undone.

200 OK403 Forbidden404 Not Found
πŸ” API Key Management
Look up, rotate, and expire tenant API keys.
POST /admin/keys/lookup Look up tenant by API key β–Ό
Request body
FieldTypeDescription
api_keystringrequiredThe gai-... key to resolve
200 OK403 Forbidden404 Not Found
POST /admin/tenants/{tenant_id}/rotate-key Rotate API key β–Ό

Generates a new gai-... key and invalidates the previous one immediately. The new key is returned in the response.

200 OK403 Forbidden404 Not Found
POST /admin/tenants/{tenant_id}/expire-key Expire API key β–Ό

Immediately expires the tenant's API key. The tenant will receive 401 on all subsequent requests until a new key is rotated or issued.

200 OK403 Forbidden404 Not Found
βš™οΈ Platform Settings
Global platform configuration β€” applies to all tenants. Admin only, never exposed publicly.
GET /admin/platform-config Get global governance scan configuration

Returns the current global governance scan execution settings: mode (serial or parallel) and parallel limit. Applies to all automated CCM scan runs across all tenants.

{ "governance_scan_mode": "serial", "governance_parallel_limit": 3 }
POST /admin/platform-config Update governance scan execution mode

Updates governance scan mode and parallel limit platform-wide. Changes apply to all future automated scans.

{
  "governance_scan_mode":      "serial",   // "serial" | "parallel"
  "governance_parallel_limit": 3           // 1-20, used when mode = "parallel"
}
πŸ”’ Vault & PMK Diagnostics
Platform-Managed Key connectivity testing and Azure OpenAI debug. Admin only.
GET /admin/vault-test/pmk Test PMK Azure Key Vault connectivity

Verifies that the platform can authenticate to the PMK Key Vault and retrieve the encryption secret. Accepts optional query params to test an alternative vault or secret before changing environment variables.

Query ParamRequiredDescription
vault_urlOptionalOverride vault URL for testing
secret_nameOptionalOverride secret name for testing
{
  "status":      "ok",
  "vault_url":   "https://guardia-ai-saas-kv.vault.azure.net/",
  "secret_name": "guardia-report-encr-creds",
  "secret_len":  44,
  "latency_ms":  123
}
GET /admin/aoai-debug Azure OpenAI narrator connectivity debug

Tests the Azure OpenAI connection used for scan narrative generation. Returns model, endpoint, latency, and a sample completion. Use to verify AI narration is functional before a scan cycle.

{
  "status":     "ok",
  "endpoint":   "https://guardia-aoai.openai.azure.com/",
  "model":      "gpt-4.1-mini",
  "latency_ms": 412
}
πŸ—„οΈ Archive & Audit Log
Internal cold-storage report archive (retention per platform policy) and structured delete audit log. Never exposed to tenants.
GET /admin/archive/stats Archive and audit log statistics

Returns aggregate statistics about the Azure Blob Storage report archive and audit log. Scoped to a single tenant via ?tenant_id= or platform totals when omitted.

Query ParamRequiredDescription
tenant_idOptionalScope to a single tenant. Omit for platform totals.
{
  "env":            "prod",
  "storage_ok":     true,
  "archive_count":  342,
  "audit_blobs":    28,
  "last_archived":  "2026-05-19T14:30:22+00:00",
  "tenants_seen":   ["tenant-id-1", "..."],
  "error":          null
}

Archive layout: report-archive-{env}/{tenant_id}/{YYYY}/{report_id}.json.gz
Audit layout: audit-log-{env}/{tenant_id}/{YYYY-MM}.jsonl
Audit actions: manual_bulk_delete Β· manual_single_delete Β· governance_history_delete Β· tenant_purged

🎁 Promotions
Create and manage time-limited promotional offers for Marketplace leads.
GET /admin/promos List all promotions

Returns all configured promotions including active state, type, validity window, and applicable plan.

POST /admin/promos Create a new promotion

Creates a new promotion offer β€” extended trial, plan upgrade, or scan quota boost.

{
  "name":          "Launch β€” 30-day Extended Trial",
  "type":          "extended_trial",
  "days":          30,
  "plan_override": "professional",
  "active":        true,
  "expires_at":    "2026-06-30T23:59:59Z"
}
POST /admin/promos/{promo_id}/toggle Toggle a promotion active / inactive

Flips the active state of a promotion. Inactive promotions are not applied to new tenants during onboarding.

GET /admin/promos/status Active promotion summary

Returns a count and summary of currently active promotions including nearest expiry. Used by the admin dashboard status badge.

πŸ”
Admin API Reference
Enter your admin key to continue