Skip to content

Protect a Gateway-Routed HTTP API

Use Gateway-routed protection when the upstream is HTTP-routable and you want Caracal to enforce every request before it reaches the target. The agent receives a short-lived Caracal mandate; Gateway verifies it, resolves the resource route, attaches the configured upstream credential when needed, forwards the request, and writes action-result audit.

Use Gateway whenUse another guide when
The upstream is HTTP, REST, MCP-over-HTTP, or another Gateway-routable target.The service must verify mandates inside its own process.
You want provider credentials to stay inside the trusted Gateway/STS boundary.The application must call the provider directly and only needs attribution.
You want action-result audit from the central Gateway.The resource server owns result audit after connector verification.

For in-process enforcement, use Protect an Express App, Protect a FastMCP App, Protect a Go net/http Service, or Protect an MCP Server.

Open the Console:

Terminal window
caracal console

Create or select a resource with:

FieldGuidance
Resource identifierStable audience URI, such as resource://billing-api.
ScopesAction-oriented scopes, such as billing:read and billing:submit.
Upstream URLNetwork URL the Gateway can reach.
Gateway applicationThe Caracal application identity Gateway uses for upstream exchanges.
Upstream credential providerThe provider record Gateway uses to attach no credential, a Caracal mandate, OAuth token, API key, or bearer token.

Keep the resource identifier stable even when upstream hosts or provider bindings change.

Provider typeUse when
NoneGateway enforces Caracal access and the upstream expects no credential.
Caracal mandateThe upstream verifies Caracal mandates directly.
OAuth client credentialsGateway needs a machine OAuth token.
OAuth authorization codeGateway needs per-user delegated OAuth consent.
API keyGateway attaches a sealed static API key in a configured header.
Bearer tokenGateway attaches a sealed pre-issued bearer token.

Use Define Resources and Providers for field definitions and Provider Recipes for concrete OpenAI, Google, GitHub, Slack, and internal API examples.

Gateway-routed requests include:

Request partValue
URLGateway URL from the generated profile or Console result view.
AuthorizationBearer <Caracal mandate>.
X-Caracal-ResourceResource identifier.
PathThe protected path you configured for the upstream.

SDKs can build the Gateway request and inject headers for you:

  • TypeScript: caracal.gatewayRequest() and caracal.transport()
  • Python: caracal.gateway_request() and caracal.transport()
  • Go: GatewayRequest() and Transport()

Run these checks before treating the route as ready:

CheckExpected result
Allowed requestGateway forwards to upstream and records action-result audit.
Missing mandateGateway rejects the request.
Missing scopeSTS or Gateway rejects the request.
Wrong resource headerGateway rejects or routes to a different configured resource.
Revoked sessionGateway rejects the old mandate.

Open Console audit and request trace with the request ID. A complete Gateway-routed call has both authorization evidence from STS and action-result evidence from Gateway.

SymptomCheck
Gateway returns 403Token expiry, resource ID, scopes, revocation, and X-Caracal-Resource.
Upstream is unreachableUpstream URL must be reachable from the Gateway container or deployment.
Provider credential not attachedResource must bind exactly one upstream credential provider.
Authorization audit exists but action-result audit is missingThe request did not reach Gateway or failed before route execution.

Related pages: Debug Authorization Decisions and Tail and Query the Audit Stream.