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