Skip to content

Create Firewall Rule

Create a new firewall rule for the authenticated user.

POST /v1/firewall-rules
ParameterTypeRequiredDescription
namestringYesRule name (max 128 characters)
is_enabledbooleanYesWhether rule is active
priorityintegerYesPriority (-1000 to 1000, higher = first)
scopestringYesprompt or response
typestringYessubstring or regex
patternstringYesPattern to match
actionstringYesblock, mask, or warn
replacementstringNoReplacement text for mask action (default: [redacted])
const rule = await client.firewallRules.create({
name: 'Block Credit Cards',
priority: 100,
is_enabled: true,
scope: 'prompt',
type: 'regex',
pattern: '\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}',
action: 'block'
});
{
"data": {
"id": 123,
"user_id": 456,
"name": "Block Credit Cards",
"is_enabled": true,
"priority": 100,
"scope": "prompt",
"type": "regex",
"pattern": "\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}",
"action": "block",
"replacement": null,
"created_at": "2025-11-10T12:00:00Z",
"updated_at": "2025-11-10T12:00:00Z"
}
}
pattern: '\\d{3}-\\d{2}-\\d{4}'
pattern: '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}'
pattern: '(sk-[a-zA-Z0-9]{32,}|Bearer [a-zA-Z0-9]{32,})'
pattern: '\\+?1?\\d{9,15}'