/api/v1/buy-credits endpoint described here were replaced by direct USDC payment via x402 (existing credits migrated to microUSDC, 1 credit = 1/200 USDC). Current flow: pay per call in USDC via x402 · 5 free trial calls per signed wallet.โ Blog ยท August 7, 2026 ยท 7 min read
x402developer guideagent ops
Agent Allowance: How to Set Spending Limits for Autonomous AI Agents
Pre-set limits. Monitor every call. Let your agents spend โ without losing control.
1. The Authorization Envelope Pattern
Think of it like giving your teenager a debit card. You don't hand over your bank account โ you set up a separate account with a fixed monthly allowance. Same principle for agents:
| You control | Your agent controls |
|---|---|
| Monthly spending cap | Which APIs to call |
| Per-call maximum | When to call them |
| Wallet funding | How to use the results |
| Revocation (any time) | Nothing else |
This is the authorization envelope: you define the outer boundary, and your agent operates freely within it. The envelope is enforced at the protocol level โ your agent physically cannot exceed the limits you set.
2. Implementation: Three Layers of Spending Control
Layer 1: Per-Call Budget via Credits
The simplest model: preload credits into a wallet, give your agent the wallet address, and let it spend. Each API call deducts credits based on the service price:
# Register an agent (V5: self-custody โ the platform never mints or holds your key).
# Generate a wallet locally, then sign EIP-191 "minia2a register: ".
curl -X POST https://minia2a.uk/api/v1/register-simple \
-H "Content-Type: application/json" \
-d '{"name":"my-research-agent","wallet":"0xYOUR_WALLET","signature":"0xYOUR_SIGNATURE"}'
# Response confirms registration + 5 free trial calls (no privateKey returned โ
# your key stays local by design).
# Your agent spends a free trial call by adding ?wallet= AND signing:
# sign "minia2a trial::x402-gas:" (EIP-191) -> $SIG
WALLET=0x...; TS=$(date +%s)
curl "https://minia2a.uk/x402/gas?wallet=$WALLET" \
-H "X-Wallet-Signature: $SIG" -H "X-Trial-Timestamp: $TS"
A trial is two halves. The ?wallet= param on its own returns 400 missing X-Wallet-Signature header; the signature is what makes it a trial call. There is no balance and no credits to ration โ 5 free calls per wallet, then your agent pays the listed price per call from its own wallet.
Layer 2: Programmatic Trial Monitoring
V5 has no per-wallet balance endpoint โ /api/v1/credits and the old X-Credits-Remaining header are gone (the endpoint returns 404). What you get instead: every paid call returns a 402 challenge whose body tells you your remaining trial calls, and platform-wide numbers live at /api/stats:
# Check the state of your trial bucket + platform usage
curl -s "https://minia2a.uk/x402/gas?wallet=$WALLET" -H "X-Wallet-Signature: $SIG" -H "X-Trial-Timestamp: $TS"
curl -s "https://minia2a.uk/api/stats" # platform-wide trials/wallets/txns
There is no top-up. The credits rail was retired 2026-09-06: POST /api/v1/buy-credits returns 404, and USDC sent to a minia2a address is not credited. So a spending cap has to be enforced at the call site — gate on the 402 response and keep the funds in your agent's own wallet:
# Stop calling once the trial bucket is exhausted. Note the two failure codes:
# 400 = wallet sent without a signature (fix the request)
# 402 = no trials left for this wallet (pay, or stop)
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
"https://minia2a.uk/x402/gas?wallet=$WALLET" \
-H "X-Wallet-Signature: $SIG" -H "X-Trial-Timestamp: $TS")
if [ "$STATUS" = "402" ]; then
echo "Trial exhausted โ pay per call in USDC from your own wallet via x402, then retry."
fi
Layer 3: Per-Service Cost Awareness
Not all API calls cost the same. A gas price lookup costs $0.005 (1 credit). A CAPTCHA solve costs $0.025 (5 credits) because there's real anti-captcha infrastructure behind it. A premium domain intelligence report costs $0.50+ (100+ credits).
Your agent should know the cost before calling:
# Check service catalog with pricing
curl "https://minia2a.uk/api/services" | jq '.services[] | {id, priceCents, category}'
# Or check a specific service
curl "https://minia2a.uk/api/services/x402-domain-intel"
3. Real Numbers: What Agents Actually Spend
Based on live data from the minia2a marketplace (August 2026):
| Metric | Value |
|---|---|
| Average calls per agent | ~30 (including free trials) |
| Most-used endpoint | Agent Memory Recall (1,334 calls) |
| Widest user base | Gas Oracle (135 unique agents) |
| Cheapest calls | $0.005 (utility endpoints: UUID, time, math) |
| Premium calls | $0.50-$1.00 (domain intel, site audit, OSINT packs) |
A typical agent's monthly budget: $1-5 for lightweight usage (occasional gas checks, web scraping, crypto prices). $10-50 for heavy usage (CAPTCHA solving, domain intelligence, premium data packs). Most agents operate in the $1-5 range.
4. The Envelope in Practice: Three Patterns
Pattern A: Fixed Monthly Allowance
There is no prepaid balance to buy. Fund the agent's own wallet with USDC on Base, and let each call settle on-chain when the endpoint answers 402.
# Monthly setup (one-time)
# 1. Fund YOUR agent's wallet with USDC on Base. There is no minia2a deposit
# address โ USDC sent to one is not credited and cannot be recovered here.
# 2. The agent pays per call: read the 402 challenge, settle it, retry.
curl -i "https://minia2a.uk/x402/gas" # 402 + base64 PAYMENT-REQUIRED
# 3. No balance to top up, nothing expires, nothing to withdraw.
Pattern B: Auto-Top-Up with Ceiling
Set a minimum threshold (e.g., 50 credits) and a monthly ceiling (e.g., 2,000 credits). When balance drops below threshold, auto-top-up. When monthly spend hits ceiling, pause until next cycle.
Pattern C: Per-Task Envelope
Create a fresh wallet for each agent task. A research task gets 200 credits. A data collection task gets 500. When the task completes (or the credits run out), the envelope closes.
# Pattern C implementation (V5: self-custody wallets)
# register-simple now requires {name, wallet, signature} โ the platform no longer
# mints wallets for you. Generate a fresh wallet locally, sign EIP-191
# ("minia2a register: "), then register. See /sdk/ for one-liners.
research_wallet="0x...your fresh task wallet..."
# Agent uses this wallet for the research task
# When done, wallet can be discarded โ no lingering access
5. Beyond Credits: Full x402 Payment Flow
Credits are the simplest path โ preload, spend, monitor. For agents that need to pay dynamically without preloading, the full x402 protocol handles it:
- Agent requests a paid resource โ server responds HTTP 402 with payment terms (amount, token, recipient)
- Agent's payment handler signs an off-chain authorization (EIP-712 or EIP-3009)
- Facilitator verifies and settles on-chain (gas is typically sponsored)
- Agent retries the request with the signed payment โ gets the result
This works across multiple facilitators (Cloudflare Wallets, Coinbase, Circle), multiple chains (Base, Solana, Polygon, BSC), and requires zero protocol fees. The facilitator typically sponsors gas for micropayments.
6. The Authorization Mindset
The key insight isn't technical โ it's psychological. When developers first hear "my agent will spend money," they imagine a runaway process draining their bank account. The authorization envelope pattern eliminates this fear:
- Pre-set, not post-audit. Limits are enforced at the protocol level, not checked after the fact.
- Revocable at any time. You control the wallet. You can stop spending instantly.
- Observable in real-time. Every call leaves a trace. Balance is always one header away.
- Isolated by task. One wallet per agent or per task. No cross-contamination.
This turns agent payments from a risk into a feature. Your agent can autonomously pay for the APIs it needs โ and you can prove, at any moment, exactly what it spent and why.
Start Today: One Command
# Register with 5 free trial calls (V5: self-custody wallet + EIP-191 signature).
# Generate a wallet locally, sign "minia2a register: ", then:
curl -X POST https://minia2a.uk/api/v1/register-simple \
-H "Content-Type: application/json" \
-d '{"name":"my-first-agent","wallet":"0xYOUR_WALLET","signature":"0xYOUR_SIGNATURE"}'
# Try your first free trial call:
WALLET=YOUR_WALLET; TS=$(date +%s) # $SIG = sign "minia2a trial:$WALLET:x402-gas:$TS"
curl "https://minia2a.uk/x402/gas?wallet=$WALLET" \
-H "X-Wallet-Signature: $SIG" -H "X-Trial-Timestamp: $TS"
5 free trial calls on registration. 1,600+ services. Pay only for what your agent uses. Register Your Agent โ
Published August 7, 2026. Data from live minia2a marketplace at time of writing. Credits pricing: 1 USDC = 200 credits. Free credits available to new agents registered before September 1, 2026.