Skip to content

First Protected Call

This walkthrough creates the baseline every later tutorial assumes: a running local stack, one zone, one confidential agent app, one protected resource, one active policy, one runtime profile, and one audited Gateway call.

Complete Install Caracal first.

Terminal window
caracal up
caracal status --ready

On Windows PowerShell:

Terminal window
caracal up
caracal status --ready

Create product objects only after readiness succeeds. If readiness fails, run:

Terminal window
caracal status --ready --json

The JSON output shows which service is not ready.

Start a local HTTP upstream on the same Docker network as Caracal:

Terminal window
docker run --rm -d --name caracalDemoUpstream --network caracalData nginx:stable-alpine

On Windows PowerShell:

Terminal window
docker run --rm -d --name caracalDemoUpstream --network caracalData nginx:stable-alpine

Use http://caracalDemoUpstream:80 as the resource upstream URL in guided setup. If you already have an HTTP service that the Gateway container can reach, you can use that URL instead.

Open the Console:

Terminal window
caracal console

On Windows PowerShell:

Terminal window
caracal console

Choose guided setup and use these first-run choices:

StepFirst-run choice
ScenarioInternal HTTP API
ZoneCreate a local evaluation zone.
Agent appCreate a confidential app for the workload.
ResourceUse a stable resource ID, required scopes, and the upstream URL you chose.
ProviderSkipped for the internal HTTP API scenario.
Access policyLet the Console create and activate the starter policy.
ReviewEnable write profile files when this machine should receive the runtime profile and secret file.

The result view shows the zone ID, application ID, resource ID, app client secret, active policy set, profile path, secret-file path, generated profile, and first-success commands.

Guided setup can write the runtime profile and secret file for you. Enable write profile files when you want the Console to create them on the current machine.

If file writing is disabled, copy the generated TOML profile and one-time app client secret from the result view into the paths the Console shows. Keep the secret file readable only by the owner.

The generated profile is the source of runtime configuration for:

  • CARACAL_CONFIG=... caracal run -- <command>
  • new Caracal() in TypeScript and Caracal() in Python
  • caracal.New() in Go

Always generate a profile from the objects you just created instead of hand-authoring runtime configuration.

Use the generated profile path with the command that starts your workload:

Terminal window
CARACAL_CONFIG=/path/to/caracal.toml caracal run -- ./start-agent.sh

On Windows PowerShell:

Terminal window
$env:CARACAL_CONFIG = "C:\path\to\caracal.toml"
caracal run -- .\start-agent.ps1

caracal run exchanges the configured application secret for resource-specific Caracal access tokens and injects them into the environment variables named in the profile. The workload reads those variables and presents the token to the Gateway or protected service.

For SDK-based workloads, the same generated profile is read by the SDK constructors (new Caracal(), Caracal(), caracal.New()).

For a Gateway-routed HTTP resource, send the request to the Gateway URL from the result view and include:

HeaderValue
AuthorizationBearer <Caracal access token>
X-Caracal-ResourceThe resource ID from guided setup.

Run the exact curl or PowerShell command from the Console result view first. It uses the resource ID, protected path, and profile values you just created.

Return to the Console:

  1. Open audit.
  2. Find the request you just made.
  3. Press Enter on the event, or open explain and paste its request ID.

The explanation should show the application, resource, requested scopes, policy version, policy set version, Gateway result, and final decision. If the request failed, the explanation identifies whether to fix runtime config, policy, resource routing, or the upstream service.

Terminal window
docker rm -f caracalDemoUpstream
caracal down

On Windows PowerShell:

Terminal window
docker rm -f caracalDemoUpstream
caracal down

Use caracal purge only when you intentionally want to remove local containers, volumes, config, runtime state, examples, and caches.

Continue with Add SDK to Your App.