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.
| Operation | Roles |
|---|---|
| List and read policies | Any member |
| Create, replace | owner, admin |
Create a policy
{
"name": "default",
"scope": "organization",
"document": {
"permissions": {
"allowed": ["tickets.read", "http.get"],
"denied": ["database.export", "http.delete"],
"approval_required": ["payment.refund", "http.post"]
}
}
}{
"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 includeagent_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; usePUTto 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.
/api/v1/policiesCreate a policy and its first immutable version
Inserts an immutable version. A second active policy for the same organization or agent is a conflict.
Request body · required
namestringrequiredscopestringrequiredone of
organization,agentagent_idstring (uuid)documentPolicyDocumentrequiredunknown fields rejected
Show child fields
agentobjectunknown fields rejected
Show child fields
idstring
permissionsobjectrequiredunknown fields rejected
Show child fields
allowedstring[]requireddeniedstring[]requiredapproval_requiredstring[]required
Responses
201PolicyCreated 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.jsonExamples are generated from the schema. Values are placeholders.
Read
/api/v1/policiesList policies in the caller's organization
Evaluation does not read this list. It reads policy_versions.
Responses
200PolicyPagePolicy 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.
/api/v1/policies/{policyId}Read one policy and the document of its current version
Implemented for any member of the organization.
Parameters
policyIdpath · string (uuid)required
Responses
200anyPolicy and current document
404ErrorBodyError
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.
/api/v1/policies/{policyId}Append a new policy version and move the current pointer
Appends a version and moves the current pointer. Existing version rows are not edited.
Parameters
policyIdpath · string (uuid)required
Request body · required
documentPolicyDocumentrequiredunknown fields rejected
Show child fields
agentobjectunknown fields rejected
Show child fields
idstring
permissionsobjectrequiredunknown fields rejected
Show child fields
allowedstring[]requireddeniedstring[]requiredapproval_requiredstring[]required
Responses
200PolicyUpdated 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.jsonExamples 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?