Skip to main content
The primary use case for AgentCash is calling APIs that require payment. This guide covers the flow from your agent’s perspective.

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:
  1. Sends the request to the endpoint
  2. Receives a 402 Payment Required response with pricing
  3. Signs a USDC payment with your wallet
  4. Retries the request with the payment proof
  5. 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

The fetch command accepts standard HTTP options:
URL:     https://example.com/api/endpoint
Method:  POST (default: GET)
Headers: {"Content-Type": "application/json"}
Body:    {"key": "value"}
Timeout: 30000 (milliseconds)
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:
ErrorCauseFix
Insufficient balanceNot enough USDC for the request priceFund your wallet
Payment verification failedOn-chain verification issueRetry the request
TimeoutEndpoint took too long to respondIncrease timeout or try again