Machine paymentsReviewed

x402

x402 Payment Protocol

x402 Foundation / x402 project

Specification family v2
Stefan Hamann · English
Text

What x402 enables

x402 lets software pay for individual resources and services, such as an API call or a data request. The server answers an unpaid request with payment requirements. The client provides the appropriate payment evidence and receives the requested service.

Connections with other protocols

  • Agents can use x402 to access a paid service during a task, such as a data API.
  • MPP and L402 also address paid web resources. With x402, the payment scheme, network and chosen implementation determine the payment route.

Versions and licence

Published version
v2
Working draft
—

V2 was announced on 11 December 2025. Language packages do not share one current release; v1 remains separately documented.

Licence / terms
Apache-2.0
Licence and terms ↗

An example flow

  1. An agent requests a paid API, such as a weather data service.
  2. The server returns HTTP 402 and specifies accepted payment terms.
  3. The client creates the required payment evidence and repeats the request.
  4. Where needed, the server uses a facilitator for verification and settlement, then returns the data after successful verification.

SDKs and examples

These libraries and examples help you get started. Each entry lists the language, package and supported version.

From the protocol projectTypeScript · Python · Go

x402 reference implementations

Includes: Client and server components and adapters

Package / module: @x402/core; x402; github.com/x402-foundation/x402/go/v2

Version & compatibility: Distinguish package versions from protocol v2

TypeScript network and transport packages such as @x402/evm and @x402/fetch complement the core.

From the protocol projectJava

x402 Java

Includes: Source build from the official repository

Package / module: org.x402:x402:1.0.0-SNAPSHOT

Version & compatibility: x402 v1; Java 17+; local Maven build

This Java implementation uses x402Version 1 and the X-PAYMENT header.

Practical integration

  • Payment requirements identify the scheme and network. The client, server and any facilitator support that combination.
  • The TypeScript, Python and Go reference implementations are listed alongside a Java implementation of the v1 flow. Each SDK entry states its version context.

Related protocols

Original sources