x402 turns a 402 status into a payment negotiation
A payments protocol for the internet. Built on HTTP.
At a glance
- What is it?
- x402 is an Apache-2.0 payments standard that rides on ordinary HTTP status codes: a server answers 402 Payment Required with a base64 requirements object, and the client retries with a signed payment header. The interesting engineering decisions sit in the schemes, the facilitator trust boundary, and the fact that the repository publishes no GitHub releases at all.
- Who is it for?
- Adopt x402 when your API is called by agents that can hold a key but cannot use a card, and when per-request metering matters more than a monthly invoice. Do not adopt it to settle in fiat today: the standard says it may extend to fiat networks but will never deprioritize onchain payments, and payment schemes named exact, upto and batch-settlement are described in `specs/schemes/` without the full flow spelled out in the overview.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 2 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- x402-foundation/x4026,821 ★ · +190
| Repository | 2026-09-23 | 2026-11-22 |
|---|---|---|
| x402-foundation/x402 | 6.6k | 6.8k |
190 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
A 402 status becomes a payment negotiation inside one request cycle
The mechanism is deliberately small. A client makes an ordinary HTTP request to a resource server. The server does not serve the content; it answers `402 Payment Required` and puts a base64 `PaymentRequired` object into a `PAYMENT-REQUIRED` header. The client reads that object, picks one of the `PaymentRequirements` inside it, builds a `PaymentPayload` for the `scheme` and `network` it chose, and sends the request again with a `PAYMENT-SIGNATURE` header carrying that payload.
From there verification happens either locally on the resource server or by POSTing the payload and requirements to the `/verify` endpoint of a facilitator, which returns a verification response. So the added round trip is one, and only when the client did not already know what the endpoint accepts. Steps one and two of the documented flow are optional for a client that has the payment details cached.
That constraint is a stated principle rather than an accident: x402 is meant to complement existing data transport and, where possible, not mandate additional requests outside a typical client/server flow. The cost of that choice is that payment state has to live in headers, and the visible integration target is one line of middleware on the server and one function on the client.
Three schemes exist, and the scheme field decides who absorbs the variance
Payment schemes in this protocol are `exact`, `upto`, and `batch-settlement`, and their specifications live under `specs/schemes/` in the repository. The client does not pick one arbitrarily: it selects a `PaymentRequirements` object that the server returned, and the scheme inside that object constrains what the resulting `PaymentPayload` may claim.
The overview names the three schemes and points at `specs/schemes/` for the detail, so the decision has to be made by reading the scheme specifications rather than the top-level documentation.
The facilitator is a trust boundary, and the rules for it are explicit
A facilitator is defined as a server that facilitates verification and execution of payments for one or many networks. The principle that shapes it is trust minimizing: all payment schemes must not allow for the facilitator or resource server to move funds, other than in accordance with client intentions. Neither of those two components is supposed to be able to take money on its own.
That is the reason the facilitator can be a third party at all. If it could move funds, handing your payment to an external verification service would be handing over the ability to spend it. Because it can only verify and settle what the client already signed for, you can run one against resources you do not host.
Three deployment options are named, and the guidance is not to pick the first one by accident. For testnet development and quickstarts, the public x402 facilitator is the easiest way in. For production mainnet routes you are told to decide explicitly between a production facilitator provider that supports your target network, running your own facilitator, or self-facilitating inside your resource server, with a worked example under `examples/typescript/servers/self-facilitation/`. The project also states plainly that you should not assume the public x402.org facilitator is the default production path for mainnet EVM routes.
One npm install line, ten chain packages, three client adapters
The TypeScript SDK is the primary implementation and its install line is unusually wide, because the network support is a set of separate packages rather than one bundle with feature flags.
npm install @x402/core @x402/evm @x402/svm @x402/fetchThat is the minimal fetch client. Swapping `@x402/fetch` for `@x402/express` gives you the minimal server instead. The full set pulls `@x402/core` plus the chain implementations `@x402/evm`, `@x402/svm`, `@x402/avm`, `@x402/aptos`, `@x402/casper`, `@x402/stellar`, `@x402/tvm`, `@x402/hedera`, `@x402/keeta` and `@x402/canton`, together with the adapters `@x402/axios`, `@x402/fastify`, `@x402/fetch`, `@x402/express`, `@x402/hono`, `@x402/next`, `@x402/paywall`, `@x402/extensions` and `@x402/mcp`.
The other two SDKs are one line each: `pip install x402` for Python and `go get github.com/x402-foundation/x402/go/v2` for Go. Both point at folders in the same repository for examples and integration guides, and the Go module path carries a `/v2` major version segment while the Python package name carries nothing at all. Worth noting when you pin versions across a polyglot codebase.
The server side is a middleware wrapper, and this is the shape the project shows:
app.use(
paymentMiddleware(
{
"GET /weather": {
accepts: [...], // As many networks / schemes as you want to support
description: "Weather data", // what your endpoint does
},
},
),
);The route key is the thing being protected, and `accepts` is where you name the networks and schemes that endpoint will take.
The compatibility promise is narrower than the ambition
Four of the stated principles constrain how the standard can change. The open standard principle says x402 will never force reliance on a single party. The backwards compatibility principle says no existing network support will be deprecated unless removal is deemed necessary for the security of the standard, and that backwards compatibility is the aim for non-major version changes.
Network, token and currency agnosticism is the widest of them, and it carries its own limit. Contributions adding new networks, both crypto and fiat, new signing standards or new schemes are welcome as long as they meet the acceptance criteria in `CONTRIBUTING.md`. The same bullet then says x402 may extend support to fiat based networks but will never deprioritize onchain payments in favour of fiat payments. That is a prioritisation commitment, not a capability statement, so read it as the order in which work lands rather than as a promise that fiat arrives.
The easy-to-use principle is the one with the most specific engineering content: the intent is to abstract as many details of crypto as possible away from the client and resource server and into the facilitator, so that the client and server do not need to think about gas or RPC. That is why the facilitator exists as a separate role, and it is also why choosing your own facilitator has consequences for how much of the crypto surface you actually own.
The repository is a specification with reference SDKs, not a shipped product
The layout tells you what this project is. `specs/` holds the standard itself and `specs/schemes/` the payment scheme documents. `docs/` is the published documentation source in Mintlify. `typescript/`, `python/` and `go/` are the SDKs with install instructions in the README, a `java/` directory also sits at the top level, and `examples/` holds matching `typescript/`, `python/` and `go/` directories, with `advanced` folders inside them for flows that depart from the typical sequence. `e2e/` is the end-to-end suite, `contracts/` the onchain contracts, `foundation/` governance files, `scripts/` tooling, and `static/` assets.
Two root files are unusual enough to be worth opening. `package.json` at the root is private and declares `[email protected]` as its package manager, which tells you the monorepo is driven by pnpm even though the SDK consumers install from npm. `TSC.md` sits next to `SECURITY.md`, `DEFAULT_ASSETS.md`, `NOTICE` and `CONTRIBUTING.md`, and `.gitmodules` means at least part of the tree arrives as a submodule.
The release history is the surprising part: the repository has no GitHub releases at all. The last push was on 2026-11-02. So there is no GitHub release to pin, no changelog attached to a release, and no semantic release history to consult before upgrading. Track the commit instead, and treat the schema of `PaymentRequired` and `PaymentPayload` as something that can move under you.
Discovery and tooling live outside the repository, in community-run directories
There is no marketplace inside this repository and no registry of facilitators to browse. Support questions go to the x402 Slack, and curated third-party SDKs, extensions and facilitators are listed in the developer tools documentation at `docs.x402.org/dev-tools/overview`.
For finding x402 services and integrations generally, the project points at community-maintained directories rather than anything it hosts: x402scan.com, Agentic.Market, Pay.sh, app.ampersend.ai/discover and x402-list.com. That list is worth reading carefully as a set of trust decisions. None of those directories is operated by the foundation, none is covered by the compatibility promises above, and a listing is not an endorsement.
The specification documentation is `specs/`, and the overview itself only sketches the flow, noting that servers have a lot of flexibility and that the `advanced` example folders show the variants.
Editorial conclusion
Adopt x402 when your API is called by agents that can hold a key but cannot use a card, and when per-request metering matters more than a monthly invoice. Do not adopt it to settle in fiat today: the standard says it may extend to fiat networks but will never deprioritize onchain payments, and payment schemes named exact, upto and batch-settlement are described in `specs/schemes/` without the full flow spelled out in the overview. Before you commit, pick your facilitator deliberately, because the public x402.org facilitator is explicitly not the production path for mainnet EVM routes, and check whether your chain has a reference package in the TypeScript SDK at all.
Frequently asked questions
What is the x402 protocol?
x402 is an open standard for internet native payments, built on HTTP, intended to support many networks and forms of value including stablecoins, tokens and fiat. A resource server answers with a 402 Payment Required status and a base64 PaymentRequired object in a PAYMENT-REQUIRED header, and the client retries with a PaymentPayload in a PAYMENT-SIGNATURE header.
How do I install the x402 TypeScript SDK?
Install @x402/core with the chain packages and one client adapter. The minimal fetch client is `npm install @x402/core @x402/evm @x402/svm @x402/fetch`, and the minimal express server swaps the last package for @x402/express. Python installs with `pip install x402` and Go with `go get github.com/x402-foundation/x402/go/v2`.
Should I use the public x402 facilitator in production?
The project says the public x402 facilitator is the easiest route for testnet development and quickstarts, and that you should not assume the public x402.org facilitator is the default production path for mainnet EVM routes. For mainnet you are told to choose a production facilitator provider, run your own facilitator, or self-facilitate inside your resource server.
Which payment schemes does x402 define?
The schemes are exact, upto and batch-settlement, and their specifications live under specs/schemes/ in the repository. The client selects one of the PaymentRequirements returned by the server and builds a PaymentPayload based on the scheme and network it chose.
Official sources
Where developers are discussing it
Posts on Hacker News, dev.to and Lobsters that link to this repository, found by our scan of those communities. 1 in the last 30 days; newest first.
- Give your agent an allowance. Get a receipt.dev.to · Nov 16, 2026 · 2 points · 0 comments
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/x402-foundation-x402)Star history chart for your README
[](https://hysenlabs.com/projects/x402-foundation-x402)Was this useful?