Client Path
Lesson 1 of 8
10 min

Understanding the x402 Flow (Client Perspective)

Learning Objectives

  • Understand the 402 Payment Required status code
  • Learn the client-side payment flow
  • Identify the role of facilitators
  • Recognize payment headers

The Problem

Traditional APIs are either free or use API keys for authentication. While API keys work well for access control, they're difficult to monetize on a per-request basis. You can't easily charge $0.001 for a single API call.

The x402 Solution

x402 brings programmatic payments directly into the HTTP protocol. Here's how it works:

1.Client makes a request to a payment-gated API
2.Server responds with 402 (Payment Required) and payment details
3.Client signs the payment using their wallet
4.Client sends payment to facilitator for on-chain settlement
5.Facilitator settles the transaction on the blockchain
6.Facilitator returns proof of payment
7.Client retries request with payment proof in headers
8.Server verifies proof and returns data
The beauty of x402 is that it's completely programmatic. No user interaction, no redirect flows, just HTTP requests and cryptocurrency payments working together.

Knowledge Check

What happens when a client receives a 402 response?