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

**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 metadata from the final response:

**data** `object`

The parsed response body from the endpoint.

**headers** `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.

**paymentInfo** `object`

Payment details, present when a 402 payment was made.

**amount** `string`

USDC amount paid.

**transaction** `string`

On-chain transaction hash.

**network** `string`

Chain used for the payment.

## 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"}`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.