Skip to Content
AgentShield
Fundamentals

Authorization

How the gateway turns an authenticated request into exactly one recorded decision, and every check that runs between the signature and the policy.

Authorization answers one question for an authenticated agent: may this operation run against this resource right now? The answer is always exactly one of allow, deny, or require_approval, and it is recorded before anything executes.

The authorize request

POST /api/v1/runtime/authorize
Content-Type: application/json
X-AgentShield-Agent-Id: …
X-AgentShield-Timestamp: …
X-AgentShield-Nonce: …
X-AgentShield-Signature: …
{
  "agent_id": "3f2b8c1e-6a4d-4f7e-9b21-5c8d0e7a4b13",
  "organization_id": "9a7e5d2c-1b3f-4c6a-8e0d-2f4b6a8c0e1d",
  "execution_id": "c4d6e8f0-2a4c-4e6a-8c0e-1a3c5e7a9b2d",
  "tool_name": "http.request",
  "operation": "http.get",
  "resource": "https://api.github.com/repos/octo/hello",
  "arguments": { "headers": { "Accept": "application/json" } },
  "requested_at": "2026-11-30T12:00:00Z",
  "idempotency_key": "idem-5f0d2c8e9a1b4c7d"
}

All nine fields are required and unknown fields are rejected. tool_name matches ^[A-Za-z0-9_.:-]{1,128}$, resource is 1–512 characters, arguments must be a JSON object, and idempotency_key is 16–200 printable characters.

The order of checks

Two properties matter here:

  • Before a decision exists, failures (bad signature, replay, budget) return an error and record nothing. Policy never runs.
  • After authentication, every failure is a recorded deny with a reason. A database error during policy load is policy load failed; an invalid stored document is policy evaluation failed. Neither is ever an allow.

The response

OutcomeHTTPBody
allow200decision_id, outcome, explanation
require_approval200Also approval_id and approval_expires_at
deny403The recorded decision
{
  "decision_id": "7f1c2a9e-…",
  "outcome": "require_approval",
  "explanation": {
    "policy_id": "…",
    "policy_version": 3,
    "matched_rule": "approval_required:payment.refund",
    "reason": "approval required"
  },
  "approval_id": "3b9e…",
  "approval_expires_at": "2026-11-30T12:15:00Z"
}

allow does not execute anything. The agent must call execute with the decision_id and the same idempotency_key.

What is written

In a single PostgreSQL transaction the gateway writes:

  1. A tool_invocations row with the tool, operation, resource, the redacted arguments, the SHA-256 of the canonical arguments, and the idempotency key.
  2. An authorization_decisions row with the outcome, explanation, and risk (none for allow, medium for approval, low for deny).
  3. A security_events row of type authorization.decided and its audit-chain link.
  4. For require_approval, a pending approval_requests row bound to the SHA-256 of the raw body, expiring in 15 minutes.
  5. Any behavioral incidents. See Budgets and limits.

If any write fails, the whole transaction rolls back and the agent receives 500 internal_error.

Idempotency

The idempotency_key makes authorize safe to retry. Keys are unique per organization. A retry with the same key, execution_id, tool, operation, resource, and arguments returns the stored decision instead of creating a new one. Reusing a key with any of those fields changed returns 409 conflict ("idempotency key does not match this request"). Every retry still needs a fresh nonce and signature.

The SDK clients generate a new execution_id and key per call unless you pass them, so pass both explicitly when you want a network-level retry to be idempotent.

Where policy comes in

The operation is evaluated as a policy action against the organization's active policy and the agent's active policy. The rules are covered in Policy evaluation, where you can also try them in the playground.

Was this page helpful?

On this page