Skip to main content
POST
Create Custom Rule
Create a custom rule that belongs to your account. Supports AI_SIGNAL, REGEX, and REQUIRE_NEAR rule types. Requires a full-access API key. Created rules start active and run on subsequent validations for your API key.

Request Body

The body is a discriminated union on type. Shared fields:
string
required
Human-readable rule name
string
required
AI_SIGNAL, REGEX, or REQUIRE_NEAR
string
required
fix or flag
string
required
do_not_send or send_with_caution
string
Editable suggested replacement or warning guidance. Omit to allow warning fallback; null clears and suppresses warning fallback.
string
Optional remediation guidance

AI_SIGNAL fields

string
required
AI instruction for the signal
array
required
Keyword gate (at least one string)
string
default:"document"
sentence, paragraph, or document

REGEX fields

string
required
Raw Python regex (max 512 chars)

REQUIRE_NEAR fields

string
required
Raw Python regex for the anchor pattern (max 512 chars)
array
required
Raw Python regex patterns checked near the anchor
integer
default:"100"
Character distance around the anchor
string
default:"either"
before, after, or either
boolean
default:"false"
Case-insensitive matching
string
default:"document"
document or page
integer
default:"1"
Minimum near-pattern hits required

Response

Returns the created custom rule (CustomRuleResponse), including rule_id, source: "custom", active, timestamps, and type-specific fields.

Errors

Example