Skip to content

Updating Rules

Modify existing rules using PUT (full replacement) or PATCH (partial update) operations.


PUT /api/rules/:id

Replace the entire rule with new configuration. All fields must be provided.

Endpoint

PUT /api/rules/:id

Authentication

Requires API Key with Policy Definition permission.

Request Body

Same as creating a rule - all fields required.

Response

Returns the updated rule object with the new configuration.


PATCH /api/rules/:id

Partially update a rule. Only specified fields are modified.

Endpoint

PATCH /api/rules/:id

Authentication

Requires API Key with Policy Definition permission.

Request Body

Provide only the fields you want to update:

{
  "description": "Updated description",
  "enable": false
}

Response

Returns the updated rule object:

Response Format
{
  "id": "rule-uuid-123",
  "name": "Block PII in External APIs",
  "description": "Updated description",
  "action": "block",
  "enable": false,
  "icapMode": "REQMOD",
  "apps": ["app-uuid-1"],
  "obfuscations": ["obfuscation-uuid-1"],
  "userFilters": [],
  "groupFilters": [],
  "timeFilterEnabled": false,
  "timeFilter": null,
  "createdAt": 1704067200,
  "updatedAt": 1704240000
}

Examples

Update Rule Description

Change only the description field using PATCH.

RULE_ID="rule-uuid-123"

curl -X PATCH "https://your-shield-host:8080/api/rules/$RULE_ID" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"description": "Updated: Prevent PII leakage to third-party APIs"}'
import requests

BASE_URL = "https://your-shield-host:8080"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

rule_id = "rule-uuid-123"

response = requests.patch(
    f"{BASE_URL}/api/rules/{rule_id}",
    headers=HEADERS,
    json={"description": "Updated: Prevent PII leakage to third-party APIs"}
)

print(f"Updated: {response.json()['description']}")
const axios = require('axios');

const BASE_URL = 'https://your-shield-host:8080';
const HEADERS = { 'Authorization': 'Bearer YOUR_API_KEY' };

const ruleId = 'rule-uuid-123';

const response = await axios.patch(
  `${BASE_URL}/api/rules/${ruleId}`,
  { description: 'Updated: Prevent PII leakage to third-party APIs' },
  { headers: HEADERS }
);

console.log(`Updated: ${response.data.description}`);
Replace Entire Rule

Use PUT to completely replace a rule's configuration.

RULE_ID="rule-uuid-123"

curl -X PUT "https://your-shield-host:8080/api/rules/$RULE_ID" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Block PII in External APIs v2",
    "description": "Updated rule with new obfuscations",
    "action": "block",
    "enable": true,
    "icapMode": "REQMOD",
    "apps": ["app-uuid-1", "app-uuid-3"],
    "obfuscations": ["obfuscation-uuid-2"]
  }'
import requests

BASE_URL = "https://your-shield-host:8080"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

rule_id = "rule-uuid-123"

rule = {
    "name": "Block PII in External APIs v2",
    "description": "Updated rule with new obfuscations",
    "action": "block",
    "enable": True,
    "icapMode": "REQMOD",
    "apps": ["app-uuid-1", "app-uuid-3"],
    "obfuscations": ["obfuscation-uuid-2"]
}

response = requests.put(f"{BASE_URL}/api/rules/{rule_id}", headers=HEADERS, json=rule)
print(f"Updated rule: {response.json()['name']}")
const axios = require('axios');

const BASE_URL = 'https://your-shield-host:8080';
const HEADERS = { 'Authorization': 'Bearer YOUR_API_KEY' };

const ruleId = 'rule-uuid-123';

const rule = {
  name: 'Block PII in External APIs v2',
  description: 'Updated rule with new obfuscations',
  action: 'block',
  enable: true,
  icapMode: 'REQMOD',
  apps: ['app-uuid-1', 'app-uuid-3'],
  obfuscations: ['obfuscation-uuid-2']
};

const response = await axios.put(`${BASE_URL}/api/rules/${ruleId}`, rule, { headers: HEADERS });
console.log(`Updated rule: ${response.data.name}`);
Add Time Filter to Existing Rule

Update a rule to add time-based filtering.

RULE_ID="rule-uuid-123"

curl -X PATCH "https://your-shield-host:8080/api/rules/$RULE_ID" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "timeFilterEnabled": true,
    "timeFilter": {
      "timeWindows": [{"startTime": "09:00", "endTime": "17:00"}],
      "daysOfWeek": [1, 2, 3, 4, 5],
      "timezone": "America/New_York",
      "behavior": "match"
    }
  }'
import requests

BASE_URL = "https://your-shield-host:8080"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

rule_id = "rule-uuid-123"

update = {
    "timeFilterEnabled": True,
    "timeFilter": {
        "timeWindows": [{"startTime": "09:00", "endTime": "17:00"}],
        "daysOfWeek": [1, 2, 3, 4, 5],
        "timezone": "America/New_York",
        "behavior": "match"
    }
}

response = requests.patch(f"{BASE_URL}/api/rules/{rule_id}", headers=HEADERS, json=update)
print(f"Time filter enabled: {response.json()['timeFilterEnabled']}")
const axios = require('axios');

const BASE_URL = 'https://your-shield-host:8080';
const HEADERS = { 'Authorization': 'Bearer YOUR_API_KEY' };

const ruleId = 'rule-uuid-123';

const update = {
  timeFilterEnabled: true,
  timeFilter: {
    timeWindows: [{ startTime: '09:00', endTime: '17:00' }],
    daysOfWeek: [1, 2, 3, 4, 5],
    timezone: 'America/New_York',
    behavior: 'match'
  }
};

const response = await axios.patch(
  `${BASE_URL}/api/rules/${ruleId}`,
  update,
  { headers: HEADERS }
);
console.log(`Time filter enabled: ${response.data.timeFilterEnabled}`);

Error Responses

Status Code Description
400 Invalid request body or validation error
401 Invalid or expired API key
403 Insufficient permissions (requires Policy Definition)
404 Rule not found
409 Rule name already exists (when changing name)