x402
x402 is an open standard for internet-native payments, maintained in the x402 Foundation repository. It revives HTTP 402: a resource server answers with payment requirements, the client retries with a signed payment, and a facilitator verifies and settles it on a payment network. With this skill the agent builds and reviews x402 resource servers, clients and facilitators over HTTP, MCP and A2A.
Follow the workflow below step by step. Every rule here comes from a source in Sources, with the section it cites. When a rule and the pinned source disagree, the source wins; when the source has a newer revision than the pin, follow the refresh steps.
Inputs (fill in, or ask before starting)
- Role: resource server (seller), client (buyer or agent), facilitator, or a server that self-facilitates.
- Transport: HTTP (default), MCP tools, or A2A tasks.
- Scheme and network:
exact,upto,batch-settlementorauth-capture, on which CAIP-2 networks and assets. - Payment flow:
authorization(default),upfrontorescrow, as the scheme's network binding allows. - Target version: x402 v2 (default). x402 v1 is legacy: read it and upgrade from it, never author it. No preview exists. See
references/versions.md. - Revision: the pinned commit in Sources, unless the user names another.
- Sources: when refreshing this skill or when a rule looks out of date, re-read every URL in Sources first, list
specs/andspecs/schemes/in the repository for new scheme bindings or a newx402-specification-v3.md, and update the pins.
Invariants
- Version marker.
x402Versionis2inPaymentRequired,PaymentPayloadand facilitator requests (v2 § 5.1.2, § 5.2.2, § 7.1). - Complete requirements.
PaymentRequiredhasresourceandaccepts. Each entry hasscheme, a CAIP-2network,amountas a string of atomic units,asset,payToandmaxTimeoutSeconds(v2 § 5.1.2, § 11.1). - HTTP wire. Answer with 402 and a base64
PAYMENT-REQUIREDheader. The client pays with a base64PAYMENT-SIGNATUREheader, and the server returns a base64PAYMENT-RESPONSEheader (HTTP transport v2). - Echo, don't edit.
PaymentPayload.acceptedis the chosenaccepts[]entry. Clients echoextensionsand may only append, never delete or overwrite (v2 § 5.1.2, § 5.2.2). - Flow ordering. At least one verify or settle runs before the resource executes. A flow other than
authorizationis declared inextra.paymentFlow. Servers reject unsupported flows, and clients never pay into a flow they do not recognise (v2 § 6.1). - Read-only verify.
/verifyMUST NOT commit payment state or write onchain (v2 § 7.1). Only/settlegives finality (v2 § 7.2). - Honest settlement results.
transactionis required: empty when nothing was broadcast, non-empty withsettlement_pending, which is non-terminal (v2 § 5.3.2, § 9). uptocaps. The settled amount is ≤ the signed maximum. The facilitator re-verifies the signature against the signed maximum, not the settle-timeamount(scheme_upto.md, properties 4 and 5).- Replay. The network's replay primitive is authoritative, and a consumed primitive fails settlement. Payloads whose resubmission looks the same as the original are deduplicated atomically across all settle processes (scheme_exact.md; v2 § 10.1).
- Trust minimisation. Neither facilitator nor server can move funds other than as the client intended. The signed payment binds the amount and the recipient (README, Principles; scheme_exact_evm.md, Summary).
- No sidechannel leaks. Facilitator extension responses (
EXTENSION-RESPONSES) are never forwarded to buyers (v2 § 7.2.1). - MCP shape. Payment required is a tool result with
isError: true, carryingPaymentRequiredinstructuredContentandcontent[0].text. The payment travels in_meta["x402/payment"]and the settlement in_meta["x402/payment-response"](MCP transport v2).
Workflow
- Pick the version. Use x402 v2. If the code or a counterparty uses
X-PAYMENT, network names likebase-sepoliaormaxAmountRequired, it is v1: plan the upgrade (step 9). ->references/versions.md✓x402Version: 2everywhere new; any v1 path is input-only and keyed onx402Version: 1. - Pick scheme, network and flow. Match the pricing model to a scheme, and read the network binding for each
(scheme, network)pair you offer. ->references/schemes-and-networks.md✓ Every pair you will put inaccepts[]is listed in the facilitator's/supportedkinds, and every non-default flow is named inextra.paymentFlow. - Server: build
PaymentRequired. Fill inresource(ResourceInfo), oneaccepts[]entry per acceptable payment, the scheme'sextrakeys, and anyextensionssuch asbazaar. ->references/payment-flow.md✓ The decodedPAYMENT-REQUIREDheader (or MCPstructuredContent, or A2Ax402.payment.required) matches the v2 § 5.1 shape. Amounts are atomic-unit strings. - Client: select and pay. Filter
accepts[]to the schemes, networks and flows you support. Check the price against your budget, buildpayloadper the binding, copy the entry intoaccepted, echoextensions, then retry. ->references/payment-flow.md✓ UnknownpaymentFlowentries are skipped. The payment travels inPAYMENT-SIGNATURE,_meta["x402/payment"]orx402.payment.payload. - Server: verify, execute, settle. Follow the resolved flow's ordering. Call
/verifywith the payload and your requirements, run the handler, then call/settle. Forupto, send the actual charge asamountat settle. ->references/facilitator.md✓ No handler runs before a verify or settle succeeds. A handler failure underauthorizationleaves the client uncharged. - Return the result. Send
SettlementResponseinPAYMENT-RESPONSE(or the transport equivalent). Map errors to 400, 402 or 500, and handlesettlement_pendingby reconciling on chain. ->references/payment-flow.md✓ A failed settlement returns 402 withsuccess: false. MCP returns no tool content after a failed settlement. - Facilitator (if that is your role). Implement
/verify,/settleand/supported, the per-binding checks, and the error codes. Expose discovery and extensions if you offer them. ->references/facilitator.md✓/verifywrites nothing./supportedlistskinds,extensionsandsigners. Every binding MUST is enforced. - Review security. Check replay, double delivery, amounts, expiry windows, sponsor safety and information exposure.
->
references/security.md✓ Every item in "Verify before done" holds, including concurrent duplicate submissions. - Upgrade (only when asked). Follow the x402 v1 to x402 v2 checklist: version marker, CAIP-2 networks,
amount,ResourceInfo,accepted, and the new headers. ->references/versions.md✓ The same price, asset and recipient as before, now on the v2 wire, and v1 clients still served until they migrate.
Verify before done
- Every new message has
x402Version: 2, and networks are CAIP-2 (v2 § 5, § 11.1). - The 402 carries
PAYMENT-REQUIRED, payments arrive inPAYMENT-SIGNATURE, and results leave inPAYMENT-RESPONSE, each base64 JSON that decodes to the v2 type (HTTP transport v2). -
amountis an atomic-unit string, and eachaccepts[]entry has all six required fields (v2 § 5.1.2). - A non-
authorizationflow setsextra.paymentFlow. A check runs before the resource, and/verifywrites nothing (v2 § 6.1, § 7.1). - The facilitator compares the payload against the server's requirements: amount,
payTo, asset, network, validity window and signature (scheme bindings). -
uptosettles ≤ the signed maximum, and re-verifies against the signed maximum (scheme_upto.md). - Replaying a settled payload fails, and two concurrent submissions of one payload deliver one resource (scheme_exact.md).
-
settlement_pendingis reconciled on chain before any retry (v2 § 9). - No extension responses or internal details reach the client (v2 § 7.2.1).
- MCP and A2A, when used, follow their transport shapes (transports-v2).
- No single facilitator is hard-wired. The facilitator URL and the networks are configuration, because the standard never forces reliance on a single party (README, Principles).
Reference index
references/versions.md: x402 v2 and x402 v1 with their status, what v2 changed, and the v1 to v2 upgrade checklist with the network name mapping. Load for steps 1 and 9.references/payment-flow.md: thePaymentRequired,PaymentRequirements,ResourceInfo,PaymentPayloadandSettlementResponsefields, the payment flows, client selection, and the HTTP, MCP and A2A transports. Load for steps 3, 4 and 6.references/schemes-and-networks.md: CAIP-2 networks,exactwith its EVM and SVM bindings,upto,batch-settlement,auth-capture, and choosing a scheme. Load for step 2.references/facilitator.md:/verify,/settle,/supported, the extension sidechannel, error codes, Bazaar discovery and the extensions. Load for steps 5 and 7.references/security.md: trust model, replay and nonces, amounts, expiry, ordering, sponsor safety, exposure and common mistakes. Load for step 8.
Related skills
http-semanticsfor the 402 status code, headers and retries:npx skills add ScaleDockHQ/scaledock-skills --skill http-semantics.mcpfor the Model Context Protocol tool results and_metathat the MCP transport uses:npx skills add ScaleDockHQ/scaledock-skills --skill mcp.a2afor the Agent2Agent tasks, metadata and extensions that the A2A transport uses:npx skills add ScaleDockHQ/scaledock-skills --skill a2a.ap2for agent payment mandates:npx skills add ScaleDockHQ/scaledock-skills --skill ap2.agentic-commerce-protocolfor agent checkout flows:npx skills add ScaleDockHQ/scaledock-skills --skill agentic-commerce-protocol.ucpfor the Universal Commerce Protocol:npx skills add ScaleDockHQ/scaledock-skills --skill ucp.ethereum-eips, when the work also follows that specification:npx skills add ScaleDockHQ/scaledock-skills --skill ethereum-eipsmachine-payments-protocolfor the Machine Payments Protocol, another HTTP 402 payment protocol for agents:npx skills add ScaleDockHQ/scaledock-skills --skill machine-payments-protocol.
Sources
Status uses the publishing body's own maturity term. Checked is the date the source was last read. GitHub sources are pinned to commit cb0ec5bca0a5b21860a36bb60f34433c2e8e0d71 on main of x402-foundation/x402.
- x402 Protocol Specification v2: Protocol Version 2, spec v2.0 (2025-12-09), checked 2026-10-05.
- x402 Transport: HTTP (v2): Protocol Version 2, checked 2026-10-05.
- x402 Transport: MCP (v2): Protocol Version 2, checked 2026-10-05.
- x402 Transport: A2A (v2): Protocol Version 2, checked 2026-10-05.
- x402 Protocol Specification v1: Protocol Version 1, spec v0.2 (2025-10-03), checked 2026-10-05.
- x402 Transport: HTTP (v1): Protocol Version 1, checked 2026-10-05.
- x402 Transport: MCP (v1): Protocol Version 1, checked 2026-10-05.
- Scheme: exact: scheme specification, checked 2026-10-05.
- Scheme: exact on EVM: network binding, checked 2026-10-05.
- Scheme: exact on SVM: network binding, checked 2026-10-05.
- Scheme: upto: scheme specification, checked 2026-10-05.
- Scheme: upto on EVM: network binding, checked 2026-10-05.
- Scheme: upto on SVM: network binding, checked 2026-10-05.
- Scheme: batch-settlement: scheme specification, checked 2026-10-05.
- Scheme: auth-capture: scheme specification, v1.1 (2026-08-18), checked 2026-10-05.
- Extension: bazaar: extension specification, checked 2026-10-05.
- Extension: payment-identifier: extension specification, checked 2026-10-05.
- x402 repository README: principles and typical flow, checked 2026-10-05.
- Legacy v1 package notice: Deprecated (v1), security patches only, checked 2026-10-05.
- Migration Guide: V1 to V2: documentation, checked 2026-10-05.
- x402.org: project site, checked 2026-10-05.