AI agent payments and x402· 2 of 4

The 402 handshake

Ask, get a price, sign a payment, ask again. A facilitator checks and settles it.

4 minMedium

Key points

  • The server answers 402 with a price in the PAYMENT-REQUIRED header.
  • The client retries with a signed payment in PAYMENT-SIGNATURE.
  • A facilitator checks the payment, then submits it to the chain.

The lesson

  1. Picture a snack machine that talks.

  2. You ask for chips. The machine says, "That's 50 cents. Here is how to pay." You put in a signed slip for 50 cents. Then you ask again. A helper checks the slip and cashes it. Out come the chips.

  3. works the same way, with three parties:

    • The client: the agent that wants the data.
    • The : the service that sells it.
    • The : a helper service that checks the payment and sends it to the chain.
  4. The client signs the payment itself. The facilitator only passes it along. It cannot change who gets paid or how much. Any change would break the client's signature.

  5. The whole trip is two web requests. On the XRP Ledger, the payment settles in seconds.

Check yourself3 questions
1. What does the server send back when a request is unpaid?
2. What does a facilitator do?
3. Why can't a facilitator redirect the money?
Next lessonSettling on the XRP Ledger