> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goantiai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Policies API

> Create and manage access policies.

## Create a policy

```bash theme={null}
curl -X POST https://api.antiailabs.com/api/v1/policies \
  -H "Authorization: Bearer YOUR_CLERK_JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "allow-stripe-read",
    "policy_type": "rego",
    "content": "package oculus.authz\n\ndefault allow = false\n\nallow {\n    input.action == \"stripe:customer:read\"\n    input.subject.status == \"active\"\n}\n"
  }'
```

## List / Get / Update / Delete

```bash theme={null}
GET    /api/v1/policies
GET    /api/v1/policies?active_only=true
GET    /api/v1/policies/{policy_id}
PUT    /api/v1/policies/{policy_id}
DELETE /api/v1/policies/{policy_id}
```

## Simulate a policy decision

```bash theme={null}
curl -X POST https://api.antiailabs.com/api/v1/policies/simulate \
  -H "Authorization: Bearer YOUR_CLERK_JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "subject_id": "your-agent-id",
    "action": "stripe:customer:read",
    "resource": "stripe/customers",
    "context": {}
  }'
```

Response:

```json theme={null}
{
  "allowed": true,
  "decision": "allow",
  "reason": "Matched rule: allow { input.action == \"stripe:customer:read\" }"
}
```

## Version history and rollback

```bash theme={null}
GET  /api/v1/policies/{id}/versions
GET  /api/v1/policies/{id}/versions/{version_number}
POST /api/v1/policies/{id}/rollback?version=3
POST /api/v1/policies/{id}/activate
```
