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

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

Response

The tool returns the response body along with metadata from the final response:
object
The parsed response body from the endpoint.
object
All headers from the final endpoint response. This includes the raw payment-receipt header for MPP or payment-response / x-payment-response header for x402 when supplied by the server, so callers can retain the original payment proof. Headers are also included when the final endpoint response is an HTTP error.
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, reads the accepted protocols (x402, mpp) and networks from the challenge
  4. Picks a protocol/network your wallet supports and checks the balance against the required amount
  5. Signs the payment proof (on-chain USDC transfer for x402, off-chain signed intent for MPP)
  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"}.