From the official x402 package (signatures as of 2.28.0). The upstream project is the authoritative reference.

Header encoding

From x402.http: Each header is base64-encoded JSON of the corresponding schema.

Clients

Example: HTTPX and requests.

Server middleware

Examples: FastAPI, Flask.

Route configuration

The route key is "<METHOD> <path>"; PaymentGate uses "POST /messages*". price can also be a callable that receives the request context, which is how PaymentGate prices each tool call.