# Recipes

> Copy-paste curl recipes for payments, policies, x402, MPP, trust lookups, approval notifications, and monitoring.

- Human URL: https://conto.finance/docs/guides/recipes
- Raw Markdown: https://conto.finance/docs/guides/recipes.md
- Terminal view: https://conto.finance/ai/docs/guides/recipes

Documentation group: Integrate

Each recipe assumes you have an active agent with an SDK key. For initial setup, see
[Quickstart](https://conto.finance/docs/quickstart/setup). To create agents, wallets, and SDK keys yourself, see
[Set up in the dashboard instead](https://conto.finance/docs/quickstart/setup#set-up-in-the-dashboard-instead), or the
[Admin SDK](https://conto.finance/docs/sdk/admin) for the API. For the same calls in TypeScript, see
[Send a payment](https://conto.finance/docs/sdk/payments) and [Code examples](https://conto.finance/docs/quickstart/connecting-agents).

Run payment recipes in the agent's runtime with its SDK key. Policy and alert recipes use an
organization API key.

```bash
# Agent SDK key (for payment operations)
export CONTO_API_KEY="conto_agent_your_key_here"

# Org API key (for policy and alert recipes)
export CONTO_ORG_API_KEY="conto_your_org_key_here"
```

### Check payment status

```bash
curl https://conto.finance/api/sdk/payments/REQUEST_ID \
  -H "Authorization: Bearer $CONTO_API_KEY"
```

Returns one of `approved`, `declined`, `review_required`, `processing`, `reconciliation_required`,
`completed`, `failed`, or `expired`. For `declined` and `review_required`, `reasons` says why.

---

### List recent transactions

```bash
curl https://conto.finance/api/sdk/transactions \
  -H "Authorization: Bearer $CONTO_API_KEY"
```

---

### x402 and MPP endpoint calls

Each protocol's API reference documents the pre-authorize, record, and budget/services calls with
full request and response shapes:

- [x402 API reference](https://conto.finance/docs/guides/x402-api-payments#api-reference): pre-authorize, record (including batch), budget, services
- [MPP API reference](https://conto.finance/docs/guides/mpp-session-payments#api-reference): pre-authorize, record settlements, budget, services

For both protocols, record endpoints use flat top-level settlement fields and optional `batchItems`
for per-call detail. Pass the `grantId` and `grantSignature` from the approved pre-authorization to
the record call. A record without a valid grant is flagged as a policy bypass and alerts the owner.

With an [OpenClaw or Hermes skill](https://conto.finance/docs/sdk/skills), the helper covers both x402 calls and requires
the grant when recording:

```bash
bash skills/conto/conto-check.sh x402 0.05 0xPayee https://api.example.com/v1 "" pay_01J...
bash skills/conto/conto-check.sh x402-record 0.05 0xPayee https://api.example.com/v1 pay_01J... 0xTxHash GRANT_ID GRANT_SIGNATURE
```

To set the guardrails those endpoints check, start from the
[x402](https://conto.finance/docs/guides/x402-api-payments#step-1-set-up-x402-policies) or
[MPP](https://conto.finance/docs/guides/mpp-session-payments#step-1-set-up-mpp-policies) starter policy. The
[rule reference](https://conto.finance/docs/policies/advanced#x402-protocol-rules) has the JSON for every x402 and MPP rule.

---

### Approve and confirm an external wallet payment

Follow the [external-wallet flow](https://conto.finance/docs/sdk/payments): request approval, sign through your executor only when authorized, then confirm the transfer hash. Retain the approval ID and token. Confirmation records an existing transfer; never send again to repair a failed confirmation.

---

## Policies

A policy created without `scope` or `agentIds` applies to every agent in the organization. The
recipes below limit each policy to one agent, either with `"scope": "assigned"` and a separate
assignment or with `"agentIds": ["AGENT_ID"]`. Remove both only when the rule should cover every
agent.

### Limit an agent to $50 per day

```bash
curl -X POST https://conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Daily Cap: $50",
    "scope": "assigned",
    "policyType": "SPEND_LIMIT",
    "rules": [
      {
        "ruleType": "DAILY_LIMIT",
        "operator": "LTE",
        "value": "50",
        "action": "ALLOW"
      }
    ]
  }'
```

Then assign it to the agent:

```bash
curl -X POST https://conto.finance/api/agents/AGENT_ID/policies \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "policyId": "POLICY_ID" }'
```

---

### Restrict payments by agent identity

Use identity rules to require a production, low-risk agent with a finance tag and hardware
attestation. Missing identity context fails closed for these allow rules.

```bash
curl -X POST https://conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Finance Agents",
    "agentIds": ["AGENT_ID"],
    "policyType": "COMPOSITE",
    "rules": [
      {
        "ruleType": "AGENT_ENVIRONMENT",
        "operator": "IN_LIST",
        "value": "{\"environments\":[\"PROD\"]}",
        "action": "ALLOW"
      },
      {
        "ruleType": "AGENT_RISK_TIER",
        "operator": "IN_LIST",
        "value": "{\"riskTiers\":[\"LOW\",\"MEDIUM\"]}",
        "action": "ALLOW"
      },
      {
        "ruleType": "AGENT_OWNER_ROLE",
        "operator": "IN_LIST",
        "value": "{\"roles\":[\"OWNER\",\"ADMIN\"]}",
        "action": "ALLOW"
      },
      {
        "ruleType": "AGENT_TAG",
        "operator": "IN_LIST",
        "value": "{\"tags\":[\"finance\"]}",
        "action": "ALLOW"
      },
      {
        "ruleType": "ATTESTATION_LEVEL",
        "operator": "IN_LIST",
        "value": "{\"attestationModes\":[\"SIGNED_REQUEST_WITH_CONTEXT\"]}",
        "action": "ALLOW"
      }
    ]
  }'
```

---

### Require approval above $100

```bash
curl -X POST https://conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Approval Above $100",
    "agentIds": ["AGENT_ID"],
    "policyType": "APPROVAL_THRESHOLD",
    "rules": [
      {
        "ruleType": "REQUIRE_APPROVAL_ABOVE",
        "operator": "GREATER_THAN",
        "value": "100",
        "action": "REQUIRE_APPROVAL"
      }
    ]
  }'
```

---

### Block payments outside business hours

```bash
curl -X POST https://conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Business Hours Only",
    "agentIds": ["AGENT_ID"],
    "policyType": "TIME_WINDOW",
    "rules": [
      {
        "ruleType": "TIME_WINDOW",
        "operator": "BETWEEN",
        "value": "{\"start\": \"09:00\", \"end\": \"17:00\"}",
        "action": "ALLOW"
      },
      {
        "ruleType": "DAY_OF_WEEK",
        "operator": "IN_LIST",
        "value": "[\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]",
        "action": "ALLOW"
      }
    ]
  }'
```

---

### Allowlist specific recipients

```bash
curl -X POST https://conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Approved Vendors Only",
    "agentIds": ["AGENT_ID"],
    "policyType": "COUNTERPARTY",
    "rules": [
      {
        "ruleType": "ALLOWED_COUNTERPARTIES",
        "operator": "IN_LIST",
        "value": "[\"0x1234567890abcdef1234567890abcdef12345678\", \"0xabcdef1234567890abcdef1234567890abcdef12\"]",
        "action": "ALLOW"
      }
    ]
  }'
```

---

### Restrict MPP to allowed services

```bash
curl -X POST https://conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "MPP Service Allowlist",
    "agentIds": ["AGENT_ID"],
    "policyType": "COMPOSITE",
    "rules": [
      {
        "ruleType": "MPP_ALLOWED_SERVICES",
        "operator": "IN_LIST",
        "value": "[\"api.service.com\", \"streaming.provider.io\"]",
        "action": "ALLOW"
      }
    ]
  }'
```

---

### Let an agent tighten its own limits

An agent with an [admin SDK key](https://conto.finance/docs/sdk/authentication#admin-sdk-keys) can tighten the policies that
govern it without a person: add a rule, lower a limit, rename a policy, or turn one on. These
calls use the agent's key. Lower a daily limit to $25:

```bash
curl -X PATCH https://conto.finance/api/policies/POLICY_ID/rules/RULE_ID \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "value": "25" }'
```

Conto refuses a looser change from an agent key with `403` and code `AGENT_KEY_TIGHTEN_ONLY`. The
agent proposes it for an owner to confirm instead:

```bash
curl -X POST https://conto.finance/api/sdk/owner-actions \
  -H "Authorization: Bearer $CONTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "action": "deactivate_policy", "input": { "policy_id": "POLICY_ID" } }'
```

The response includes a `reviewUrl`. Share it with the owner. Nothing changes until they confirm it.

---

## Approvals and trust

### Look up trust for a counterparty address

```bash
curl https://conto.finance/api/sdk/network/trust/0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18 \
  -H "Authorization: Bearer $CONTO_API_KEY"
```

Requires the `network:read` scope. Returns normalized trust information, a relationship summary,
aggregate transaction history, and an active risk-signal count.

---

### Notify Slack about large payments

1. Create an approval threshold rule:

```bash
curl -X POST https://conto.finance/api/policies \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Approval Above $500",
    "agentIds": ["AGENT_ID"],
    "policyType": "APPROVAL_THRESHOLD",
    "rules": [
      {
        "ruleType": "REQUIRE_APPROVAL_ABOVE",
        "operator": "GREATER_THAN",
        "value": "500",
        "action": "REQUIRE_APPROVAL"
      }
    ]
  }'
```

2. Add a Slack notification channel with the `approval.requested` event.

Slack posts each request with a **Review in Conto** link. Approvers decide in the dashboard or from
the email link. See [approval notifications](https://conto.finance/docs/guides/approval-workflows#notify-approvers) for channel
setup.

---

## Monitoring

### Get agent spending summary

```bash
curl "https://conto.finance/api/sdk/analytics?period=month" \
  -H "Authorization: Bearer $CONTO_API_KEY"
```

---

### Get wallet balance

```bash
curl https://conto.finance/api/sdk/wallets \
  -H "Authorization: Bearer $CONTO_API_KEY"
```

Returns all linked wallets with current balances.

---

### List active alerts

```bash
curl "https://conto.finance/api/alerts?status=open" \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY"
```
