> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tentaclepay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Paying for APIs

> Use tpay curl to clear x402 paywalls automatically.

`tpay curl` is a drop-in replacement for `curl`. It forwards every flag you pass. The difference: when a server responds with `402 Payment Required`, `tpay` settles the payment from your wallet and retries the request — so your agent sees a normal `200 OK`.

## Make a paid request

```sh theme={null}
tpay curl https://api.weather.ai/forecast
```

What happens behind the scenes:

<Steps>
  <Step title="The request is sent as-is">
    `tpay` runs the request exactly like `curl` would.
  </Step>

  <Step title="A 402 is intercepted">
    If the server returns `402 Payment Required`, `tpay` reads the `accepts` list — the price, network, token, and recipient.
  </Step>

  <Step title="You approve the spend">
    `tpay` asks you to authorize the payment (Touch ID on macOS) before signing anything.
  </Step>

  <Step title="The payment is attached and retried">
    `tpay` builds and signs the Sui payment, attaches it to the request, and sends it again. The server verifies and settles through the facilitator, then returns the resource.
  </Step>
</Steps>

## Passing curl flags

Every `curl` flag works. A few common ones:

```sh theme={null}
# POST with a JSON body
tpay curl -X POST https://api.example.com/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a tentacle holding a coin"}'

# Send a header and follow redirects
tpay curl -H "Accept: application/json" -L https://api.example.com/data

# Include response headers in the output
tpay curl -i https://api.weather.ai/forecast
```

<Warning>
  Don't set the `PAYMENT-SIGNATURE` (or `X-PAYMENT`) header yourself — `tpay` adds it after you approve the payment. Setting it manually will conflict.
</Warning>

## Choosing a wallet

By default `tpay curl` pays from the active wallet. Use `--account` to pay from a different one for a single request:

```sh theme={null}
tpay curl --account trading-bot https://api.example.com/data
```

## Networks

`tpay` pays on whichever network the server's payment requirements specify — `sui:mainnet` or `sui:testnet`. You don't choose the network for a payment; the seller does, and `tpay` matches it from the matching wallet balance.

## If a payment can't be made

If the wallet doesn't have enough balance, or you decline the approval, `tpay` reports the reason and the request is not retried. Top up the wallet (see [Managing wallets](/wallet/accounts)) and try again.

## Next steps

<Card title="Connect an agent" icon="robot" href="/wallet/agents">
  Expose `pay` and `get_balance` to Claude and other MCP clients.
</Card>
