Skip to main content
The fetch tool sends an HTTP request to any URL and automatically handles SIWX authentication and payment if the endpoint requires them. Equivalent CLI command: npx agentcash fetch <url>

Parameters

url
string
required
The URL to fetch.
method
string
default:"GET"
HTTP method. One of GET, POST, PUT, PATCH, DELETE.
body
string
Raw request body string. When provided, Content-Type: application/json is set by default unless overridden by a header entry.
headers
string[]
Additional HTTP headers. Each entry must be a string in Name: value format.
timeout
number
Request timeout in milliseconds.
paymentProtocol
string
Force a specific payment protocol: x402 or mpp. By default, AgentCash auto-selects.
paymentNetwork
string
Preferred network for SIWX and payment when applicable. By default, AgentCash auto-selects.
maxAmount
number
Maximum amount (in USD) to pay if the route still requires payment.

Response

The tool returns the response body along with payment metadata when a payment was made:
data
object
The parsed response body from the endpoint.
paymentInfo
object
Payment details, present when a 402 payment was made.

Behavior

  1. Sends the request to the target URL
  2. If the response is 402 Payment Required with a SIWX challenge, signs the challenge and retries with auth headers
  3. If the route still returns 402, extracts payment details
  4. Checks your wallet balance against the required amount
  5. Signs a payment credential with your wallet’s private key
  6. Retries the request with the payment proof attached
  7. Returns the final response and payment info

Example

Ask your agent:
Use AgentCash to POST to https://stableenrich.dev/api/company/lookup with body {"domain": "stripe.com"}.