Policies API

The Policies API manages governance rules that fire on request or response. See Security Policies for the full condition and action reference.

GET /api/policies
List all policies for the current tenant

Parameters:

ParamTypeDescription
limitnumberMax results (default 50)
offsetnumberPagination offset
phasestringFilter by phase: request or response
enabledbooleanFilter by enabled status

Response (200):

{
  "data": [
    {
      "id": "policy_abc123",
      "name": "block-injection",
      "phase": "request",
      "condition": {
        "type": "injection_score",
        "threshold": 0.7
      },
      "action": "block",
      "enabled": true,
      "fireCount": 42,
      "createdAt": "2026-01-20T08:00:00Z",
      "updatedAt": "2026-01-20T08:00:00Z"
    }
  ],
  "total": 6,
  "limit": 50,
  "offset": 0
}
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: process.env.RIVANO_API_KEY! });

const policies = await rivano.policies.list({ phase: 'request', enabled: true });
POST /api/policies
Create a new policy

Request body:

{
  "name": "redact-pii-in-responses",
  "phase": "response",
  "on": "*",
  "condition": {
    "type": "pii_detected",
    "entities": ["email", "phone", "name"]
  },
  "action": "redact",
  "redactionStrategy": "mask",
  "enabled": true
}
FieldRequiredDescription
nameYesUnique policy name
phaseYesrequest or response
conditionYesCondition object (see Policies docs)
actionYesblock, redact, or warn
onNoAgent name or * for all agents
redactionStrategyNoRequired when action is redact
enabledNoDefault true

Response (201):

{
  "data": {
    "id": "policy_xyz789",
    "name": "redact-pii-in-responses",
    "phase": "response",
    "condition": { "type": "pii_detected", "entities": ["email", "phone", "name"] },
    "action": "redact",
    "redactionStrategy": "mask",
    "enabled": true,
    "fireCount": 0,
    "createdAt": "2026-04-04T10:00:00Z",
    "updatedAt": "2026-04-04T10:00:00Z"
  }
}
const policy = await rivano.policies.create({
  name: 'redact-pii-in-responses',
  phase: 'response',
  condition: { type: 'pii_detected', entities: ['email', 'phone', 'name'] },
  action: 'redact',
  redactionStrategy: 'mask',
  enabled: true,
});
PUT /api/policies/:id
Update an existing policy

Request body (all fields optional — send only what you want to change):

{
  "enabled": false,
  "condition": {
    "type": "injection_score",
    "threshold": 0.85
  }
}

Response (200): Updated policy object (same shape as POST response).

await rivano.policies.update('policy_abc123', { enabled: false });
DELETE /api/policies/:id
Delete a policy

Response (200):

{ "success": true }
await rivano.policies.delete('policy_abc123');
GET /api/policies/templates
List available policy templates

Response (200):

{
  "data": [
    {
      "id": "foundational",
      "name": "Foundational Policy Pack",
      "description": "Core injection and PII policies for production agents",
      "policyCount": 4
    },
    {
      "id": "hipaa-pii",
      "name": "HIPAA PII Pack",
      "description": "Extended PHI detection for healthcare applications",
      "policyCount": 6
    },
    {
      "id": "financial-pii",
      "name": "Financial PII Pack",
      "description": "Credit card, account number, and routing number detection",
      "policyCount": 3
    }
  ]
}
const templates = await rivano.policies.listTemplates();
templates.data.forEach(t => console.log(t.id, t.policyCount, 'policies'));
POST /api/policies/templates/apply
Apply a policy template to the tenant

Request body:

{
  "template": "foundational",
  "agentName": "*",
  "enabled": true
}
FieldRequiredDescription
templateYesTemplate ID from the list endpoint
agentNameNoApply to specific agent or * for all. Default: *
enabledNoWhether policies are enabled on creation. Default: true

Response (201):

{
  "created": 4,
  "policies": [
    { "id": "policy_001", "name": "block-injection" },
    { "id": "policy_002", "name": "redact-pii-responses" },
    { "id": "policy_003", "name": "warn-high-token-requests" },
    { "id": "policy_004", "name": "block-pii-in-requests" }
  ]
}
const result = await rivano.policies.applyTemplate('foundational', {
  agentName: '*',
  enabled: true,
});
console.log(`Applied ${result.created} policies`);