# System API

## GET /health/live

`GET /health/live` · operation `live`

**Authentication:** None.

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Process is running | — |


## GET /health/ready

`GET /health/ready` · operation `ready`

**Authentication:** None.

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Configuration loaded and HTTP server is ready | — |
| `503` | Replica is shutting down: readiness is withdrawn at once, requests are still served until the drain delay ends, then new operations are refused | — |


## GET /metrics

`GET /metrics` · operation `metrics`

Optional Prometheus scrape endpoint, gated by metrics_endpoint; restrict network access at ingress.

**Authentication:** None.

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Prometheus text exposition | — |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |


## GET /ui

`GET /ui` · operation `console`

Native self-contained console HTML with exact CSP hashes and no-store; no cross-replica asset fetch is required. Client routes are served under /ui/ when ui is enabled.

**Authentication:** None.

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | HTML application | — |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |


## GET /openapi.yaml

`GET /openapi.yaml` · operation `openAPIContract`

**Authentication:** None.

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | This OpenAPI 3.1 YAML contract | — |


## GET /api/v1/admin/panic

`GET /api/v1/admin/panic` · operation `getPanic`

Requires config:read. Emergency stop state (ADR 0108).

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | engaged, reason, actor, at | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |


## POST /api/v1/admin/panic

`POST /api/v1/admin/panic` · operation `engagePanic`

Requires features:manage (global administrators). Emergency stop: new data plane requests while engaged (/v1, /v1beta, /a2a: inference, realtime, agents, MCP, files, vector stores) answer 503 gateway_panic, requests in flight are cancelled at once (streams and realtime sessions included). Before headers, a stop-cut request answers 503 gateway_panic; an unfinished response whose headers were sent closes without replay or a new HTTP status. A client cancellation or deadline that happened first retains its classification. Background workers (batches, eval runs and rules, retention, rollups, valuation, alerts, durable recovery) pause. The console, admin API, health and metrics stay up. This replica stops immediately, even if the database is unreachable; the state is stored without a version check and every replica applies it on its next control sync (5 s). Audited as panic.engage.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `reason` (string, required, min length 1, max length 500)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | State and propagated (false when the database could not record it) | — |
| `400` | Missing reason | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Missing features:manage or CSRF token | — |


## DELETE /api/v1/admin/panic

`DELETE /api/v1/admin/panic` · operation `releasePanic`

Requires features:manage. Releases the emergency stop; paused batches and eval runs resume where they stopped. Audited as panic.release.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | State and propagated | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Missing features:manage or CSRF token | — |


## GET /api/v1/admin/source-of-truth

`GET /api/v1/admin/source-of-truth` · operation `sourceOfTruthPlan`

Requires config:read and gitops_source_of_truth. The GitOps dry run against the stored control state - the mode, the IDs the YAML declares per kind, the console rows the file shadows, the database-only rows, and the digest an apply must name. Read-only.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Dry run; private and not cached. | `application/json`: [SourceOfTruthPlan](/docs/api/schemas/s/#sourceoftruthplan) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Storage unavailable | — |


## POST /api/v1/admin/source-of-truth/apply

`POST /api/v1/admin/source-of-truth/apply` · operation `applySourceOfTruth`

Requires features:manage, CSRF, gitops_source_of_truth and gitops.source_of_truth file. Deletes the rows the reviewed dry run lists - the shadowed console overrides, and the database-only rows only with gitops.prune - in one transaction. The digest must match the current plan and the pruned configuration must validate, or nothing changes. Audited.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `digest` (string, required, pattern `^[0-9a-f]{64}$`)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The new configuration version and the plan after the apply. | `application/json`: object |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | The database is the source of truth, the plan changed since the dry run, or a row is still in use | — |
| `422` | The pruned configuration would not validate | — |
| `503` | Storage unavailable | — |

Response `200` fields:

- `application/json`: object
  - `version` (integer (int64), required)
  - `plan` ([SourceOfTruthPlan](/docs/api/schemas/s/#sourceoftruthplan), required)

