---
name: pay-x402-endpoint
description: Pay an HTTP API that uses x402 V2. Use when a response is HTTP 402 and includes a PAYMENT-REQUIRED header.
license: CC-BY-4.0
metadata:
  author: agentpaywire
  version: "1.0"
---

# Pay an x402 endpoint

This follows the x402 V2 HTTP headers. It is not a recommendation to buy a token or use a particular chain.

## Steps

1. Request the resource.
2. If the status is 402, read the `PAYMENT-REQUIRED` header. It is a Base64-encoded PaymentRequired object: accepted schemes, price, network, and destination.
3. Choose one accepted option and sign a PaymentPayload with a wallet that supports that scheme and network.
4. Retry the same request with:

```
PAYMENT-SIGNATURE: <base64 PaymentPayload>
```

5. Read `PAYMENT-RESPONSE`. It is a Base64-encoded settlement result. Success is the resource. Failure is another 402.

## Version notes

- V2 network ids are CAIP-2. The migration guide maps Base mainnet to `eip155:8453`.
- V1 clients sent `X-PAYMENT` and read `X-PAYMENT-RESPONSE`.
- The server may verify and settle through a facilitator (`/verify` and `/settle`) or on its own.
- The docs do not fix one asset contract. Read the payment requirements in the 402 response. Do not assume a token or a chain that the header did not list.

Header reference: https://docs.x402.org/core-concepts/http-402
Migration reference: https://docs.x402.org/guides/migration-v1-to-v2
