The Handshake Sequence
Step-by-Step Breakdown
Step 1: Initial Unauthenticated Request
The client attempts to access a protected route without a payment signature:Step 2: HTTP 402 Challenge
The gateway intercepts the call and responds with HTTP 402, returning challenge parameters:Step 3: Payment Signature Generation
The client decodes the challenge, checks budget policies, and creates a Soroban cryptographic authorization entry signed by the client’s Stellar secret key.Step 4: Authenticated Request
The client repeats the request with thePayment-Signature header:
Step 5: Verification & Forwarding
The gateway decodes the signature, verifies that the network and recipient match, validates the expiration timestamp, attachesreq.x402Payment, and forwards the request to the upstream API.