> ## 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.

# fetch

> Make HTTP requests with automatic SIWX authentication and payment handling.

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

<ParamField body="url" type="string" required>
  The URL to fetch.
</ParamField>

<ParamField body="method" type="string" default="GET">
  HTTP method. One of `GET`, `POST`, `PUT`, `PATCH`, `DELETE`.
</ParamField>

<ParamField body="body" type="string">
  Raw request body string. When provided, `Content-Type: application/json` is set by default unless overridden by a header entry.
</ParamField>

<ParamField body="headers" type="string[]">
  Additional HTTP headers. Each entry must be a string in `Name: value` format.
</ParamField>

<ParamField body="timeout" type="number">
  Request timeout in milliseconds.
</ParamField>

<ParamField body="paymentProtocol" type="string">
  Force a specific payment protocol: `x402` or `mpp`. By default, AgentCash auto-selects.
</ParamField>

<ParamField body="paymentNetwork" type="string">
  Preferred network for SIWX and payment when applicable. By default, AgentCash auto-selects.
</ParamField>

<ParamField body="maxAmount" type="number">
  Maximum amount (in USD) to pay if the route still requires payment.
</ParamField>

## Response

The tool returns the response body along with payment metadata when a payment was made:

<ResponseField name="data" type="object">
  The parsed response body from the endpoint.
</ResponseField>

<ResponseField name="paymentInfo" type="object">
  Payment details, present when a 402 payment was made.

  <Expandable>
    <ResponseField name="amount" type="string">
      USDC amount paid.
    </ResponseField>

    <ResponseField name="transaction" type="string">
      On-chain transaction hash.
    </ResponseField>

    <ResponseField name="network" type="string">
      Chain used for the payment.
    </ResponseField>
  </Expandable>
</ResponseField>

## 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](https://stableenrich.dev/api/company/lookup) with body `{"domain": "stripe.com"}`.
