API Reference
Restriction Rules API

Restriction Rules API

Restriction rules are security policies that block, mask, or flag queries before they reach an LLM. Use these endpoints to manage rules that protect against unauthorized content, sensitive data exposure, and compliance violations.

Rule Object

{
  "id": "rest_01HXYZ",
  "name": "Block SSN disclosure",
  "trigger_phrase": "social security number",
  "action": "block",
  "severity": "high",
  "rule_type": "keyword",
  "created_at": "2025-01-15T10:30:00Z",
  "updated_at": "2025-01-15T10:30:00Z"
}

Endpoints

MethodPathDescription
GET/restriction-rulesList all restriction rules
POST/restriction-rulesCreate a new restriction rule
PUT/restriction-rules/{id}Update an existing rule
DELETE/restriction-rules/{id}Delete a restriction rule

List Restriction Rules

GET /api/v1/restriction-rules

Returns all restriction rules for your organization.

Response

[
  {
    "id": "rest_01HXYZ",
    "name": "Block SSN disclosure",
    "trigger_phrase": "social security number",
    "action": "block",
    "severity": "high",
    "rule_type": "keyword",
    "created_at": "2025-01-15T10:30:00Z",
    "updated_at": "2025-01-15T10:30:00Z"
  }
]

cURL

curl https://api.xilos.ai/api/v1/restriction-rules \
  -H "Authorization: Bearer YOUR_X..._KEY"

Create Restriction Rule

POST /api/v1/restriction-rules

Request Body

FieldTypeRequiredDescription
namestringYesHuman-readable name for the rule.
trigger_phrasestringYesPhrase or pattern that activates the rule.
actionstringYesAction to take: block, mask, or flag.
severitystringNoSeverity level: high, medium, or low. Default: medium.
rule_typestringYesRule engine: ai (semantic matching) or keyword (exact match).

Info: - block — The query is rejected and never reaches the LLM.

  • mask — Sensitive content in the query is redacted before forwarding to the LLM.
  • flag — The query proceeds but is flagged in the audit log for review.

cURL

curl -X POST https://api.xilos.ai/api/v1/restriction-rules \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_X..._KEY" \
  -d '{
    "name": "Block SSN disclosure",
    "trigger_phrase": "social security number",
    "action": "block",
    "severity": "high",
    "rule_type": "keyword"
  }'

Response

Returns the created Rule Object.


Update Restriction Rule

PUT /api/v1/restriction-rules/{id}

Updates an existing restriction rule. All fields are optional — only provided fields are updated.

Request Body

FieldTypeRequiredDescription
namestringNoUpdated name.
trigger_phrasestringNoUpdated trigger phrase.
actionstringNoUpdated action.
severitystringNoUpdated severity.
rule_typestringNoUpdated rule type.

cURL

curl -X PUT https://api.xilos.ai/api/v1/restriction-rules/rest_01HXYZ \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_X..._KEY" \
  -d '{
    "action": "mask",
    "severity": "medium"
  }'

Response

Returns the updated rule object.


Delete Restriction Rule

DELETE /api/v1/restriction-rules/{id}

Deletes a restriction rule. This action cannot be undone.

cURL

curl -X DELETE https://api.xilos.ai/api/v1/restriction-rules/rest_01HXYZ \
  -H "Authorization: Bearer YOUR_X..._KEY"

Response

{
  "id": "rest_01HXYZ",
  "deleted": true
}

Choosing a Rule Type

Keyword Rules

Use rule_type: "keyword" for exact phrase matching. Fast and deterministic — ideal for compliance blocks on specific terms like "social security number" or "credit card number."

AI Rules

Use rule_type: "ai" for semantic matching. The AI engine evaluates intent, so paraphrased or indirect attempts to trigger the restriction are still caught. Ideal for nuanced policy enforcement.

Combine Both

Layer keyword rules for hard blocks and AI rules for nuanced flagging. Review flagged queries in the audit trail to refine your policies.