Skip to main content

Policies API

Manage spending policies and rules.

List Policies

curl https://www.conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_API_KEY"

Response

{
  "policies": [
    {
      "id": "cmm...",
      "name": "Standard Spend Limits",
      "description": "Default spend limits for agents",
      "policyType": "SPEND_LIMIT",
      "priority": 50,
      "isActive": true,
      "rules": [
        {
          "id": "cmm...",
          "ruleType": "MAX_AMOUNT",
          "operator": "LTE",
          "value": "500",
          "action": "ALLOW"
        }
      ],
      "agentPolicies": [
        {
          "id": "...",
          "agent": { "id": "...", "name": "Operations Agent" }
        }
      ]
    }
  ]
}

Get Policy

curl https://www.conto.finance/api/policies/{policyId} \
  -H "Authorization: Bearer $CONTO_API_KEY"

Create Policy

curl -X POST https://www.conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "High-Value Policy",
    "description": "Policy for high-value transactions",
    "policyType": "SPEND_LIMIT",
    "priority": 50,
    "isActive": true
  }'

Request Body

FieldTypeRequiredDescription
namestringYesPolicy name
descriptionstringNoPolicy description
policyTypeenumYesPolicy type (see below)
prioritynumberNoEvaluation priority (0-100, higher = first)
isActivebooleanNoActive state (default: true)

Policy Types

TypeDescription
SPEND_LIMITAmount-based restrictions
TIME_WINDOWHour/day restrictions
MERCHANTMerchant allowlist/blocklist
CATEGORYCategory restrictions
VELOCITYTransaction frequency limits
GEOGRAPHICRegion/country restrictions
APPROVAL_THRESHOLDRequire human approval above amount
COUNTERPARTYApproved vendor lists
BUDGET_ALLOCATIONDepartment/project budgets
WHITELISTApproved address lists
EXPIRATIONTime-limited permissions
COMPOSITEMultiple rules combined
CONTRACT_ALLOWLISTAllowed smart contracts
BLACKOUT_PERIODBlock during maintenance windows

Add Rules to Policy

Rules define the specific conditions for a policy. Each rule has a ruleType, operator, value, and action.
curl -X POST https://www.conto.finance/api/policies/{policyId}/rules \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "rules": [
      {
        "ruleType": "MAX_AMOUNT",
        "operator": "LTE",
        "value": "500",
        "action": "ALLOW"
      },
      {
        "ruleType": "DAILY_LIMIT",
        "operator": "LTE",
        "value": "2000",
        "action": "ALLOW"
      }
    ]
  }'

Rule Types

Rule TypeDescriptionExample Value
MAX_AMOUNTPer-transaction amount limit"500"
DAILY_LIMITDaily cumulative spend"2000"
WEEKLY_LIMITWeekly cumulative spend"10000"
MONTHLY_LIMITMonthly cumulative spend"50000"
BUDGET_CAPBudget with period"{\"amount\": 10000, \"period\": \"MONTHLY\"}"
TIME_WINDOWAllowed hours (HH:MM)"{\"start\": \"09:00\", \"end\": \"17:00\"}"
DAY_OF_WEEKAllowed days"[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\"]"
DATE_RANGEValid date range"{\"start\": \"2024-01-01\", \"end\": \"2024-12-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"[\"0x1234...\", \"0x5678...\"]"
BLOCKED_COUNTERPARTIESBlocked addresses"[\"0xdead...\"]"
VELOCITY_LIMITTransaction frequency"{\"maxCount\": 10, \"period\": \"HOUR\"}"
REQUIRE_APPROVAL_ABOVEApproval threshold"2500"
GEOGRAPHIC_RESTRICTIONBlocked countries"[\"IR\", \"KP\", \"RU\"]"
TRUST_SCOREMin trust score"70"
CONTRACT_ALLOWLISTAllowed contracts"{\"contracts\": [\"0x...\"]}"

Operators

OperatorAliasesDescription
EQUALSEQExact match
NOT_EQUALSNEQNot equal
GREATER_THANGTGreater than
GTEGREATER_THAN_OR_EQUALGreater than or equal
LESS_THANLTLess than
LTELESS_THAN_OR_EQUALLess than or equal
ININ_LISTValue in list
NOT_INNOT_IN_LISTValue not in list
BETWEEN-Between range
NOT_BETWEEN-Outside range

Actions

ActionDescription
ALLOWAllow if condition passes, deny if it fails
DENYDeny if condition matches
REQUIRE_APPROVALRequire human approval if condition matches

Assign Policy to Agent

curl -X POST https://www.conto.finance/api/agents/{agentId}/policies \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"policyId": "cmm..."}'
Multi-policy AND logic: When multiple policies are assigned to an agent, ALL must pass for a payment to be approved. The first DENY stops evaluation immediately.

Remove Policy from Agent

curl -X DELETE "https://www.conto.finance/api/agents/{agentId}/policies?policyId=cmm..." \
  -H "Authorization: Bearer $CONTO_API_KEY"
The policyId is passed as a query parameter, not a path parameter.

Update Policy

curl -X PATCH https://www.conto.finance/api/policies/{policyId} \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Policy Name",
    "priority": 75,
    "isActive": false
  }'

Update Rule

curl -X PATCH https://www.conto.finance/api/policies/{policyId}/rules/{ruleId} \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "7500",
    "action": "REQUIRE_APPROVAL"
  }'

Delete Rule

curl -X DELETE https://www.conto.finance/api/policies/{policyId}/rules/{ruleId} \
  -H "Authorization: Bearer $CONTO_API_KEY"

Delete Policy

Deleting a policy removes it from all agents. Consider deactivating instead.
curl -X DELETE https://www.conto.finance/api/policies/{policyId} \
  -H "Authorization: Bearer $CONTO_API_KEY"

Violation Types

When a payment is denied, the response includes violation details:
{
  "status": "DENIED",
  "violations": [
    {
      "type": "DAILY_LIMIT",
      "limit": 1000,
      "current": 1150,
      "message": "Would exceed daily limit: $-150.00 remaining of $1000 daily limit"
    }
  ]
}
Violation TypeDescription
INSUFFICIENT_BALANCEWallet balance too low
PER_TX_LIMITPer-transaction limit exceeded
DAILY_LIMITDaily spending limit exceeded
WEEKLY_LIMITWeekly spending limit exceeded
MONTHLY_LIMITMonthly spending limit exceeded
TIME_WINDOWOutside allowed hours/days
BLOCKED_COUNTERPARTYRecipient is blocked
WHITELIST_VIOLATIONRecipient not in allowed list
CATEGORY_RESTRICTIONCategory blocked or not allowed
VELOCITY_LIMITTransaction frequency exceeded
GEOGRAPHIC_RESTRICTIONRestricted country
BUDGET_EXCEEDEDBudget cap exceeded
EXPIRED_PERMISSIONDate range expired
CONTRACT_NOT_ALLOWEDContract not in allowlist
BLACKOUT_PERIODBlackout/maintenance window