Skip to Content
AgentShield
API Reference

Policy Management

Create organization and agent policies, read the current document, and append new immutable versions.

Policies are named documents with immutable versions. The gateway evaluates the current version of the organization's active policy and of the agent's active policy. Document format and precedence: Policy evaluation.

OperationRoles
List and read policiesAny member
Create, replaceowner, admin

Create a policy

Organization policy
{
  "name": "default",
  "scope": "organization",
  "document": {
    "permissions": {
      "allowed": ["tickets.read", "http.get"],
      "denied": ["database.export", "http.delete"],
      "approval_required": ["payment.refund", "http.post"]
    }
  }
}
Agent policy
{
  "name": "billing-agent",
  "scope": "agent",
  "agent_id": "3f2b8c1e-6a4d-4f7e-9b21-5c8d0e7a4b13",
  "document": {
    "agent": { "id": "billing-agent" },
    "permissions": { "allowed": ["invoice.read"], "denied": [], "approval_required": [] }
  }
}
  • scope: "organization" must not include agent_id; scope: "agent" requires it, and the agent must exist in the organization.
  • An organization can have one active organization policy, and each agent one active agent policy. A second create returns 409 conflict; use PUT to change the existing one.
  • Policy names are unique within the organization.
  • The document is validated with the same rules as the gateway's evaluator. An invalid document returns 400 validation_failed.
POST/api/v1/policies

Create a policy and its first immutable version

Bearer sessionoperationId: createPolicy

Inserts an immutable version. A second active policy for the same organization or agent is a conflict.

Request body · required

  • namestringrequired
  • scopestringrequired

    one of organization, agent

  • agent_idstring (uuid)
  • documentPolicyDocumentrequired

    unknown fields rejected

    Show child fields
    • agentobject

      unknown fields rejected

      Show child fields
      • idstring
    • permissionsobjectrequired

      unknown fields rejected

      Show child fields
      • allowedstring[]required
      • deniedstring[]required
      • approval_requiredstring[]required

Responses

  • 201Policy

    Created policy

curl -X POST "http://127.0.0.1:8080/api/v1/policies" \
  -H "Authorization: Bearer $AGENTSHIELD_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @body.json

Examples are generated from the schema. Values are placeholders.

Read

GET/api/v1/policies

List policies in the caller's organization

Bearer sessionoperationId: listPolicies

Evaluation does not read this list. It reads policy_versions.

Responses

  • 200PolicyPage

    Policy page

curl -X GET "http://127.0.0.1:8080/api/v1/policies" \
  -H "Authorization: Bearer $AGENTSHIELD_TOKEN"

Examples are generated from the schema. Values are placeholders.

GET/api/v1/policies/{policyId}

Read one policy and the document of its current version

Bearer sessionoperationId: getPolicy

Implemented for any member of the organization.

Parameters

  • policyIdpath · string (uuid)required

Responses

  • 200any

    Policy and current document

  • 404ErrorBody

    Error

curl -X GET "http://127.0.0.1:8080/api/v1/policies/$POLICY_ID" \
  -H "Authorization: Bearer $AGENTSHIELD_TOKEN"

Examples are generated from the schema. Values are placeholders.

Replace (new version)

PUT appends a new immutable version and moves the policy's current pointer. Earlier versions remain, and decisions keep referring to the version that produced them.

PUT/api/v1/policies/{policyId}

Append a new policy version and move the current pointer

Bearer sessionoperationId: replacePolicy

Appends a version and moves the current pointer. Existing version rows are not edited.

Parameters

  • policyIdpath · string (uuid)required

Request body · required

  • documentPolicyDocumentrequired

    unknown fields rejected

    Show child fields
    • agentobject

      unknown fields rejected

      Show child fields
      • idstring
    • permissionsobjectrequired

      unknown fields rejected

      Show child fields
      • allowedstring[]required
      • deniedstring[]required
      • approval_requiredstring[]required

Responses

  • 200Policy

    Updated policy pointer

curl -X PUT "http://127.0.0.1:8080/api/v1/policies/$POLICY_ID" \
  -H "Authorization: Bearer $AGENTSHIELD_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @body.json

Examples are generated from the schema. Values are placeholders.

curl -s -X PUT http://127.0.0.1:8080/api/v1/policies/$POLICY_ID \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"document":{"permissions":{"allowed":["sample.echo","tickets.read"],"denied":[],"approval_required":["payment.refund"]}}}'

The new version takes effect for the next authorize request. There is no cache to invalidate: the gateway loads the current version on every evaluation.

Was this page helpful?

On this page