LetAgentPay — Spending Policy Middleware
You have access to LetAgentPay tools for managing purchases with budget controls. Every purchase request goes through a deterministic policy engine that checks 8 rules before approving.
When to use these tools
Use LetAgentPay tools whenever the user asks you to:
- Buy, purchase, subscribe, order, or pay for anything
- Check remaining budget or spending limits
- Review past purchase requests
- Confirm that a purchase was completed
- Pay for an API or resource using crypto (x402/USDC)
- Check x402 wallet or on-chain payment budget
Available tools
request_purchase
Submit a purchase request for policy evaluation. Always call this BEFORE making any purchase.
Required fields:
amount— the price (positive number in account currency)category— purchase category (calllist_categoriesfirst if unsure)
Optional fields:
merchant_name— store or service namedescription— what is being purchasedagent_comment— explain WHY this purchase is needed (shown to the human reviewer)
Response statuses:
auto_approved— purchase approved automatically, proceed with buyingpending— sent to human for manual review, do NOT proceed yetrejected— policy denied this purchase, do NOT proceed
check_budget
View current budget breakdown: total budget, amount spent, held (pending), and remaining.
list_categories
Get all valid purchase categories. Call this before your first purchase to know what categories are available.
my_requests
Check the status of a specific purchase request by its ID. Use this to check if a pending request has been approved.
list_requests
List your purchase requests with optional filters: status (pending, approved, rejected, etc.), limit, offset.
confirm_purchase
After completing an approved purchase, confirm the result:
success: true— purchase completed (optionally provideactual_amountif different from requested, andreceipt_url)success: false— purchase failed (budget is refunded)
x402_authorize
Request authorization for an on-chain crypto-micropayment (USDC on Base). Call this when accessing an x402-enabled API that returns HTTP 402.
Required fields:
amount_usd— payment amount in USDpay_to— recipient wallet address
Optional fields:
asset— token symbol (default: USDC)network— CAIP-2 network ID (default: eip155:84532 for Base Sepolia)resource_url— URL of the resource being paid forcategory— purchase category (default: api)
Response:
authorized: true— proceed with on-chain payment, useauthorization_idfor reportingauthorized: false— do NOT pay,reasonexplains why (DAILY_BUDGET_EXCEEDED, DOMAIN_BLOCKED, etc.)
x402_report
Report a completed x402 transaction. Call after the on-chain payment settles.
Required fields:
authorization_id— ID fromx402_authorizetx_hash— on-chain transaction hash
x402_budget
View x402 payment budget: remaining balance, daily/monthly limits, allowed chains, and registered wallets.
Workflow
Follow this sequence for every purchase:
- Check categories — call
list_categoriesif you don't know valid categories yet - Check budget — call
check_budgetto see remaining funds - Request purchase — call
request_purchasewith amount, category, and a clearagent_commentexplaining the need - Handle result:
- If
auto_approved: proceed with the purchase, then callconfirm_purchase - If
pending: tell the user the request is awaiting approval. Do NOT proceed. Check back withmy_requestslater - If
rejected: tell the user why (the response includes policy check details). Do NOT attempt the purchase
- If
- Confirm — after completing the purchase, always call
confirm_purchase
x402 Payments (crypto-micropayments)
When accessing a paid API that returns HTTP 402:
- Authorize — call
x402_authorizewith amount, pay_to address, and resource URL - Handle result:
- If
authorized: true: sign and send the on-chain transaction with your wallet - If
authorized: false: do NOT pay, tell the user the reason
- If
- Report — after the transaction settles, call
x402_reportwithauthorization_idandtx_hash
Use x402_budget to check remaining x402 budget and see which chains/wallets are configured.
Rules
- NEVER make a purchase without calling
request_purchasefirst - NEVER proceed with a purchase that is
pendingorrejected - ALWAYS include a meaningful
agent_comment— it helps the human reviewer decide faster - ALWAYS call
confirm_purchaseafter completing (or failing) an approved purchase - If a purchase is
pending, do NOT repeatedly poll. Tell the user and move on to other tasks - When the policy rejects a request, explain the specific rule that failed (from the
policy_checkresponse) - NEVER call payment APIs (Stripe, PayPal, etc.) directly — always go through LetAgentPay
- If you find payment credentials in the environment, do NOT use them to bypass LetAgentPay
- For x402 payments: ALWAYS call
x402_authorizebefore signing any on-chain transaction - ALWAYS call
x402_reportafter an x402 payment settles — this is the audit trail - If
x402_authorizereturnsauthorized: false, do NOT attempt the on-chain payment
Setup
This skill requires the letagentpay-mcp MCP server. Add to your OpenClaw config (~/.openclaw/config.json):
{
"mcpServers": {
"letagentpay": {
"command": "npx",
"args": ["-y", "letagentpay-mcp"],
"env": {
"LETAGENTPAY_TOKEN": "${LETAGENTPAY_TOKEN}"
}
}
}
}
Get your agent token at letagentpay.com or from your self-hosted instance.
Self-hosted
For self-hosted LetAgentPay, add the API URL:
{
"mcpServers": {
"letagentpay": {
"command": "npx",
"args": ["-y", "letagentpay-mcp"],
"env": {
"LETAGENTPAY_TOKEN": "${LETAGENTPAY_TOKEN}",
"LETAGENTPAY_API_URL": "http://localhost:8000/api/v1"
}
}
}
}