Skip to main content

Advanced Policies

Advanced policy types and the rule engine for complex business requirements.

Policy Rules

Each policy consists of one or more rules. Rules define specific conditions and actions:

Rule Structure

{
  "ruleType": "SINGLE_AMOUNT",
  "operator": "GREATER_THAN",
  "value": "{\"amount\": 500}",
  "action": "REQUIRE_APPROVAL"
}
FieldDescription
ruleTypeType of condition (see below)
operatorComparison operator
valueJSON-encoded value for comparison
actionALLOW, DENY, or REQUIRE_APPROVAL

Supported Rule Types

Rule TypeDescriptionExample Value
MAX_AMOUNTPer-transaction amount"500"
DAILY_LIMITDaily spend cap"1000"
WEEKLY_LIMITWeekly spend cap"5000"
MONTHLY_LIMITMonthly spend cap"20000"
BUDGET_CAPBudget allocation"{\"amount\": 50000, \"period\": \"MONTHLY\"}"
TIME_WINDOWTime window restriction"{\"start\": \"09:00\", \"end\": \"18:00\"}"
DAY_OF_WEEKDay restriction"[\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]"
DATE_RANGETemporal validity"{\"start\": \"2024-01-01\", \"end\": \"2024-03-31\"}"
BLACKOUT_PERIODBlock during windows"{\"windows\": [{\"start\": \"02:00\", \"end\": \"06:00\", \"reason\": \"Maintenance\"}]}"
ALLOWED_CATEGORIESAllowed categories"[\"software\", \"infrastructure\"]"
BLOCKED_CATEGORIESBlocked categories"[\"gambling\", \"adult\"]"
ALLOWED_COUNTERPARTIESAllowed addresses"[\"0x123...\", \"0x456...\"]"
BLOCKED_COUNTERPARTIESBlocked addresses"[\"0xdead...\"]"
VELOCITY_LIMITTransaction frequency"{\"maxCount\": 10, \"period\": \"HOUR\"}"
REQUIRE_APPROVAL_ABOVEApproval threshold"2500"
GEOGRAPHIC_RESTRICTIONBlocked countries"[\"CU\", \"IR\", \"KP\", \"SY\", \"RU\"]"
TRUST_SCOREMin trust score"70"
COUNTERPARTY_STATUSTrust level requirement"{\"status\": \"TRUSTED\"}"
CONTRACT_ALLOWLISTAllowed contracts"{\"contracts\": [\"0x...\"], \"protocols\": [\"uniswap\"]}"

Supported Operators

OperatorAliasesDescription
EQUALSEQExact match
NOT_EQUALSNEQNot equal
GREATER_THANGTGreater than
GREATER_THAN_OR_EQUALGTE, GREATER_THAN_OR_EQUALSGreater or equal
LESS_THANLTLess than
LESS_THAN_OR_EQUALLTE, LESS_THAN_OR_EQUALSLess or equal
ININ_LISTValue in list
NOT_INNOT_IN_LISTValue not in list
BETWEEN-Within range
NOT_BETWEEN-Outside range

Rule Actions

  • ALLOW - If condition matches, allow the transaction
  • DENY - If condition matches, block the transaction
  • REQUIRE_APPROVAL - If condition matches, require manual approval

Example: High-Value Approval Rule

Block transactions over $500 unless manually approved:
{
  "name": "High Value Transaction Review",
  "policyType": "APPROVAL_THRESHOLD",
  "priority": 80,
  "rules": [
    {
      "ruleType": "SINGLE_AMOUNT",
      "operator": "GREATER_THAN",
      "value": "{\"amount\": 500}",
      "action": "REQUIRE_APPROVAL"
    }
  ]
}

Geographic Restrictions (OFAC)

Block transactions to sanctioned countries:
curl -X POST https://www.conto.finance/api/policies/{policyId}/rules \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -d '{
    "rules": [{
      "ruleType": "GEOGRAPHIC_RESTRICTION",
      "operator": "IN_LIST",
      "value": "[\"NK\", \"IR\", \"SY\", \"CU\", \"RU\"]",
      "action": "DENY"
    }]
  }'

OFAC Sanctioned Countries

CodeCountry
CUCuba
IRIran
KPNorth Korea
SYSyria
RURussia
BYBelarus
MMMyanmar
VEVenezuela
Always consult legal counsel for compliance requirements. This is not legal advice.

Approval Thresholds

Require manual approval above certain amounts:
{
  "policyType": "APPROVAL_THRESHOLD",
  "rules": [
    {
      "type": "AMOUNT_THRESHOLD",
      "threshold": 500,
      "approvers": ["admin", "finance"]
    }
  ]
}
When triggered:
  • Payment returns REQUIRES_APPROVAL
  • Approvers are notified
  • Payment held until approved or denied

Velocity Limits

Control transaction frequency:
curl -X POST https://www.conto.finance/api/policies/{policyId}/rules \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -d '{
    "rules": [
      {
        "ruleType": "VELOCITY_LIMIT",
        "operator": "LESS_THAN",
        "value": "{\"maxCount\": 10, \"period\": \"HOUR\"}",
        "action": "ALLOW"
      },
      {
        "ruleType": "VELOCITY_LIMIT",
        "operator": "LESS_THAN",
        "value": "{\"maxAmount\": 1000, \"period\": \"DAILY\"}",
        "action": "ALLOW"
      }
    ]
  }'
Velocity counting is per-wallet, per-agent. It counts transactions with status CONFIRMED or PENDING. The current transaction is included in the count (+1).
Use cases:
  • Prevent rapid drain attacks
  • Detect unusual patterns
  • Rate limit agent activity

Category Restrictions

Allow or block specific categories:
curl -X POST https://www.conto.finance/api/policies/{policyId}/rules \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -d '{
    "rules": [
      {
        "ruleType": "BLOCKED_CATEGORIES",
        "operator": "IN_LIST",
        "value": "[\"gambling\", \"adult\", \"weapons\"]",
        "action": "DENY"
      },
      {
        "ruleType": "ALLOWED_CATEGORIES",
        "operator": "IN_LIST",
        "value": "[\"infrastructure\", \"ai_services\", \"marketing\"]",
        "action": "ALLOW"
      }
    ]
  }'
Category matching is case-insensitive. If no category is provided in the payment request, ALLOWED_CATEGORIES rules with ALLOW action are skipped (not denied).

Budget Allocations

Allocate budgets by department or project:
{
  "policyType": "BUDGET_ALLOCATION",
  "rules": [
    {
      "type": "DEPARTMENT_BUDGET",
      "department": "ENGINEERING",
      "monthlyBudget": 50000,
      "rollover": false
    },
    {
      "type": "PROJECT_BUDGET",
      "projectId": "PROJECT_123",
      "totalBudget": 100000
    }
  ]
}

Expiration Policies

Time-limited permissions:
{
  "policyType": "EXPIRATION",
  "rules": [
    {
      "type": "VALID_UNTIL",
      "expiresAt": "2024-12-31T23:59:59Z"
    },
    {
      "type": "VALID_BETWEEN",
      "startDate": "2024-01-01",
      "endDate": "2024-03-31"
    }
  ]
}
Use cases:
  • Temporary elevated access
  • Contract-based limits
  • Trial periods

Composite Policies

Combine multiple conditions with AND/OR logic:
{
  "policyType": "COMPOSITE",
  "rules": [
    {
      "type": "AND",
      "conditions": [
        { "type": "AMOUNT_LESS_THAN", "amount": 1000 },
        { "type": "CATEGORY_IS", "category": "INFRASTRUCTURE" }
      ]
    },
    {
      "type": "OR",
      "conditions": [
        { "type": "TRUSTED_COUNTERPARTY" },
        { "type": "MANUAL_OVERRIDE" }
      ]
    }
  ]
}

Example: High-Security Agent

Complete configuration for a high-security agent:
[
  {
    "name": "OFAC Compliance",
    "policyType": "GEOGRAPHIC",
    "priority": 100,
    "rules": [{ "type": "BLOCK_COUNTRIES", "countries": ["NK","IR","SY","CU","RU"] }]
  },
  {
    "name": "Whitelist Only",
    "policyType": "WHITELIST",
    "priority": 90,
    "rules": [{ "type": "ADDRESS_WHITELIST", "addresses": ["0x..."] }]
  },
  {
    "name": "Strict Limits",
    "policyType": "SPEND_LIMIT",
    "priority": 80,
    "rules": [
      { "type": "PER_TRANSACTION", "maxAmount": 100 },
      { "type": "DAILY", "maxAmount": 500 }
    ]
  },
  {
    "name": "All Require Approval",
    "policyType": "APPROVAL_THRESHOLD",
    "priority": 70,
    "rules": [{ "type": "AMOUNT_THRESHOLD", "threshold": 0 }]
  }
]

Bulk Policy Operations

Create Multiple Policies

curl -X POST https://conto.finance/api/policies/bulk \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -d '{
    "policies": [
      { "name": "Policy 1", "policyType": "SPEND_LIMIT", ... },
      { "name": "Policy 2", "policyType": "TIME_WINDOW", ... }
    ]
  }'

Assign to Multiple Agents

curl -X PUT https://conto.finance/api/policies/bulk \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -d '{
    "assignments": [
      { "policyId": "policy_1", "agentIds": ["agent_a", "agent_b"] },
      { "policyId": "policy_2", "agentIds": ["agent_c"] }
    ]
  }'