The primary use case for AgentCash is calling APIs that require payment. Endpoints may charge via x402 (on-chain USDC transfer) or MPP (signed off-chain payment intent); AgentCash handles both transparently. This guide covers the flow from your agent’s perspective.Documentation Index
Fetch the complete documentation index at: https://agentcash.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Basic usage
Ask your agent to fetch data from a premium endpoint:
Use AgentCash to fetch https://stableenrich.dev/api/company/lookup with body {"domain": "anthropic.com"}.
The agent calls the fetch tool (in MCP mode) or uses the CLI, which:
- Sends the request to the endpoint
- Receives a
402 Payment Requiredresponse listing accepted protocols (x402,mpp) and networks - Picks a protocol your wallet supports and signs the payment proof
- Retries the request with the proof attached
- Returns the response data and payment info
Checking the price first
If you want to know the cost before paying, ask your agent to check the endpoint:Check the pricing for https://stableenrich.dev/api/company/lookup using AgentCash.This probes the endpoint without making a payment. It returns the price, accepted methods, and input/output schema.
Request options
Thefetch command accepts standard HTTP options:
AgentCash sets
Content-Type: application/json by default for requests with a body.Payment info in responses
Every paid request returns payment metadata alongside the response data:- amount: USDC paid
- transaction: on-chain transaction hash
- network: which chain the payment was made on
Error handling
If a payment fails, AgentCash returns a clear error. Common issues:| Error | Cause | Fix |
|---|---|---|
| Insufficient balance | Not enough USDC for the request price | Fund your wallet |
| Payment verification failed | On-chain verification issue | Retry the request |
| Timeout | Endpoint took too long to respond | Increase timeout or try again |