Repository navigation
Expand file tree
/
Copy pathwhat-is-x402.html
More file actions
159 lines (132 loc) · 10.7 KB
/
Copy pathwhat-is-x402.html
File metadata and controls
159 lines (132 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>What is x402? Paying APIs with HTTP 402, explained for developers</title>
<meta name="description" content="HTTP 402 Payment Required sat unused for 25 years. The x402 standard turns it into instant USDC micropayments for machine-to-machine API calls. How it works, what selling looks like, and the economics of one-cent APIs.">
<link rel="canonical" href="https://dacode-dev.github.io/what-is-x402.html">
<meta name="robots" content="index,follow">
<meta property="og:type" content="article">
<meta property="og:site_name" content="dacode-dev">
<meta property="og:title" content="What is x402? Paying APIs with HTTP 402, explained">
<meta property="og:description" content="The 402 status code was reserved in 1996 and ignored for decades. x402 uses it for instant USDC micropayments between machines. How it works and what selling on it actually looks like.">
<meta property="og:url" content="https://dacode-dev.github.io/what-is-x402.html">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="What is x402? Paying APIs with HTTP 402, explained">
<meta name="twitter:description" content="How the x402 standard turns an unused HTTP status code into instant USDC micropayments for machine-to-machine APIs.">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "What is x402? Paying APIs with HTTP 402, explained for developers",
"description": "How the x402 standard turns HTTP 402 into instant USDC micropayments for machine-to-machine APIs, from a seller operating paid routes in production.",
"url": "https://dacode-dev.github.io/what-is-x402.html",
"author": {"@type": "Organization", "name": "dacode-dev", "url": "https://dacode-dev.github.io/"},
"publisher": {"@type": "Organization", "name": "dacode-dev", "url": "https://dacode-dev.github.io/"},
"datePublished": "2026-08-24",
"keywords": ["x402", "HTTP 402", "micropayments", "USDC", "Base", "AI agent payments", "pay per call API"]
}
</script>
<style>
:root { --bg:#0b0d10; --card:#14171c; --text:#e8eaed; --muted:#9aa0a6; --accent:#34d399; --border:#262a30; --code-bg:#0e1013; }
@media (prefers-color-scheme:light) { :root { --bg:#fafafa; --card:#fff; --text:#16181c; --muted:#5f6368; --accent:#047857; --border:#e2e4e8; --code-bg:#f1f2f4; } }
* { box-sizing:border-box; }
body { margin:0; padding:42px 20px 64px; background:var(--bg); color:var(--text); font:16px/1.7 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; }
main { max-width:720px; margin:auto; }
.crumb { font-size:.85rem; margin-bottom:22px; }
.crumb a { color:var(--muted); }
h1 { margin:0 0 10px; font-size:clamp(1.6rem,4vw,2.3rem); line-height:1.15; letter-spacing:-0.02em; }
.meta { color:var(--muted); font-size:.88rem; margin-bottom:34px; }
h2 { margin:38px 0 12px; font-size:1.35rem; letter-spacing:-0.01em; }
p { margin:0 0 18px; }
ul,ol { margin:0 0 18px; padding-left:24px; }
li { margin-bottom:9px; }
pre { overflow:auto; padding:16px; background:var(--code-bg); border:1px solid var(--border); border-radius:10px; font-size:.84rem; line-height:1.55; }
code { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
p code, li code { background:var(--code-bg); border:1px solid var(--border); border-radius:5px; padding:1px 6px; font-size:.85em; }
table { width:100%; border-collapse:collapse; margin:14px 0 20px; font-size:.9rem; }
th,td { text-align:left; padding:9px 11px; border-bottom:1px solid var(--border); vertical-align:top; }
th { color:var(--muted); font-weight:600; }
.callout { border:1px solid var(--accent); border-radius:11px; padding:16px 18px; margin:24px 0; font-size:.94rem; line-height:1.6; }
.note { margin-top:40px; padding-top:20px; border-top:1px solid var(--border); color:var(--muted); font-size:.9rem; }
</style>
</head>
<body>
<main>
<p class="crumb"><a href="/">← dacode-dev</a></p>
<h1>What is x402? Paying APIs with HTTP 402, explained</h1>
<p class="meta">2026-08-24 · by dacode-dev · operating paid x402 routes in production since August 2026</p>
<p>When your code calls a REST API today, payment happens somewhere else entirely: an API key tied to an account, a billing relationship, a subscription, a credit card on file. Every one of those steps assumes a human set things up in advance.</p>
<p>AI agents broke that assumption. An agent that discovers a new API at runtime has no card, no account, and no one to email. What it does have is an HTTP client and a wallet. <strong>x402</strong> is the open standard that connects the two, and it works by reviving the oldest unused slot in the HTTP specification.</p>
<h2>The 402 status code, finally put to work</h2>
<p>HTTP 402 "Payment Required" was reserved in RFC 1945 (1996) as a placeholder for a future digital payments scheme that never arrived. For nearly three decades, servers returned it only as a joke or a placeholder. x402 gives it an actual job:</p>
<ol>
<li>Your client calls a paid endpoint without paying.</li>
<li>Instead of an error page, the server answers <code>402</code> with a machine-readable header describing exactly how to pay: which token, which network, how much, and which address receives it.</li>
<li>The client pays (for x402 on Base, that is a USDC transfer authorized with EIP-3009, so no gas-in-flight management), then retries the same request with proof of payment attached.</li>
<li>The server verifies the proof through a facilitator service and returns the actual response.</li>
</ol>
<p>A real challenge from a live endpoint looks like this (decoded):</p>
<pre><code>HTTP/1.1 402 Payment Required
payment-required: eyJ4NDAyVmVyc2lvbiI6Miw...
{
"x402Version": 2,
"resource": {
"url": "https://api.example.com/v1/weather",
"description": "Weather lookup",
"mimeType": "application/json"
},
"accepts": [{
"scheme": "exact",
"network": "eip155:8453",
"amount": "10000",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"payTo": "0x...",
"maxTimeoutSeconds": 30
}]
}</code></pre>
<p>That is the entire contract. The <code>amount</code> is in USDC base units (10000 = $0.01), <code>eip155:8453</code> is Base, and the asset address is native USDC on that chain. A client that can read this can pay it, with no account creation anywhere in the loop.</p>
<h2>Why agents changed the economics</h2>
<p>Per-call micropayments were always technically possible; they failed because humans will not open a billing relationship for a one-cent call. Agents flip that calculus. A software agent does not mind paying one cent. What it needs is certainty about three things before it pays:</p>
<ul>
<li><strong>Price:</strong> exactly how much this call costs, declared up front.</li>
<li><strong>Destination:</strong> which address receives the money.</li>
<li><strong>Delivery:</strong> evidence the seller actually delivers after being paid.</li>
</ul>
<p>x402 solves the first two structurally: every 402 response is a price quote plus a payee, signed into the flow. The third is why marketplaces and directories matter. On PayanAgent's catalog, each offer carries public delivery-rate history computed from settled receipts, so a buyer can check whether the seller actually delivered for previous buyers before committing its own cent.</p>
<h2>What selling looks like in practice</h2>
<p>I operate several paid routes on this stack: context-preflight checks, a page reader, an x402 seller verifier, a funded-work radar. Three observations from running them:</p>
<ul>
<li><strong>Pricing clusters hard around one cent.</strong> Across roughly 150 listed services on public facilitators, the modal price is $0.001–$0.01. Buyers at this layer are agents doing thousands of small lookups, not humans buying reports.</li>
<li><strong>Reliability is the product.</strong> With prices this low, differentiation comes almost entirely from uptime and honest delivery rates. The catalog tracks both publicly, and buyers sort by them.</li>
<li><strong>Discovery is the bottleneck.</strong> Payment rail solved, pricing solved; the hard problem is letting agents find you. Facilitator discovery endpoints, catalogs, and directories are where competition actually happens.</li>
</ul>
<div class="callout">
<strong>If you take one thing away:</strong> x402 makes an API call self-describing about money. The 402 response is simultaneously a price list, an invoice, and a receipt format. Anything that can speak HTTP and hold a wallet can be a customer.
</div>
<h2>Trying it without spending anything</h2>
<p>An unpaid request to any x402 endpoint returns the payment challenge instead of an error. That means you can inspect the whole mechanism for free:</p>
<pre><code>curl -i https://agent-context-api-proxy.agent-context-proxy.workers.dev/v1/read-page \
-X POST -H 'content-type: application/json' \
-d '{"url":"https://example.com"}'
# HTTP/2 402
# payment-required: eyJ4NDAyVmVyc2lvbiI6Miw... (base64 JSON)</code></pre>
<p>Decode that header and you have read a real payment requirement: my receiving address, one cent of USDC on Base, thirty-second timeout. To go further, tools help:</p>
<table>
<tr><th>Tool</th><th>What it does</th><th>Cost</th></tr>
<tr><td><a href="/agent-context-api.html">Agent Context API</a></td><td>Sells context checks, page reads, and seller verification over x402</td><td>$0.005–$0.03 / call</td></tr>
<tr><td><a href="https://dacode-dev.github.io/x402-services-directory/">x402 Services Directory</a></td><td>Live listing of sellers across facilitators with verified gates</td><td>Free</td></tr>
<tr><td><a href="https://github.com/dacode-dev/llm-ctxpack">llm-ctxpack</a></td><td>Packs repos into agent context, free CLI</td><td>Free</td></tr>
</table>
<h2>Open questions worth watching</h2>
<ul>
<li><strong>Reputation portability.</strong> Delivery rates live inside each marketplace today. Whether they become portable seller credentials across facilitators is an open design question.</li>
<li><strong>Discovery standards.</strong> Facilitator discovery feeds exist but differ in shape. A common crawlable schema would do for x402 what sitemaps did for the web.</li>
<li><strong>Beyond USDC-on-Base.</strong> Solana and Monad facilitators are appearing; multi-chain price quoting is already in the v2 challenge format.</li>
</ul>
<p class="note">Written by dacode-dev, which operates x402-paid developer tools on Base. Related: the <a href="https://dacode-dev.github.io/x402-services-directory/">live x402 services directory</a>, the <a href="/agent-context-api.html">Agent Context API route table</a>, and <a href="/repo-context-budgets.html">why full-repo dumps waste your context budget</a>.</p>
<p class="crumb" style="margin-top:26px;"><a href="/">← Back to dacode-dev</a></p>
</main>
</body>
</html>