[{"data":1,"prerenderedAt":233},["ShallowReactive",2],{"project-\u002Fprojects\u002Fs402-agent-pays-api":3},{"id":4,"title":5,"body":6,"description":211,"extension":212,"featured":213,"github":214,"live":214,"meta":215,"metric_source":214,"navigation":216,"order":123,"path":217,"pr_links":218,"proof_url":180,"seo":219,"status":220,"statusColor":221,"stem":222,"subtitle":223,"tech":224,"tier":230,"verification_tier":231,"__hash__":232},"projects\u002Fprojects\u002Fs402-agent-pays-api.md","Agent Pays for an API",{"type":7,"value":8,"toc":205},"minimark",[9,13,28,46,51,88,91,95,156,160,165,169,201],[10,11,5],"h1",{"id":12},"agent-pays-for-an-api",[14,15,16],"blockquote",{},[17,18,19,20,27],"p",{},"I retired s402 in September 2026. It was my HTTP 402 payment protocol for agents on Sui, and x402 has since become the industry standard. For new work, use ",[21,22,26],"a",{"href":23,"rel":24},"https:\u002F\u002Fx402.org",[25],"nofollow","x402",".",[17,29,30,31,35,36,40,41,45],{},"The companion proof for ",[21,32,34],{"href":33},"\u002Fprojects\u002Fs402","s402"," — not the protocol, but an ",[37,38,39],"strong",{},"agent actually using it",". An autonomous agent calls a paywalled API, gets back ",[42,43,44],"code",{},"402 Payment Required",", reads a price it never knew, signs a Sui payment, retries, and receives the data. No API keys. No human in the loop.",[47,48,50],"h2",{"id":49},"what-happens","What happens",[52,53,54,58,74,81],"ol",{},[55,56,57],"li",{},"Agent calls a free endpoint → data, no payment.",[55,59,60,61,64,65,68,69,73],{},"Agent calls a premium endpoint → ",[42,62,63],{},"402"," + machine-readable s402 terms (",[42,66,67],{},"exact",", amount, asset, payTo). It ",[70,71,72],"em",{},"discovers"," the price.",[55,75,76,77,80],{},"The agent's s402 client signs a Sui transaction and retries with an ",[42,78,79],{},"X-PAYMENT"," header.",[55,82,83,84,87],{},"The server settles on Sui testnet and returns ",[42,85,86],{},"200"," + data + a receipt carrying the on-chain tx digest.",[17,89,90],{},"The server holds no key — it only broadcasts the agent's signed transaction. Trustless by construction.",[47,92,94],{"id":93},"run-it","Run it",[96,97,102],"pre",{"className":98,"code":99,"language":100,"meta":101,"style":101},"language-bash shiki shiki-themes github-light github-dark","pnpm install --ignore-workspace\nexport SUI_TESTNET_PRIVATE_KEY=…   # a funded testnet wallet\npnpm exec tsx demo.ts\n","bash","",[42,103,104,121,142],{"__ignoreMap":101},[105,106,109,113,117],"span",{"class":107,"line":108},"line",1,[105,110,112],{"class":111},"sScJk","pnpm",[105,114,116],{"class":115},"sZZnC"," install",[105,118,120],{"class":119},"sj4cs"," --ignore-workspace\n",[105,122,124,128,132,135,138],{"class":107,"line":123},2,[105,125,127],{"class":126},"szBVR","export",[105,129,131],{"class":130},"sVt8B"," SUI_TESTNET_PRIVATE_KEY",[105,133,134],{"class":126},"=",[105,136,137],{"class":130},"…   ",[105,139,141],{"class":140},"sJ8bj","# a funded testnet wallet\n",[105,143,145,147,150,153],{"class":107,"line":144},3,[105,146,112],{"class":111},[105,148,149],{"class":115}," exec",[105,151,152],{"class":115}," tsx",[105,154,155],{"class":115}," demo.ts\n",[47,157,159],{"id":158},"demo","Demo",[17,161,162],{},[70,163,164],{},"Terminal recording lands here — every premium response is backed by a real Sui testnet transaction, with Suiscan links printed in the run.",[47,166,168],{"id":167},"proof","Proof",[170,171,172,185,195],"ul",{},[55,173,174,177,178,184],{},[37,175,176],{},"npm:"," ",[21,179,182],{"href":180,"rel":181},"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fs402",[25],[42,183,34],{}," — the protocol, v0.9.0, deprecated since September 2026.",[55,186,187,188,27],{},"Built on ",[21,189,192],{"href":190,"rel":191},"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@sweefi\u002Fsui",[25],[42,193,194],{},"@sweefi\u002Fsui",[55,196,197,198,200],{},"Verified: server + ",[42,199,63],{}," handshake observed live; full settlement issues real testnet transactions.",[202,203,204],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":101,"searchDepth":123,"depth":123,"links":206},[207,208,209,210],{"id":49,"depth":123,"text":50},{"id":93,"depth":123,"text":94},{"id":158,"depth":123,"text":159},{"id":167,"depth":123,"text":168},"A runnable demo of s402 in motion — an AI agent hits an HTTP 402-gated API, discovers the price from the 402 itself, signs a real Sui payment, and gets the data. The agentic-payments loop, end to end. Retired with s402 in September 2026.","md",false,null,{},true,"\u002Fprojects\u002Fs402-agent-pays-api",[],{"title":5,"description":211},"Testnet","blue","projects\u002Fs402-agent-pays-api","An autonomous agent discovers a paywall and pays it on Sui, retired with s402",[225,226,227,228,229],"TypeScript","Sui","HTTP 402","AI Agent","Hono","working","testnet","oltHtH5-JHcsQYHw4InEvenY8YXnsMUmXJRAmZHw8_g",1792110478575]