Skip to content

Policies CRUD

Enforcement Policies

Create, read, update, and delete enforcement policies programmatically. Policies are evaluated in priority order (highest first) and the most restrictive decision wins.

GET /v1/enforce/policies List all policies for the workspace, ordered by priority. POST /v1/enforce/policies Create a new enforcement policy. PUT /v1/enforce/policies/{id} Update an existing policy. DELETE /v1/enforce/policies/{id} Delete a policy.

Policy Types

Type What It Does Conditions
action_type Matches actions by name Uses action_types field (supports wildcards: delete_*)
threshold Blocks agents below a trust level Uses trust_threshold field
content_pattern Regex match on action content conditions.patterns: array of regex strings
temporal Time/day restrictions conditions.blocked_hours: [0-23], conditions.blocked_days: [1-7]
chain_of_custody Agent chain depth/agent rules conditions.max_chain_depth, conditions.forbidden_agents

Create Policy Example

# Block trades containing sensitive keywords
policy = requests.post(
    "https://www.xybern.com/api/v1/enforce/policies",
    headers={"X-API-Key": API_KEY},
    json={
        "name": "Block Insider Trading Keywords",
        "description": "Block any trade with insider-related language",
        "policy_type": "content_pattern",
        "decision": "block",
        "priority": 200,
        "action_types": ["execute_trade", "modify_order"],
        "conditions": {
            "patterns": [
                "insider.*info",
                "material.*non-public",
                "tip.*from.*executive"
            ]
        }
    }
).json()

# Block all activity on weekends
weekend_policy = requests.post(
    "https://www.xybern.com/api/v1/enforce/policies",
    headers={"X-API-Key": API_KEY},
    json={
        "name": "Weekend Trading Lockout",
        "policy_type": "temporal",
        "decision": "block",
        "priority": 300,
        "action_types": ["execute_trade"],
        "conditions": {"blocked_days": [6, 7]}
    }
).json()