> ## Documentation Index
> Fetch the complete documentation index at: https://conto.finance/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Spend Limits

> Set per-transaction, daily, weekly, and monthly spending caps for AI agents with budget tracking and automatic resets

# Spend Limit Policies

Spend limit policies control the maximum amount that can be spent per transaction, day, week, or month.

## Configuration

Create a SPEND\_LIMIT policy and add rules via the API:

```bash theme={null}
# Create policy
curl -X POST https://conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Spend Limits", "policyType": "SPEND_LIMIT", "priority": 50, "isActive": true}'

# Add rules
curl -X POST https://conto.finance/api/policies/{policyId}/rules \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -d '{
    "rules": [
      {"ruleType": "MAX_AMOUNT", "operator": "LTE", "value": "500", "action": "ALLOW"},
      {"ruleType": "DAILY_LIMIT", "operator": "LTE", "value": "2000", "action": "ALLOW"},
      {"ruleType": "WEEKLY_LIMIT", "operator": "LTE", "value": "10000", "action": "ALLOW"},
      {"ruleType": "MONTHLY_LIMIT", "operator": "LTE", "value": "30000", "action": "ALLOW"}
    ]
  }'
```

## Rule Types

| Rule Type       | Description                    | Operator | Value                                |
| --------------- | ------------------------------ | -------- | ------------------------------------ |
| `MAX_AMOUNT`    | Maximum per single transaction | `LTE`    | Amount (number)                      |
| `DAILY_LIMIT`   | Maximum total spend per day    | `LTE`    | Amount (number)                      |
| `WEEKLY_LIMIT`  | Maximum total spend per week   | `LTE`    | Amount (number)                      |
| `MONTHLY_LIMIT` | Maximum total spend per month  | `LTE`    | Amount (number)                      |
| `BUDGET_CAP`    | Budget with period             | `LTE`    | `{"amount": N, "period": "MONTHLY"}` |

## How It Works

1. **Per-Transaction**: Checked against the requested amount
2. **Daily/Weekly/Monthly**: Checked against cumulative spend + requested amount

<Info>
  Conto uses fixed-precision monetary values for spend limits, balances, and transaction amounts to avoid floating-point rounding issues in financial calculations.
</Info>

### Example Evaluation

```
Agent: Operations Agent
Daily Limit: $1,000
Spent Today: $750

Request: $300 payment

Evaluation:
- Per-tx check: $300 < limit (pass)
- Daily check: $750 + $300 = $1,050 > $1,000 (FAIL)

Result: DENIED
Reason: "Would exceed daily limit: $250 remaining"
```

## Wallet-Level Limits

In addition to policies, limits can be set on the agent-wallet link:

```json theme={null}
{
  "agentId": "cmm59z8fj000l49h7bjqza11p",
  "walletId": "cmm5b2wal002n49h7ckrtb33r",
  "spendLimitPerTx": 100,
  "spendLimitDaily": 1000,
  "spendLimitWeekly": 5000,
  "spendLimitMonthly": 15000
}
```

These are evaluated **first**, before policy rules.

<Info>
  **Auto-creation defaults:** When an external wallet is auto-created, the system applies these defaults: daily = $1,000, weekly = $5,000, monthly = \$20,000, no per-transaction limit. You can override these when linking a wallet to an agent. Wallet-level limits treat `null`, omitted fields, and `0` as unlimited; use a deny policy or suspend the agent when you need to block spend.
</Info>

## Tracking Spend

The system tracks spending automatically:

* **spentToday** - Resets at midnight UTC
* **spentThisWeek** - Resets Monday midnight UTC
* **spentThisMonth** - Resets 1st of month midnight UTC

## Best Practices

<AccordionGroup>
  <Accordion title="Start Conservative">
    Begin with a low per-transaction cap and increase based on operational needs:

    ```json theme={null}
    {
      "ruleType": "MAX_AMOUNT",
      "operator": "LTE",
      "value": "50",
      "action": "ALLOW"
    }
    ```
  </Accordion>

  <Accordion title="Layer Limits">
    Use multiple limit types for defense in depth:

    * Per-tx: Prevents single large payments
    * Daily: Limits daily exposure
    * Monthly: Controls overall budget
  </Accordion>

  <Accordion title="Different Limits per Agent">
    Create different policies for different agent risk levels:

    * Low-risk agents: Higher limits
    * New agents: Lower limits until proven
    * Critical agents: Strict limits + approval
  </Accordion>
</AccordionGroup>
