Go Proxy REST API Reference
Base URL: http://<proxy>:8080
Auth: X-Api-Key header (maps to organisation ID)
Request Identity and Correlation
Every HTTP request entering the proxy through its middleware chain is assigned a unique UUID v4 request identifier.
- Response header: The proxy echoes the assigned identifier in the
X-Request-Idresponse header on all responses (including 2xx successes, streaming SSE frames, and 4xx/5xx errors). - Error payloads: When an error response is generated, the JSON error payload includes the identifier in the
request_idfield. - Engine correlation: The proxy propagates the request identifier as
x-request-idgRPC metadata on every call to the engine. If W3C distributed tracing is enabled,traceparentandtracestateheaders are also forwarded. - Structured logs: The proxy emits a structured log record upon request completion containing the
request_id,org_id,method,path,status,bytes, andduration_ms.
Engine Transport Security
The proxy communicates with the UndoLog effect engine over gRPC. By default, communication uses unencrypted plaintext TCP on port 50051. In production and zero-trust deployments, transport security can be configured:
- Transport TLS: Enabled by specifying
UNDOLOG_PROXY_ENGINE_TLS_CA_PATH. The proxy verifies the engine's TLS certificate chain against the configured custom CA bundle (or falls back to system root certificates when unset while client certificates are active). - Mutual TLS (mTLS): Enabled by configuring
UNDOLOG_PROXY_ENGINE_TLS_CLIENT_CERT_PATHandUNDOLOG_PROXY_ENGINE_TLS_CLIENT_KEY_PATHalongsideUNDOLOG_PROXY_ENGINE_TLS_CA_PATH. The proxy presents its client certificate to the engine during the handshake. - Authentication decoupling: Bearer token authentication via
UNDOLOG_PROXY_ENGINE_AUTH_TOKENoperates independently of TLS and is sent on every RPC across plaintext, TLS, or mTLS connections.
POST /mcp/tool_call
Intercept and execute a tool call through the UndoLog engine.
Request
Headers
| Header | Required | Description |
|---|---|---|
X-Api-Key |
Yes | API key for tenant authentication. Maps to an organisation ID. |
Content-Type |
Yes | application/json |
Body
{
"session_id": "uuid",
"tool_name": "str",
"tool_version": "str",
"step_index": 0,
"args": {}
}
| Field | Type | Required | Description |
|---|---|---|---|
session_id |
string |
Yes | UUID identifying the session. |
tool_name |
string |
Yes | Logical name of the tool. |
tool_version |
string |
No | Semantic version of the tool implementation. |
step_index |
uint32 |
No | Monotonically increasing call order within the session. |
args |
object |
Yes | Tool arguments as a JSON object. |
Responses
200 OK. Executed
{
"status": "executed",
"effect_id": "uuid",
"result": {}
}
| Field | Type | Description |
|---|---|---|
status |
string |
"executed" |
effect_id |
string |
Effect log entry identifier. |
result |
object |
Upstream tool execution result. |
A logical tool failure is returned as status: "executed" with
result.success: false: when the upstream answers with a 4xx/5xx HTTP
status but a structured ToolResult body (as the mock tool server does), the
proxy forwards that result to the engine instead of treating it as a transport
error. Transport failures (unreachable upstream, non-ToolResult error bodies,
timeouts) still surface as 502 tool_error, and the effect is reported as
failed through Fail.
Commit and Fail are retried with bounded backoff on transient engine
failures (for example an unavailable engine), so a momentary engine outage does
not turn into a spurious 502 commit_failed for an effect that the engine will
record once the connection recovers. Intercept, Approve, and Reject are not
retried. One residual window remains: if the engine applies a Commit or
Fail but the response is lost in transit, a retried call hits the
already-terminal state and the proxy reports the error even though the effect
is recorded. Execution is still exactly-once there, because the SDK retry
replays the cached result instead of re-running the tool.
200 OK. Replayed
{
"status": "replayed",
"effect_id": "uuid",
"result": {}
}
| Field | Type | Description |
|---|---|---|
status |
string |
"replayed" |
effect_id |
string |
Effect identifier of the original (cached) entry. |
result |
object |
Cached tool result from the original execution. |
202 Accepted. Pending Approval
{
"status": "pending_approval",
"approval_id": "uuid",
"retry_after": 5
}
| Field | Type | Description |
|---|---|---|
status |
string |
"pending_approval" |
approval_id |
string |
Approval request identifier. |
retry_after |
int |
Suggested seconds before retrying the same call. |
Error Responses
| Status | code |
Description |
|---|---|---|
400 Bad Request |
invalid_request |
Invalid JSON body, missing session_id/tool_name, or uncanonicalizable args. |
401 Unauthorized |
auth_failed |
Missing X-Api-Key header. |
403 Forbidden |
auth_failed |
API key not recognised. |
405 Method Not Allowed |
method_not_allowed |
HTTP method is not POST. |
502 Bad Gateway |
intercept_failed |
Engine interception call failed. |
502 Bad Gateway |
tool_error |
Upstream tool execution failed. |
502 Bad Gateway |
commit_failed |
Engine commit call failed after successful execution. |
Error body:
{
"request_id": "uuid",
"code": "error_code",
"message": "Human-readable description",
"timestamp": "2026-01-01T00:00:00Z"
}
Every response carries an X-Request-Id header (and the error body includes the
same value as request_id). The proxy forwards this value as x-request-id
gRPC metadata on every engine call, so engine and proxy logs for one tool call
can be correlated across the two services.
GET /health
Liveness probe for the UndoLog proxy.
Request
No headers are required and the endpoint is unauthenticated.
Response
200 OK
{
"status": "ok",
"service": "undolog-proxy"
}
| Field | Type | Description |
|---|---|---|
status |
string |
"ok" |
service |
string |
Service identifier. |
The endpoint is a liveness probe only: it does not check the engine connection or upstream reachability, and it does not echo configuration values (such as the engine address or upstream URL), which are kept out of unauthenticated responses.
GET /readyz
Readiness probe for the UndoLog proxy and engine reachability.
Request
No headers are required and the endpoint is unauthenticated.
Responses
200 OK. Ready
{
"status": "ready",
"service": "undolog-proxy"
}
| Field | Type | Description |
|---|---|---|
status |
string |
"ready" |
service |
string |
Service identifier ("undolog-proxy"). |
Returned when the proxy has established an active and healthy gRPC connection to the engine.
503 Service Unavailable. Not Ready
{
"status": "not_ready",
"service": "undolog-proxy"
}
| Field | Type | Description |
|---|---|---|
status |
string |
"not_ready" |
service |
string |
Service identifier ("undolog-proxy"). |
Returned when the engine gRPC connection is unavailable, disconnected, or reconnecting. Orchestrators should gate incoming traffic on /readyz while leaving /health for liveness probes.
Like /health, /readyz is served outside the middleware chain, requires no API key, and intentionally exposes no configuration values.
GET /metrics
Prometheus text exposition of proxy service metrics. No auth required.
Metric families
| Metric | Type | Labels | Description |
|---|---|---|---|
undolog_proxy_http_requests_total |
counter | route, status |
Completed HTTP requests by route and status code. |
undolog_proxy_http_request_duration_seconds |
histogram | route |
HTTP request duration per route. Note that /events reports the full stream lifetime. |
undolog_proxy_engine_connected |
gauge | none | Current engine connection state: 1 when connected and ready, 0 when disconnected. |
undolog_proxy_engine_reconnects_total |
counter | none | Number of successful engine reconnect attempts after connection drop. |
undolog_proxy_engine_rpc_duration_seconds |
histogram | method |
Engine gRPC call duration per method. |
undolog_proxy_engine_rpc_errors_total |
counter | method |
Engine calls that returned an error. |
undolog_proxy_engine_rpc_retries_total |
counter | method |
Engine calls retried after a transient failure. |
undolog_proxy_engine_inflight |
gauge | none | In-flight requests currently executing against the engine. |
undolog_proxy_engine_queue_depth |
gauge | none | Requests waiting in the bounded queue for an engine execution slot. |
undolog_proxy_engine_breaker_state |
gauge | none | Engine circuit breaker state: 0 (closed/healthy), 1 (half-open), 2 (open/failing). |
undolog_proxy_engine_rejections_total |
counter | reason |
Engine requests rejected by backpressure ("breaker" or "queue_full"). |
undolog_proxy_rate_limit_rejections_total |
counter | none | Requests rejected by per-API-key rate limiting (HTTP 429). |
undolog_proxy_executor_duration_seconds |
histogram | result |
Upstream tool executor duration by outcome ("success" or "error"). |
undolog_proxy_sse_subscribers |
gauge | org |
Active SSE subscribers per organisation. |
undolog_proxy_sse_events_dropped_total |
counter | org |
SSE events dropped because a subscriber channel was full. |
undolog_proxy_approval_decisions_total |
counter | action, result |
Approval decisions by action and outcome. |
undolog_proxy_approval_decision_duration_seconds |
histogram | action |
Approval decision latency. |
The metric endpoint is unauthenticated and intentionally carries no configuration or API-key material. If it must not be reachable by the public, scope it behind a reverse-proxy rule.
The route label carries the request path with the approval id collapsed to a
fixed segment, so /approvals/{id}/approve and /approvals/{id}/reject
produce one series per action instead of one per approval id. The /events
duration histogram covers the full SSE stream lifetime. Approval latency only
samples requests that reached the decision state machine. The /health,
/readyz, and /metrics endpoints are served outside the middleware chain, so
they do not appear in the HTTP metrics and are not covered by API-key auth.
GET /approvals
List approval requests filtered by organisation and state.
Request
Headers
| Header | Required | Description |
|---|---|---|
X-Api-Key |
Yes | API key for tenant authentication. |
X-Org-Id |
Yes | Organisation identifier (set by auth middleware). |
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
state |
string |
No | pending |
Filter by approval state. One of: pending, approved, rejected. |
limit |
int |
No | 100 |
Maximum number of records to return (1-500). Records are ordered newest first, with the ID as tiebreaker. |
Response
200 OK
[
{
"id": "uuid",
"org_id": "uuid",
"session_id": "uuid",
"effect_id": "uuid",
"tool_name": "transfer_funds",
"args": [123, 34, ...],
"status": "pending"
}
]
Each record contains:
| Field | Type | Description |
|---|---|---|
id |
string |
Approval request identifier. |
org_id |
string |
Organisation identifier. |
session_id |
string |
Session identifier. |
effect_id |
string |
Effect identifier. |
tool_name |
string |
Tool name. |
args |
bytes |
Raw JSON tool arguments. |
status |
string |
One of: pending, approved, rejected. |
Error Responses
| Status | Description |
|---|---|
400 Bad Request |
Invalid state parameter. An invalid or out-of-range limit falls back to the default (100). |
401 Unauthorized |
Missing X-Org-Id header. |
POST /approvals/{id}/approve
Approve a pending approval request and resume the suspended session.
When the approval record is absent from the proxy's local cache (e.g. after a proxy
restart), the proxy falls back to querying the engine directly via GetApproval. If
the engine reports the record as pending for the authenticated organisation, it is
upserted into the local store and processed. If the engine reports the record as
already resolved (approved, rejected, or timed out), the endpoint returns 409 Conflict.
Request
Headers
| Header | Required | Description |
|---|---|---|
X-Api-Key |
Yes | API key for tenant authentication. |
X-Org-Id |
Yes | Organisation identifier (set by auth middleware). |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Approval request identifier. |
Response
200 OK
{
"status": "approved",
"approval_id": "uuid",
"effect_id": "uuid",
"execution": "committed",
"result": {}
}
| Field | Type | Description |
|---|---|---|
status |
string |
"approved" |
approval_id |
string |
Approval request identifier. |
effect_id |
string |
Effect identifier. |
execution |
string |
"committed" on success, "failed" if the tool execution failed after approval. |
result |
object |
Upstream tool execution result (present when execution is "committed"). |
error |
string |
Execution error message (present when execution is "failed"). |
Error Responses
| Status | Description |
|---|---|
400 Bad Request |
Missing approval ID in path or malformed decision body. |
401 Unauthorized |
Missing X-Org-Id header. |
404 Not Found |
Approval ID not found or does not belong to the organisation. |
409 Conflict |
Approval already resolved. |
502 Bad Gateway |
Engine rejected the approval decision. |
POST /approvals/{id}/reject
Reject a pending approval request and halt the suspended session.
When the approval record is absent from the proxy's local cache (e.g. after a proxy
restart), the proxy falls back to querying the engine directly via GetApproval. If
the engine reports the record as pending for the authenticated organisation, it is
upserted into the local store and processed. If the engine reports the record as
already resolved (approved, rejected, or timed out), the endpoint returns 409 Conflict.
Request
Headers
| Header | Required | Description |
|---|---|---|
X-Api-Key |
Yes | API key for tenant authentication. |
X-Org-Id |
Yes | Organisation identifier (set by auth middleware). |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Approval request identifier. |
Response
200 OK
{
"status": "rejected",
"approval_id": "uuid"
}
| Field | Type | Description |
|---|---|---|
status |
string |
"rejected" |
approval_id |
string |
Approval request identifier. |
Error Responses
| Status | Description |
|---|---|
400 Bad Request |
Missing approval ID in path or malformed decision body. |
401 Unauthorized |
Missing X-Org-Id header. |
404 Not Found |
Approval ID not found or does not belong to the organisation. |
409 Conflict |
Approval already resolved. |
502 Bad Gateway |
Engine rejected the rejection decision. |
GET /events
Server-Sent Events stream for real-time dashboard updates.
Request
Headers
| Header | Required | Description |
|---|---|---|
X-Api-Key |
Yes | API key for tenant authentication. |
X-Org-Id |
Yes | Organisation identifier (set by auth middleware). |
Last-Event-ID |
No | Sequence ID of the last event received by the client. |
Replay and Reconnection
The proxy assigns monotonically increasing positive integers to each broadcasted event and maintains an in-memory ring buffer of the most recent 1,000 events across all tenants:
- Replay: When a client reconnects presenting a valid
Last-Event-ID, the proxy snapshots and replays all buffered events for the authenticated organisation strictly newer than the requested ID before streaming live events. - Tenant isolation: Replayed events are strictly filtered to the authenticated organisation.
- Buffer limits: Replay buffer capacity is 1,000 events. The buffer is held in memory and resets on proxy restart.
- Resynchronization: If the requested
Last-Event-IDis older than the oldest buffered event, the proxy emits aresync_requiredevent before live events, signaling that the client missed events that exceeded buffer capacity and must refresh full state from the REST API. - Future sequence: If
Last-Event-IDis newer than the current sequence, no events are replayed and live streaming starts immediately. - Malformed ID: If
Last-Event-IDis not a valid unsigned integer, the endpoint returns400 Bad Request.
Response
text/event-stream with Cache-Control: no-cache.
Event types:
| Event | Description |
|---|---|
effect_intercepted |
Tool call reached the engine for interception. |
effect_committed |
Engine committed the effect successfully. |
effect_replayed |
Tool call served from cached state. |
effect_failed |
Failure at any interception stage. |
approval_required |
Tool call waiting for human approval. |
approval_approved |
Human approved an approval request. |
approval_rejected |
Human rejected an approval request. |
resync_required |
Event gap exceeded ring buffer capacity. Full REST sync required. |
Event format:
event: effect_committed
id: 42
data: {"type":"effect_committed","timestamp":"2026-01-01T00:00:00Z","org_id":"...","session_id":"...","effect_id":"...","payload":{"stage":"committed"}}
Heartbeat (: ping) sent every 25 seconds to maintain connection.
Error Responses
| Status | Description |
|---|---|
400 Bad Request |
Malformed Last-Event-ID header. |
401 Unauthorized |
Missing org ID via header or query parameter. |
500 Internal Server Error |
Streaming unsupported by proxy. |
GET /api/v1/admin/dead-letters
List dead-letter compensation records for the authenticated organization.
Request
Headers
| Header | Required | Description |
|---|---|---|
X-Api-Key |
Yes | Administrative API key. Must carry the admin role. |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
state |
string |
No | Lifecycle state filter (failed, retrying, or skipped). Defaults to failed. |
The organization is derived strictly from the authenticated API key; any org_id query parameter is ignored.
Responses
200 OK
{
"records": [
{
"dead_letter_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"org_id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
"session_id": "c3b9b4a1-8d2b-4d7a-8f91-7d3a2b4c5e6f",
"effect_id": "d1e2f3a4-b5c6-4d7e-8f90-1a2b3c4d5e6f",
"undo_id": "e2f3a4b5-c6d7-4e8f-901a-2b3c4d5e6f70",
"compensation_fn": "cancel_reservation",
"compensation_version": "1.0.0",
"compensation_args": {
"reservation_id": "res-12345"
},
"error_message": "upstream service returned 503",
"retry_count": 0,
"state": "failed",
"created_at": "2026-11-07T12:00:00Z",
"updated_at": "2026-11-07T12:00:00Z"
}
],
"count": 1
}
| Field | Type | Description |
|---|---|---|
records |
array |
Dead-letter records for the requested organization and state. |
count |
int |
Total number of records returned. |
Error Responses
| Status | Code | Description |
|---|---|---|
400 Bad Request |
invalid_argument |
The state query parameter is not one of failed, retrying, or skipped. |
401 Unauthorized |
auth_failed |
Missing X-Api-Key header. |
403 Forbidden |
auth_failed |
API key is unrecognized or belongs to a member role instead of an admin role. |
405 Method Not Allowed |
method_not_allowed |
HTTP method is not GET. |
501 Not Implemented |
dead_letter_unavailable |
The backing engine does not support dead-letter queues (such as SQLite). |
502 Bad Gateway |
engine_error |
The engine returned an internal database or communication error. |
503 Service Unavailable |
engine_unavailable |
Engine is unavailable or overloaded. Includes Retry-After: 1 header. |
POST /api/v1/admin/dead-letters/{id}/retry
Mark a failed dead-letter compensation record for retry.
Request
Headers
| Header | Required | Description |
|---|---|---|
X-Api-Key |
Yes | Administrative API key. Must carry the admin role. |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Dead-letter record UUID. |
The organization is derived strictly from the authenticated API key. The target record must belong to the caller's organization and be in the failed state.
Responses
200 OK
{
"dead_letter_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"org_id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
"session_id": "c3b9b4a1-8d2b-4d7a-8f91-7d3a2b4c5e6f",
"effect_id": "d1e2f3a4-b5c6-4d7e-8f90-1a2b3c4d5e6f",
"undo_id": "e2f3a4b5-c6d7-4e8f-901a-2b3c4d5e6f70",
"compensation_fn": "cancel_reservation",
"compensation_version": "1.0.0",
"compensation_args": {
"reservation_id": "res-12345"
},
"error_message": "upstream service returned 503",
"retry_count": 1,
"state": "retrying",
"created_at": "2026-11-07T12:00:00Z",
"updated_at": "2026-11-07T12:05:00Z"
}
Error Responses
| Status | Code | Description |
|---|---|---|
400 Bad Request |
invalid_argument |
Path parameter id is not a valid UUID. |
401 Unauthorized |
auth_failed |
Missing X-Api-Key header. |
403 Forbidden |
auth_failed |
API key belongs to a member role instead of an admin role. |
404 Not Found |
dead_letter_not_found |
Dead-letter record not found, belongs to a different organization, or is not in failed state. |
405 Method Not Allowed |
method_not_allowed |
HTTP method is not POST. |
501 Not Implemented |
dead_letter_unavailable |
The backing engine does not support dead-letter queues (such as SQLite). |
502 Bad Gateway |
engine_error |
The engine returned an internal database or communication error. |
503 Service Unavailable |
engine_unavailable |
Engine is unavailable or overloaded. Includes Retry-After: 1 header. |
POST /api/v1/admin/dead-letters/{id}/skip
Mark a failed dead-letter compensation record as skipped.
Request
Headers
| Header | Required | Description |
|---|---|---|
X-Api-Key |
Yes | Administrative API key. Must carry the admin role. |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Dead-letter record UUID. |
The organization is derived strictly from the authenticated API key. The target record must belong to the caller's organization and be in the failed state.
Responses
200 OK
{
"dead_letter_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"org_id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
"session_id": "c3b9b4a1-8d2b-4d7a-8f91-7d3a2b4c5e6f",
"effect_id": "d1e2f3a4-b5c6-4d7e-8f90-1a2b3c4d5e6f",
"undo_id": "e2f3a4b5-c6d7-4e8f-901a-2b3c4d5e6f70",
"compensation_fn": "cancel_reservation",
"compensation_version": "1.0.0",
"compensation_args": {
"reservation_id": "res-12345"
},
"error_message": "upstream service returned 503",
"retry_count": 0,
"state": "skipped",
"created_at": "2026-11-07T12:00:00Z",
"updated_at": "2026-11-07T12:05:00Z"
}
Error Responses
| Status | Code | Description |
|---|---|---|
400 Bad Request |
invalid_argument |
Path parameter id is not a valid UUID. |
401 Unauthorized |
auth_failed |
Missing X-Api-Key header. |
403 Forbidden |
auth_failed |
API key belongs to a member role instead of an admin role. |
404 Not Found |
dead_letter_not_found |
Dead-letter record not found, belongs to a different organization, or is not in failed state. |
405 Method Not Allowed |
method_not_allowed |
HTTP method is not POST. |
501 Not Implemented |
dead_letter_unavailable |
The backing engine does not support dead-letter queues (such as SQLite). |
502 Bad Gateway |
engine_error |
The engine returned an internal database or communication error. |
503 Service Unavailable |
engine_unavailable |
Engine is unavailable or overloaded. Includes Retry-After: 1 header. |