Skip to main content

Universal API Contract (UAC)

The Universal API Contract (UAC) is STOA's gateway-agnostic API definition format. It normalizes API specifications into a common model that can be reconciled to any supported gateway.

Why UAC?​

Different API gateways use different configuration formats:

  • webMethods uses its own REST API with specific resource models
  • Kong uses declarative YAML with services, routes, and plugins
  • Apigee uses API proxies with proxy endpoints and target endpoints

UAC provides a single definition that STOA translates to each gateway's native format through the Gateway Adapter pattern.

UAC Structure​

A UAC contract is a JSON document validated against the UAC v1 JSON Schema (uac_contract_v1_schema.json in the Control Plane API, mirrored by the gateway's Rust types). YAML is shown here for readability and converts 1:1 to JSON:

name: catalog-api                 # kebab-case, unique within the tenant
version: 1.0.0 # semantic version
tenant_id: example # owning tenant
display_name: Catalog API
description: Read access to the product catalog
classification: H # H | VH | VVH (DORA-aligned ICT risk level)
required_policies: [rate-limit, auth-jwt] # derived from classification
status: published # draft | published | deprecated

endpoints:
- path: /catalog/items/{item_id}
methods: [GET]
backend_url: https://backend.example.local/v1/catalog
operation_id: get_catalog_item
# Optional LLM-facing metadata: drives the MCP tool projection
llm:
summary: Fetch a catalog item by id.
intent: Use when an agent needs read-only details about a known item.
tool_name: catalog_get_item
side_effects: read # none | read | write | destructive
safe_for_agents: true
requires_human_approval: false
examples:
- input: { item_id: sku-1234 }
expected_output_contains: { id: sku-1234 }

Serialized as JSON, this document is accepted unchanged by the gateway's POST /admin/contracts endpoint. A published contract must declare at least one endpoint, each with a backend_url, unless it carries an llm_config.

UAC in the GitOps Flow​

The UAC is the artifact that flows through the GitOps pipeline:

UAC Components​

Contract​

FieldRequiredDescription
nameYesUnique contract name within the tenant (kebab-case)
versionYesSemantic version (MAJOR.MINOR.PATCH)
tenant_idYesOwning tenant identifier
classificationYesICT risk level: H, VH or VVH
statusYesLifecycle: draft, published or deprecated
display_name, descriptionNoHuman-readable name and description
required_policiesNoPolicies derived from the classification (recomputed on upsert)
source_spec_url, spec_hashNoSource OpenAPI URL and hash used for drift detection
llm_configNoLLM backend configuration for AI-powered contracts

Policies​

Classification drives the required policies: H requires rate-limit and auth-jwt; VH adds mtls and audit-logging; VVH adds data-encryption and geo-restriction.

Endpoint​

Operations are listed under endpoints[]. Each entry becomes a REST route and, when projected, an MCP tool.

FieldRequiredDescription
pathYesURL path pattern, e.g. /catalog/items/{item_id}
methodsYesAllowed HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)
backend_urlYesBackend URL to proxy requests to
operation_idNoOpenAPI operationId, used for MCP tool naming
input_schema, output_schemaNoJSON Schema for request and response bodies
llmNoLLM-facing metadata for the MCP tool projection (see below)

LLM metadata​

endpoint.llm is optional in v1: a published contract whose endpoint lacks it gets a validation warning, while a malformed block is an error. When present, every field is required:

FieldDescription
summaryShort human-readable tool summary
intentWhen an agent should use this endpoint
tool_nameStable MCP tool name, unique within the contract
side_effectsnone, read, write or destructive
safe_for_agentsWhether autonomous agents may call the endpoint
requires_human_approvalWhether a human approval step precedes invocation
examplesAt least one example with input and an optional expected_output_contains

Hard rule: side_effects: destructive requires requires_human_approval: true. The validator rejects the contract otherwise.

Gateway Adapter Translation​

Each Gateway Adapter implements the translation from UAC to native format:

class GatewayAdapterInterface:
def sync_api(self, api_spec: dict, tenant_id: str) -> AdapterResult:
"""Translate UAC and sync to target gateway."""

def upsert_policy(self, policy_spec: dict) -> AdapterResult:
"""Translate and apply policy."""

def provision_application(self, app_spec: dict) -> AdapterResult:
"""Provision consumer access."""

The adapter guarantees idempotent operations — syncing the same UAC twice produces identical results on the gateway.

Legacy adapter input. The api_spec dictionary passed to sync_api is the deployment's desired state, a flat structure keyed by api_name/apiName that the Control Plane derives for each adapter. It is not the UAC contract format shown above and is not accepted by the contract endpoints.

Shadow Mode (Future)​

In the planned shadow gateway mode, STOA will be able to auto-generate UAC definitions by passively capturing API traffic. This enables onboarding existing APIs without manual specification:

  1. Deploy STOA Gateway in shadow mode alongside existing traffic
  2. Capture request/response patterns
  3. Auto-generate UAC with inferred schemas and policies
  4. Review and publish via Console UI

Cookies and privacy

With your permission, we use cookies to measure visits and understand navigation to improve the site.

Learn more

Google Analytics measures visits and useful clicks. Microsoft Clarity provides masked interaction replays. No advertising use. Your choice is saved for six months. You can change or withdraw it at any time using the “Cookies” button.

Read the audience measurement details