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

# x402

> Pay for an API with x402 — the open standard built on HTTP 402 Payment Required.

[x402](https://docs.x402.org/introduction) is the open payment standard built on the HTTP `402 Payment Required` status code. It lets clients pay programmatically for API access without accounts, sessions, or API keys.

Every Proceeds paywall exposes an x402 URL. Use x402 when you want broad client compatibility — any x402-aware library or agent will work.

## Endpoint

```
https://myproceeds.xyz/api/x402/pay/{serviceId}/{slug}
```

## Flow

1. Client requests the x402 URL.
2. Proceeds responds with `402 Payment Required` and a challenge.
3. Client signs an EIP-3009 USDC payment authorization.
4. Client retries with the authorization in the `X-Payment` header.
5. Proceeds verifies and proxies the upstream response.

## curl

<CodeGroup>
  ```bash Step 1 — request the resource theme={null}
  curl -i https://myproceeds.xyz/api/x402/pay/{serviceId}/{slug}
  ```

  ```bash Step 2 — retry with payment theme={null}
  curl -i \
    -H "X-Payment: YOUR_PAYMENT_RECEIPT" \
    https://myproceeds.xyz/api/x402/pay/{serviceId}/{slug}
  ```
</CodeGroup>

## JavaScript

A wallet-aware client signs the EIP-3009 authorization and retries automatically.

```javascript theme={null}
import { createUSDCPaymentFetch } from '@/lib/usdc-payment-client'
import { useWallets } from '@privy-io/react-auth'
import { createWalletClient, custom } from 'viem'

const { wallets } = useWallets()
const wallet = wallets[0]
const provider = await wallet.getEthereumProvider()

const walletClient = createWalletClient({
  account: wallet.address,
  transport: custom(provider),
})

const usdcFetch = createUSDCPaymentFetch(walletClient, BigInt(100000000))

const response = await usdcFetch(
  'https://myproceeds.xyz/api/x402/pay/{serviceId}/{slug}'
)

const data = await response.json()
```

## React

A drop-in component that renders the result after payment is confirmed.

```jsx theme={null}
import { X402PaymentClient } from '@/components/X402PaymentClient'

function MyComponent() {
  return (
    <X402PaymentClient
      resourceUrl="https://myproceeds.xyz/api/x402/pay/{serviceId}/{slug}"
      onSuccess={(content) => console.log('Content:', content)}
      onError={(error) => console.error('Failed:', error)}
    />
  )
}
```

## Use from an agent

To pay an x402 Proceeds URL from an agent in Claude Code, Cursor, or Codex without writing the client yourself:

* [AgentCash](/agents/agentcash) — one USDC balance across x402 and MPP.
* [Circle Agent Stack](/agents/circle-agent-stack) — Circle Agent Wallets, plus sub-cent settlement via Gateway.

See [Pay with an agent](/agents/overview) for setup.

## When to use x402

* You want broadest client compatibility.
* Your buyers are humans or apps with wallets, not Tempo-native agents.
* Sub-cent pricing isn't required — for that, layer in [Circle Nanopayments](/standards/circle-nanopayments).

<Card title="More on x402" icon="book" href="https://docs.x402.org/introduction">
  Read the open standard at docs.x402.org.
</Card>
