Skip to main content
Pay with x402 lets AI agents and apps pay over HTTP. The customer sends a base64-encoded payment payload in the PAYMENT-SIGNATURE header. Use it for machine-to-machine payments and API monetization. You create the payment session and give its x402Url to the agent. The agent gets the payment requirements and submits a signed payment. You track the authorization until it succeeds or fails.

1. Create a payment session

Create a payment session with a wallet target. The response includes an x402Url, which is the session’s POST .../payment-sessions/{id}/authorizations/x402 endpoint. Give this URL to an x402-enabled agent. The agent gets the payment requirements and submits the payment. The examples below use $X402_URL for this URL.

2. Get the payment requirements

The agent sends the request without a PAYMENT-SIGNATURE header. The response is 402 Payment Required:
The base64-encoded PAYMENT-REQUIRED header lists the accepted networks, assets, amounts, and payment addresses.

3. Submit the payment

The agent signs a payment that meets one of the requirements, then retries the request with the base64-encoded payload in the PAYMENT-SIGNATURE header:
An invalid PAYMENT-SIGNATURE also returns 402 Payment Required.

4. Track the authorization

The agent receives 200 with a PAYMENT-RESPONSE header and the authorization, which starts as pending:
The authorization moves to succeeded or failed. You track it with webhooks or by fetching the payment session with your API key. Don’t rely on the agent’s copy of the response.

Payment Sessions

Session lifecycle, authorization outcomes, and idempotency

x402 with Payment Acceptance

How x402 agents use Payment Acceptance sessions

Webhooks

Get notified when authorization succeeds or fails