# Admin System Health

Endpoint that exposes a snapshot of the platform's operational health for admin dashboards.

## Endpoint

| Method | Path | Auth |
|--------|------|------|
| GET | `/api/v1/admin/system-health` | `auth:api` + `super_admin` or `admin` |

## Response

```json
{
  "data": {
    "system_health": {
      "api": {
        "status": "ok",
        "latency_ms": 42
      },
      "database": {
        "status": "ok"
      },
      "queue": {
        "status": "ok",
        "pending_jobs": 0
      },
      "storage": {
        "status": "ok"
      },
      "checked_at": "2026-07-14T00:00:00Z"
    }
  }
}
```

## Fields

| Field | Type | Description |
|-------|------|-------------|
| `system_health.api.status` | string | `ok`, `degraded`, or `down`. Based on the latency of a simple DB ping performed inside the request. |
| `system_health.api.latency_ms` | integer | Round-trip latency in milliseconds. |
| `system_health.database.status` | string | `ok` or `down`. Result of attempting to connect to the default DB connection. |
| `system_health.queue.status` | string | `ok` or `backed_up`. `backed_up` when more than 100 jobs are pending. |
| `system_health.queue.pending_jobs` | integer | Number of jobs currently waiting in the queue. |
| `system_health.storage.status` | string | `ok` or `degraded`. `degraded` when the local storage disk has less than 10% free space remaining. |
| `system_health.checked_at` | string | ISO 8601 timestamp of when the health snapshot was taken. |

## Error responses

- `401 Unauthorized` — request is not authenticated.
- `403 Forbidden` — authenticated user is not an `admin` or `super_admin`.

## Notes

- This is a real-time check: every call re-evaluates API latency, database connectivity, queue size, and storage capacity.
- No caching is applied by default. If the dashboard polls this endpoint, consider adding a short-lived cache (e.g. 30–60 seconds) to avoid unnecessary load.
