Skip to content

Agent Gateway API Reference ​

The Agent Gateway (L3) manages MCP (Model Context Protocol) servers, tool discovery and execution, A2A (Agent-to-Agent) communication, session lifecycle, security policies, human-in-the-loop (HITL) approvals, and MCP elicitation flows.

Base URL: http://localhost:5001

All endpoints require authentication via the Authorization header (Bearer JWT). Tenant identification is extracted from the JWT tenant_id claim or the x-tenant-id header.


Health ​

GET / ​

Service information, supported protocols, and endpoint discovery.

Response: 200 OK

json
{
  "service": "agent-gateway",
  "engine": "rust",
  "version": "0.1.0",
  "protocols": ["MCP", "A2A"],
  "endpoints": {
    "/v1/mcp/servers": "MCP server registry",
    "/v1/mcp/tools": "Tool discovery",
    "/v1/mcp/tools/call": "Execute a tool",
    "/v1/a2a/agents": "A2A agent registry",
    "/v1/a2a/send": "Send A2A message",
    "/v1/sessions": "Session management",
    "/v1/policies/:tenant_id": "Security policies",
    "/v1/hitl/pending": "HITL approval queue"
  }
}

curl Example:

bash
curl http://localhost:5001/

GET /health ​

Health check with MCP server count.

Response: 200 OK

json
{
  "status": "ok",
  "service": "agent-gateway",
  "engine": "rust",
  "mcp_servers": 3
}

curl Example:

bash
curl http://localhost:5001/health

MCP Servers ​

GET /v1/mcp/servers ​

List registered MCP servers, optionally filtered by tenant.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
x-tenant-idNoFilter servers by tenant

Response: 200 OK

json
{
  "servers": [
    {
      "id": "srv-abc123",
      "name": "file-server",
      "url": "http://mcp-file-server:8080",
      "tenant_id": "tenant-alpha",
      "tools": [
        {"name": "read_file", "description": "Read file contents", "inputSchema": {}}
      ],
      "status": "active",
      "registered_at": "2026-03-25T10:00:00Z",
      "fingerprint": "sha256:abc123..."
    }
  ],
  "total": 1
}

curl Example:

bash
curl http://localhost:5001/v1/mcp/servers \
  -H "Authorization: Bearer $TOKEN" \
  -H "x-tenant-id: tenant-alpha"

POST /v1/mcp/servers ​

Register a new MCP server. The gateway generates an ID if not provided, sets the status to active, and computes a tool fingerprint for poisoning detection.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
Content-TypeYesapplication/json

Request Body:

json
{
  "name": "file-server",
  "url": "http://mcp-file-server:8080",
  "tenant_id": "tenant-alpha",
  "tools": [
    {
      "name": "read_file",
      "description": "Read file contents",
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": {"type": "string"}
        },
        "required": ["path"]
      }
    }
  ]
}

Response: 201 Created

json
{
  "id": "srv-abc123",
  "tools_registered": 1
}

Error Response: 409 Conflict (tool naming collision detected)

json
{
  "error": "tool_naming_collision",
  "collisions": ["read_file"]
}

WARNING

The gateway checks for tool naming collisions across all registered servers. If a tool name already exists on a different server, registration is rejected with 409 Conflict to prevent tool poisoning attacks.

curl Example:

bash
curl -X POST http://localhost:5001/v1/mcp/servers \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "file-server",
    "url": "http://mcp-file-server:8080",
    "tenant_id": "tenant-alpha",
    "tools": [
      {"name": "read_file", "description": "Read file contents", "inputSchema": {"type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"]}}
    ]
  }'

GET /v1/mcp/servers/:server_id ​

Get details for a specific MCP server.

Path Parameters:

ParameterDescription
server_idMCP server identifier

Response: 200 OK

json
{
  "id": "srv-abc123",
  "name": "file-server",
  "url": "http://mcp-file-server:8080",
  "tenant_id": "tenant-alpha",
  "tools": [],
  "status": "active",
  "registered_at": "2026-03-25T10:00:00Z",
  "fingerprint": "sha256:abc123..."
}

Error Response: 404 Not Found

json
{"error": "Server not found"}

curl Example:

bash
curl http://localhost:5001/v1/mcp/servers/srv-abc123 \
  -H "Authorization: Bearer $TOKEN"

PUT /v1/mcp/servers/:server_id ​

Update a registered server (name, url, transport, tenant, tools, stdio fields). Fields the body omits keep their stored values; the tool fingerprint is recomputed. Visibility and ownership follow GET /v1/mcp/servers/:server_id: a tenant user may update only its own tenant's servers (a foreign id answers 404), and may not move a server to another tenant or make it global (403).

Errors

StatuserrorWhen
400invalid_server_identitythe new name contains : (W2-D7-56). The policy lists use : as the server:tool separator, so a renamed server could never be matched by a name-qualified deny/HITL entry again. Same body as registration; nothing is changed.
403—tenant change or tenant-less target by a non-admin
404—unknown id, or another tenant's server
409tool_naming_collisiona tool name already exists on another server
429—registry full

The OpenAPI import (POST /v1/mcp/servers/from-openapi) applies the same 400 invalid_server_identity rule to the request's name.

:::note Servers stored before the rule A server whose id or name already contains : (registered or renamed before W2-D7-56) still loads at startup, with a warning per server, so an operator can rename or delete it. Until then POST /v1/mcp/tools/call against it answers 403 {"error":"invalid_server_identity"}: a name-qualified deny or HITL entry could never match it, so the gateway fails closed instead of open. :::


DELETE /v1/mcp/servers/:server_id ​

Remove an MCP server from the registry.

Path Parameters:

ParameterDescription
server_idMCP server identifier

Response: 200 OK

json
{"removed": "srv-abc123"}

Error Response: 404 Not Found

json
{"error": "Server not found"}

curl Example:

bash
curl -X DELETE http://localhost:5001/v1/mcp/servers/srv-abc123 \
  -H "Authorization: Bearer $TOKEN"

GET /v1/mcp/servers/:server_id/auth ​

Get authentication configuration for a specific MCP server. Each server can have its own OAuth provider configuration, overriding the global Zitadel settings.

Path Parameters:

ParameterDescription
server_idMCP server identifier

Response: 200 OK

json
{
  "server_id": "srv-abc123",
  "auth_config": {
    "mode": "strict",
    "oauth_url": "https://auth.example.com",
    "client_id": "my-client-id",
    "client_secret": "***REDACTED***",
    "required_scopes": ["tools:execute", "data:read"],
    "token_endpoint": "https://auth.example.com/oauth2/token"
  }
}

Field Descriptions:

FieldTypeDescription
modestringAuth mode: strict (reject if auth fails), permissive (warn but allow), or optional (no auth required)
oauth_urlstring?OAuth provider URL (overrides global Zitadel if set)
client_idstring?OAuth client ID for this server
client_secretstringAlways redacted in GET responses for security
required_scopesstring[]Required OAuth scopes for tool calls to this server
token_endpointstring?OAuth token endpoint for client_credentials grant

WARNING

The client_secret field is always redacted (***REDACTED***) in GET responses to prevent secret exposure. To update the secret, use the PUT endpoint.

curl Example:

bash
curl http://localhost:5001/v1/mcp/servers/srv-abc123/auth \
  -H "Authorization: Bearer $TOKEN"

PUT /v1/mcp/servers/:server_id/auth ​

Set or update authentication configuration for a specific MCP server. Allows each server to use a different OAuth provider instead of the global Zitadel configuration.

Path Parameters:

ParameterDescription
server_idMCP server identifier

Request Body:

json
{
  "mode": "strict",
  "oauth_url": "https://auth.example.com",
  "client_id": "my-client-id",
  "client_secret": "my-client-secret",
  "required_scopes": ["tools:execute", "data:read"],
  "token_endpoint": "https://auth.example.com/oauth2/token"
}

Response: 200 OK

json
{
  "status": "ok",
  "server_id": "srv-abc123",
  "mode": "strict"
}

Error Response: 404 Not Found (server does not exist)

json
{
  "error": "server_not_found",
  "message": "MCP server 'srv-abc123' not found"
}

curl Example:

bash
curl -X PUT http://localhost:5001/v1/mcp/servers/srv-abc123/auth \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "strict",
    "oauth_url": "https://auth.example.com",
    "client_id": "my-client-id",
    "client_secret": "my-client-secret",
    "required_scopes": ["tools:execute", "data:read"],
    "token_endpoint": "https://auth.example.com/oauth2/token"
  }'

GET /v1/mcp/servers/:server_id/tools ​

List tools registered on a specific MCP server.

Path Parameters:

ParameterDescription
server_idMCP server identifier

Response: 200 OK

json
{
  "tools": [
    {"name": "read_file", "description": "Read file contents", "inputSchema": {}}
  ]
}

Error Response: 404 Not Found

json
{"error": "Server not found"}

curl Example:

bash
curl http://localhost:5001/v1/mcp/servers/srv-abc123/tools \
  -H "Authorization: Bearer $TOKEN"

MCP Tools ​

GET /v1/mcp/tools ​

Discover all tools across all MCP servers, optionally filtered by tenant.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
x-tenant-idNoFilter tools by tenant

Response: 200 OK

json
{
  "tools": [
    {
      "tool": {"name": "read_file", "description": "Read file contents", "inputSchema": {}},
      "server_id": "srv-abc123",
      "server_name": "file-server"
    }
  ],
  "total": 1
}

curl Example:

bash
curl http://localhost:5001/v1/mcp/tools \
  -H "Authorization: Bearer $TOKEN" \
  -H "x-tenant-id: tenant-alpha"

POST /v1/mcp/tools/call ​

Execute a tool on an MCP server. Every tool call runs inside a session (POST /v1/sessions): the gateway binds the call to the session's tenant, enforces the session's allowlist and budget, validates the arguments against the tool's JSON schema, evaluates the tenant policy (denylist, allowlist, CEL rules, HITL list) and only then forwards the call via JSON-RPC 2.0. A call without a session_id is refused.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
Content-TypeYesapplication/json

Request Body:

json
{
  "server_id": "srv-abc123",
  "tool_name": "read_file",
  "arguments": {"path": "/tmp/data.txt"},
  "tenant_id": "tenant-alpha",
  "session_id": "sess-xyz789",
  "sts_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
FieldTypeRequiredDescription
server_idstringYesTarget MCP server ID
tool_namestringYesName of the tool to call
argumentsobjectYesTool arguments (validated against JSON schema)
tenant_idstringYesTenant identifier
session_idstringYesSession the call runs in (POST /v1/sessions). The session's allowlist/budget and the tenant policy are enforced against it
sts_tokenstringNoPer-hop agent identity token (feature-flagged: GATEZ_AGENT_IDENTITY=on)

Response: 200 OK

json
{
  "result": {"content": "file contents here..."},
  "latency_ms": 42,
  "server_id": "srv-abc123",
  "tool_name": "read_file"
}

Error Responses:

StatusTypeDescription
202pending_approvalTool call requires HITL approval (returns approval_id)
400session_requiredNo session_id — open a session first
400validation_failedArgument validation failed against tool JSON schema
401identity_required / identity_invalidAgent identity is on and the per-hop token is missing or does not verify (the verifier detail is logged, not returned)
403session_not_found / session_inactive / session_tenant_mismatchThe session is gone, not active, or belongs to another tenant
403tool_not_allowedTool not in the session allowlist (or on its denylist)
403policy_deniedDenied by the tenant policy: denylist, allowlist, or CEL rules (configured rules with no match deny)
404server_not_foundMCP server not found
429budget_exceededSession token budget exceeded
503session_store_unavailable / policy_unavailable / hitl_unavailableRedis outage — the call was not executed; retry

HITL Pending Response: 202 Accepted

json
{
  "status": "pending_approval",
  "approval_id": "hitl-abc123",
  "message": "Tool call requires human approval"
}

curl Example:

bash
curl -X POST http://localhost:5001/v1/mcp/tools/call \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "server_id": "srv-abc123",
    "tool_name": "read_file",
    "arguments": {"path": "/tmp/data.txt"},
    "tenant_id": "tenant-alpha",
    "session_id": "sess-xyz789"
  }'

:::note Every tool call is logged to the ClickHouse agent_audit_log table with hashed input/output values. Tool calls within a session update the session's tool call count. :::

:::note Agent Identity (Feature-Flagged) When GATEZ_AGENT_IDENTITY=on, the optional sts_token field enables per-hop agent identity verification. L3 verifies the token signature, checks expiry, enforces replay defense (jti denylist), and extracts dual principals (originating human + acting agent) for authorization. See the Agent Identity Guide for details.

When the feature is off (default), the sts_token field is ignored. :::


A2A Agents ​

GET /v1/a2a/agents ​

List registered A2A agents.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}

Response: 200 OK

json
{
  "agents": [],
  "total": 0,
  "note": "Register agents via POST /v1/a2a/agents"
}

curl Example:

bash
curl http://localhost:5001/v1/a2a/agents \
  -H "Authorization: Bearer $TOKEN"

POST /v1/a2a/agents ​

Register an A2A agent. The agent card is persisted in Redis.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
Content-TypeYesapplication/json

Request Body:

json
{
  "id": "agent-summarizer",
  "name": "Document Summarizer",
  "url": "http://summarizer-agent:9000/a2a",
  "tenant_id": "tenant-alpha",
  "capabilities": ["summarize", "extract"],
  "description": "Summarizes documents and extracts key points"
}

Response: 201 Created

json
{
  "id": "agent-summarizer",
  "status": "registered"
}

curl Example:

bash
curl -X POST http://localhost:5001/v1/a2a/agents \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "agent-summarizer",
    "name": "Document Summarizer",
    "url": "http://summarizer-agent:9000/a2a",
    "tenant_id": "tenant-alpha",
    "capabilities": ["summarize", "extract"],
    "description": "Summarizes documents"
  }'

POST /v1/a2a/send ​

Send a message from one agent to another. Supports delegation chain tracking, loop detection, and chain depth limits.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
Content-TypeYesapplication/json

Request Body:

json
{
  "from_agent": "agent-orchestrator",
  "to_agent": "agent-summarizer",
  "message": {"task": "summarize", "document_id": "doc-123"},
  "tenant_id": "tenant-alpha",
  "session_id": "sess-xyz789",
  "delegation_chain": [],
  "sts_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
FieldTypeRequiredDescription
from_agentstringYesSending agent ID
to_agentstringYesTarget agent ID
messageobjectYesMessage payload
tenant_idstringYesTenant identifier
session_idstringNoSession ID for context
delegation_chainarrayNoList of agents already in the chain (for loop detection)
sts_tokenstringNoPer-hop agent identity token (feature-flagged: GATEZ_AGENT_IDENTITY=on)

Response (agent registered, forwarded successfully): 200 OK

json
{
  "task_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "from": "agent-orchestrator",
  "to": "agent-summarizer",
  "delegation_chain": ["agent-orchestrator"],
  "result": {"summary": "..."}
}

Response (agent not registered): 202 Accepted

json
{
  "task_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "pending",
  "from": "agent-orchestrator",
  "to": "agent-summarizer",
  "delegation_chain": ["agent-orchestrator"],
  "note": "Target agent not registered — task queued"
}

Error Responses:

StatusTypeDescription
400chain_depth_exceededDelegation chain depth exceeds max 5
409circular_delegationTarget agent already in delegation chain (loop detected)
502—Target agent returned error or is unreachable

curl Example:

bash
curl -X POST http://localhost:5001/v1/a2a/send \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "from_agent": "agent-orchestrator",
    "to_agent": "agent-summarizer",
    "message": {"task": "summarize", "document_id": "doc-123"},
    "tenant_id": "tenant-alpha",
    "delegation_chain": []
  }'

:::note Agent Identity (Feature-Flagged) When GATEZ_AGENT_IDENTITY=on, the optional sts_token field enables per-hop agent identity verification. L3 verifies the token's aud claim matches the receiving agent (to_agent), enforces replay defense, and extracts the dual principal for authorization. The hop token is propagated to the next agent so the act_chain survives the delegation. See the Agent Identity Guide for details.

When the feature is off (default), the sts_token field is ignored. :::


GET /v1/a2a/tasks/:task_id ​

Get the status of an A2A task.

Path Parameters:

ParameterDescription
task_idTask identifier returned from /v1/a2a/send

Response: 200 OK

json
{
  "task_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "pending",
  "message": "Task status tracking via Redis (full implementation in progress)"
}

curl Example:

bash
curl http://localhost:5001/v1/a2a/tasks/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer $TOKEN"

Sessions ​

GET /v1/sessions ​

List sessions for a tenant.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
x-tenant-idNoTenant identifier (defaults to "default")

Response: 200 OK

json
{
  "sessions": [
    {
      "id": "sess-xyz789",
      "tenant_id": "tenant-alpha",
      "agent_id": "agent-orchestrator",
      "tool_allowlist": ["read_file", "search"],
      "status": "active",
      "created_at": "2026-03-25T10:00:00Z"
    }
  ],
  "total": 1
}

curl Example:

bash
curl http://localhost:5001/v1/sessions \
  -H "Authorization: Bearer $TOKEN" \
  -H "x-tenant-id: tenant-alpha"

POST /v1/sessions ​

Create a new agent session with explicit tool allowlist and budget.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
Content-TypeYesapplication/json

Request Body:

json
{
  "tenant_id": "tenant-alpha",
  "agent_id": "agent-orchestrator",
  "tool_allowlist": ["read_file", "search", "write_file"],
  "token_budget": 50000,
  "metadata": {"purpose": "document processing"}
}

Response: 201 Created

json
{
  "id": "sess-xyz789",
  "tenant_id": "tenant-alpha",
  "agent_id": "agent-orchestrator",
  "tool_allowlist": ["read_file", "search", "write_file"],
  "token_budget": 50000,
  "tokens_used": 0,
  "tool_calls": 0,
  "status": "active",
  "created_at": "2026-03-25T10:00:00Z"
}

curl Example:

bash
curl -X POST http://localhost:5001/v1/sessions \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "tenant_id": "tenant-alpha",
    "agent_id": "agent-orchestrator",
    "tool_allowlist": ["read_file", "search"],
    "token_budget": 50000
  }'

WARNING

Every agent session must have an explicit tool allowlist. The gateway denies by default — tools not in the allowlist are rejected with 403 Forbidden.


GET /v1/sessions/:session_id ​

Get session details.

Path Parameters:

ParameterDescription
session_idSession identifier

Response: 200 OK

json
{
  "id": "sess-xyz789",
  "tenant_id": "tenant-alpha",
  "agent_id": "agent-orchestrator",
  "tool_allowlist": ["read_file", "search"],
  "token_budget": 50000,
  "tokens_used": 1200,
  "tool_calls": 5,
  "status": "active",
  "created_at": "2026-03-25T10:00:00Z"
}

Error Response: 404 Not Found

json
{"error": "Session not found"}

curl Example:

bash
curl http://localhost:5001/v1/sessions/sess-xyz789 \
  -H "Authorization: Bearer $TOKEN"

DELETE /v1/sessions/:session_id ​

Terminate a session. Logs a session_terminate audit entry.

Path Parameters:

ParameterDescription
session_idSession identifier

Response: 200 OK

json
{
  "id": "sess-xyz789",
  "status": "terminated",
  "tenant_id": "tenant-alpha"
}

Error Response: 404 Not Found

json
{"error": "Session not found"}

curl Example:

bash
curl -X DELETE http://localhost:5001/v1/sessions/sess-xyz789 \
  -H "Authorization: Bearer $TOKEN"

GET /v1/sessions/:session_id/tools ​

List tools available to a session (filtered by the session's tool allowlist and tenant scope).

Path Parameters:

ParameterDescription
session_idSession identifier

Response: 200 OK

json
{
  "tools": [
    {
      "tool": {"name": "read_file", "description": "Read file contents", "inputSchema": {}},
      "server_id": "srv-abc123",
      "server_name": "file-server"
    }
  ],
  "total": 1
}

Error Response: 404 Not Found

json
{"error": "Session not found"}

curl Example:

bash
curl http://localhost:5001/v1/sessions/sess-xyz789/tools \
  -H "Authorization: Bearer $TOKEN"

POST /v1/sessions/:session_id/execute ​

Execute a tool within a session context. Delegates to the tool call handler with the session ID automatically injected for constraint enforcement.

Path Parameters:

ParameterDescription
session_idSession identifier

Request Body:

json
{
  "server_id": "srv-abc123",
  "tool_name": "read_file",
  "arguments": {"path": "/tmp/data.txt"},
  "tenant_id": "tenant-alpha"
}

Response: Same as POST /v1/mcp/tools/call.

curl Example:

bash
curl -X POST http://localhost:5001/v1/sessions/sess-xyz789/execute \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "server_id": "srv-abc123",
    "tool_name": "read_file",
    "arguments": {"path": "/tmp/data.txt"},
    "tenant_id": "tenant-alpha"
  }'

Security / HITL ​

GET /v1/policies/:tenant_id ​

Get the security policy for a tenant. The response carries stored: true when a policy is saved for the tenant, false when the defaults are shown because none is saved. A tenant without a stored policy cannot call tools — POST /v1/mcp/tools/call answers 403 {"error":"policy_missing"} until an operator saves one (deny by default).

Path Parameters:

ParameterDescription
tenant_idTenant identifier

Response: 200 OK

json
{
  "tenant_id": "tenant-alpha",
  "hitl_required_tools": ["delete_file", "execute_command"],
  "max_concurrent_sessions": 10,
  "max_tool_calls_per_session": 100,
  "allowed_network_hosts": ["api.example.com"],
  "updated_at": "2026-03-25T10:00:00Z",
  "stored": true
}

curl Example:

bash
curl http://localhost:5001/v1/policies/tenant-alpha \
  -H "Authorization: Bearer $TOKEN"

PUT /v1/policies/:tenant_id ​

Set or update the security policy for a tenant. Entries of tool_allowlist, tool_denylist and hitl_required_tools are a bare tool name or <server_id>:<tool> (the Operator Portal's Tools page stores this form); tool_denylist and hitl_required_tools also accept <server_name>:<tool>. An allowlist never admits by server name, because tenants choose their server names (W2-D7-44). Entries are parsed at the first :; server ids and names may not contain : (registration, rename and OpenAPI import answer 400 invalid_server_identity), and an existing server id may be re-registered only by its owning tenant or a platform admin (409 server_id_taken). Platform operators only: a tenant user answers 403 {"error":"policy_write_forbidden"} even for its own tenant (a tenant must not be able to remove its own deny-by-default, HITL gates or blast-radius limits). Reads stay own-tenant-or-operator.

Path Parameters:

ParameterDescription
tenant_idTenant identifier

Request Body:

json
{
  "hitl_required_tools": ["delete_file", "execute_command"],
  "max_concurrent_sessions": 10,
  "max_tool_calls_per_session": 100,
  "allowed_network_hosts": ["api.example.com"]
}

Response: 200 OK

json
{
  "tenant_id": "tenant-alpha",
  "hitl_required_tools": ["delete_file", "execute_command"],
  "max_concurrent_sessions": 10,
  "max_tool_calls_per_session": 100,
  "allowed_network_hosts": ["api.example.com"],
  "updated_at": "2026-03-25T12:00:00Z"
}

curl Example:

bash
curl -X PUT http://localhost:5001/v1/policies/tenant-alpha \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "hitl_required_tools": ["delete_file", "execute_command"],
    "max_concurrent_sessions": 10,
    "max_tool_calls_per_session": 100,
    "allowed_network_hosts": ["api.example.com"]
  }'

GET /v1/hitl/pending ​

List pending HITL (human-in-the-loop) approval requests for a tenant.

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
x-tenant-idNoTenant identifier (defaults to "default")

Response: 200 OK

json
{
  "pending": [
    {
      "id": "hitl-abc123",
      "session_id": "sess-xyz789",
      "tenant_id": "tenant-alpha",
      "tool_name": "delete_file",
      "arguments": {"path": "/data/important.txt"},
      "status": "pending",
      "request_type": "tool_call",
      "created_at": "2026-03-25T10:05:00Z"
    }
  ],
  "total": 1
}

curl Example:

bash
curl http://localhost:5001/v1/hitl/pending \
  -H "Authorization: Bearer $TOKEN" \
  -H "x-tenant-id: tenant-alpha"

POST /v1/hitl/:approval_id/approve ​

Approve a pending HITL request.

Path Parameters:

ParameterDescription
approval_idHITL approval request identifier

Response: 200 OK

json
{
  "id": "hitl-abc123",
  "status": "approved",
  "resolved_at": "2026-03-25T10:10:00Z"
}

Error Response: 404 Not Found

json
{"error": "Approval not found"}

curl Example:

bash
curl -X POST http://localhost:5001/v1/hitl/hitl-abc123/approve \
  -H "Authorization: Bearer $TOKEN"

POST /v1/hitl/:approval_id/deny ​

Deny a pending HITL request.

Path Parameters:

ParameterDescription
approval_idHITL approval request identifier

Response: 200 OK

json
{
  "id": "hitl-abc123",
  "status": "denied",
  "resolved_at": "2026-03-25T10:10:00Z"
}

Error Response: 404 Not Found

json
{"error": "Approval not found"}

curl Example:

bash
curl -X POST http://localhost:5001/v1/hitl/hitl-abc123/deny \
  -H "Authorization: Bearer $TOKEN"

Elicitation ​

MCP elicitation enables mid-task structured input collection from humans. An agent can pause execution, request specific structured data (defined by a JSON schema), and resume once the user responds.

POST /v1/elicit ​

Create an elicitation request (pauses agent workflow, waits for user input).

Headers:

HeaderRequiredDescription
AuthorizationYesBearer {jwt-token}
Content-TypeYesapplication/json

Request Body:

json
{
  "session_id": "sess-xyz789",
  "tenant_id": "tenant-alpha",
  "tool_name": "configure_deployment",
  "message": "Please confirm the deployment target environment.",
  "schema": {
    "type": "object",
    "properties": {
      "environment": {"type": "string", "enum": ["staging", "production"]},
      "confirm": {"type": "boolean"}
    },
    "required": ["environment", "confirm"]
  }
}
FieldTypeRequiredDescription
session_idstringYesSession requesting elicitation
tenant_idstringYesTenant identifier
tool_namestringYesTool that triggered the elicitation
messagestringYesHuman-readable prompt for the user
schemaobjectYesJSON Schema defining expected response structure

Response: 202 Accepted

json
{
  "elicitation_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "pending",
  "type": "elicitation",
  "message": "Waiting for user input"
}

curl Example:

bash
curl -X POST http://localhost:5001/v1/elicit \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "sess-xyz789",
    "tenant_id": "tenant-alpha",
    "tool_name": "configure_deployment",
    "message": "Please confirm the deployment target.",
    "schema": {"type": "object", "properties": {"environment": {"type": "string"}}, "required": ["environment"]}
  }'

POST /v1/elicit/:elicit_id/respond ​

Respond to a pending elicitation with structured input.

Path Parameters:

ParameterDescription
elicit_idElicitation request identifier

Request Body: (must conform to the schema defined in the elicitation request)

json
{
  "environment": "staging",
  "confirm": true
}

Response: 200 OK

json
{
  "elicitation_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "responded",
  "response": {
    "environment": "staging",
    "confirm": true
  }
}

Error Response: 404 Not Found

json
{"error": "Elicitation not found"}

curl Example:

bash
curl -X POST http://localhost:5001/v1/elicit/550e8400-e29b-41d4-a716-446655440000/respond \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"environment": "staging", "confirm": true}'

Metrics ​

GET /metrics ​

Prometheus-format metrics endpoint.

Response: 200 OK (text/plain, Prometheus exposition format)

# HELP agent_gateway_tool_calls_total Total tool calls
# TYPE agent_gateway_tool_calls_total counter
agent_gateway_tool_calls_total 847
# HELP agent_gateway_tool_calls_denied Tool calls denied by policy
# TYPE agent_gateway_tool_calls_denied counter
agent_gateway_tool_calls_denied 12
# HELP agent_gateway_tool_latency_seconds Tool call latency
# TYPE agent_gateway_tool_latency_seconds histogram
agent_gateway_tool_latency_seconds_bucket{le="0.1"} 800
# HELP agent_gateway_sessions_total Sessions created
# TYPE agent_gateway_sessions_total counter
agent_gateway_sessions_total 156
# HELP agent_gateway_sessions_active Active sessions
# TYPE agent_gateway_sessions_active gauge
agent_gateway_sessions_active 23
# HELP agent_gateway_a2a_hops_total A2A message hops
# TYPE agent_gateway_a2a_hops_total counter
agent_gateway_a2a_hops_total 89
# HELP agent_gateway_hitl_requests_total HITL requests created
# TYPE agent_gateway_hitl_requests_total counter
agent_gateway_hitl_requests_total 34
# HELP agent_gateway_hitl_approved HITL requests approved
# TYPE agent_gateway_hitl_approved counter
agent_gateway_hitl_approved 28
# HELP agent_gateway_hitl_denied HITL requests denied
# TYPE agent_gateway_hitl_denied counter
agent_gateway_hitl_denied 6
# HELP agent_gateway_tool_poisoning_detected Tool poisoning attempts
# TYPE agent_gateway_tool_poisoning_detected counter
agent_gateway_tool_poisoning_detected 1

curl Example:

bash
curl http://localhost:5001/metrics

Endpoint Summary ​

MethodPathDescription
GET/Service info and endpoint discovery
GET/healthHealth check
GET/metricsPrometheus metrics
GET/v1/mcp/serversList MCP servers
POST/v1/mcp/serversRegister MCP server
GET/v1/mcp/servers/:server_idGet MCP server details
DELETE/v1/mcp/servers/:server_idRemove MCP server
GET/v1/mcp/servers/:server_id/toolsList server tools
GET/v1/mcp/toolsDiscover all tools
POST/v1/mcp/tools/callExecute a tool
GET/v1/a2a/agentsList A2A agents
POST/v1/a2a/agentsRegister A2A agent
POST/v1/a2a/sendSend A2A message
GET/v1/a2a/tasks/:task_idGet A2A task status
GET/v1/sessionsList sessions
POST/v1/sessionsCreate session
GET/v1/sessions/:session_idGet session
DELETE/v1/sessions/:session_idTerminate session
GET/v1/sessions/:session_id/toolsList session tools
POST/v1/sessions/:session_id/executeExecute tool in session
GET/v1/policies/:tenant_idGet security policy
PUT/v1/policies/:tenant_idSet security policy
GET/v1/hitl/pendingList pending HITL requests
POST/v1/hitl/:approval_id/approveApprove HITL request
POST/v1/hitl/:approval_id/denyDeny HITL request
POST/v1/elicitCreate elicitation request
POST/v1/elicit/:elicit_id/respondRespond to elicitation

Webhooks — hitl_pending (W2-D8-08) ​

When a tool call is parked for human approval, the agent gateway notifies the approvers, fire-and-forget, right after the approval is queued:

  • Destinations: the global HITL_WEBHOOK_URL (raw JSON) and the tenant's notification preferences (PUT /api/notifications/preferences on the control plane): webhook_url receives the raw JSON, slack_url receives a Slack incoming-webhook message, both only when enabled_types lists hitl_pending.
  • Payload (raw JSON):
json
{
  "event": "hitl_pending", "approval_id": "…", "tenant_id": "insurance", "session_id": "…", "agent_id": "agent:triage",
  "tool_name": "book_appointment", "request_type": "approval",
  "argument_keys": ["patient_id", "slot"],
  "portal_url": "https://operator.example/approvals/<approval_id>", "created_at": "2026-10-06T09:00:00Z"
}

Argument values are never sent (they may hold PII) and neither is a digest of them; approval_id is the correlation key. The global hook links to the Operator Portal (GATEZ_OPERATOR_PORTAL_URL); a tenant's own hooks link to the Developer Portal (GATEZ_DEVELOPER_PORTAL_URL), where tenant users approve their own sessions.

  • Slack message: one template — a text fallback, a section with tool / agent / tenant / session, and a "Review approval" button that opens portal_url.
  • Destination rules (checked again at send time, whatever the control plane accepted when the URL was stored): https only (plain http only under GATEZ_ENV=local), no userinfo, a real public hostname (no single-label service names, no .local / .internal / .localhost), every resolved address public (no loopback, private, link-local, CGNAT, IPv6 ULA or mapped ranges — the resolved addresses are pinned, so DNS rebinding cannot redirect the request), and redirects are never followed. A refused destination makes no request and is logged with status_code 0.
  • Signature: with GATEZ_WEBHOOK_SECRET set, every request carries X-Gatez-Timestamp (unix seconds) and X-Gatez-Signature: sha256=<hex HMAC-SHA256(secret, "<timestamp>.<body>")>; verify both and reject stale timestamps.
  • Delivery: 5 s timeout, one retry after 1 s on a transport failure or 5xx (none on 4xx), the same URL delivered once, at most 64 deliveries in flight across all tenants and 60 hitl_pending deliveries per tenant per minute (beyond that the event is dropped and logged), every attempt logged to gateway.webhook_delivery_log (webhook_id = global | tenant_slack | tenant_webhook, URL masked to scheme + host + port).
  • Slack cards escape tenant-controlled text (tool and agent names), so a tool name cannot inject a mention or a link.
  • The /approvals/:id routes land in the UI lane (Operator Portal first, Developer Portal in its parity work).

Enterprise API + AI + Agent Gateway