{"_id":"@agentwares/x402","_rev":"3-4d4d4b3f0400ddaca9f29c9e2bd620c4","name":"@agentwares/x402","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@agentwares/x402","version":"0.1.0","keywords":["x402","402","payment-required","micropayments","pay-per-call","agent-payments","mcp","ai-agents","stripe"],"license":"MIT","_id":"@agentwares/x402@0.1.0","maintainers":[{"name":"umerbukhari","email":"umer.bukhari@gmail.com"}],"homepage":"https://github.com/agentwares/libs/tree/main/packages/x402#readme","bugs":{"url":"https://github.com/agentwares/libs/issues"},"dist":{"shasum":"55bd3e89bb025bd14ad6bc912eb84ee28feab0d3","tarball":"https://registry.npmjs.org/@agentwares/x402/-/x402-0.1.0.tgz","fileCount":6,"integrity":"sha512-TONA+ybKrtWhBPZRfC0JEi4rIYolMi/E6b8W56mLNHxPFZWunxT6Da+/JY2SjgDp5bIrk7A8Qd/LhPE2HXut9w==","signatures":[{"sig":"MEYCIQDzesh9x6WY2MYu8XdbSTMPQ7kz5ZaBMmWWFknBBFySGAIhANawIkvVu35yvipkPBAY34pgKGlhCCQyzUWgci5wbZMo","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18557},"main":"./dist/index.js","type":"module","_from":"file:agentwares-x402-0.1.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"lint":"eslint src","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"umerbukhari","email":"umer.bukhari@gmail.com"},"_resolved":"/private/var/folders/2p/2j2wcvfs4wz6v0nfr4h455k40000gn/T/cf1c8565dd8bf8c6e63fbec6e6697ee3/agentwares-x402-0.1.0.tgz","_integrity":"sha512-TONA+ybKrtWhBPZRfC0JEi4rIYolMi/E6b8W56mLNHxPFZWunxT6Da+/JY2SjgDp5bIrk7A8Qd/LhPE2HXut9w==","repository":{"url":"git+https://github.com/agentwares/libs.git","type":"git","directory":"packages/x402"},"_npmVersion":"10.9.8","description":"402 Payment Required for paid HTTP endpoints and MCP tools: build the response with x402 and Stripe MPP payment requirements, a structured code/cause/fix/retryable body, and a pluggable PaymentVerifier. Web-standard, zero Node dependencies.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"zod":"^4.5.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/x402_0.1.0_1788805231762_0.2141976767323739","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@agentwares/x402","version":"0.2.0","keywords":["x402","402","payment-required","micropayments","pay-per-call","agent-payments","mcp","ai-agents","stripe"],"license":"MIT","_id":"@agentwares/x402@0.2.0","maintainers":[{"name":"umerbukhari","email":"umer.bukhari@gmail.com"}],"homepage":"https://github.com/agentwares/libs/tree/main/packages/x402#readme","bugs":{"url":"https://github.com/agentwares/libs/issues"},"dist":{"shasum":"27c14db256647a8d846a3c04dcd0b31a731559a2","tarball":"https://registry.npmjs.org/@agentwares/x402/-/x402-0.2.0.tgz","fileCount":6,"integrity":"sha512-u81sSpzz8XZcTZoFvK0QHEnRo63CaTE1iN/vtW9T52ixcWPfhhjctVqRoyn3MoAqw/xin41FE7/Ytii0qwfyzA==","signatures":[{"sig":"MEQCIGEYytzZxfbPxjFyK3mRKPXEtdxmJXvafA8wcH9iQzaAAiAoJNDeOc6p/Oew4YPC7H+YoZ3A8mvqY4onvv0TuNer4Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51034},"main":"./dist/index.js","type":"module","_from":"file:agentwares-x402-0.2.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"lint":"eslint src","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"umerbukhari","email":"umer.bukhari@gmail.com"},"_resolved":"/private/var/folders/2p/2j2wcvfs4wz6v0nfr4h455k40000gn/T/eb7bce567f135a3635021192c198e063/agentwares-x402-0.2.0.tgz","_integrity":"sha512-u81sSpzz8XZcTZoFvK0QHEnRo63CaTE1iN/vtW9T52ixcWPfhhjctVqRoyn3MoAqw/xin41FE7/Ytii0qwfyzA==","repository":{"url":"git+https://github.com/agentwares/libs.git","type":"git","directory":"packages/x402"},"_npmVersion":"10.9.8","description":"402 Payment Required for paid HTTP endpoints and MCP tools: build the response with x402 and Stripe MPP payment requirements, a structured code/cause/fix/retryable body, and a pluggable PaymentVerifier. Web-standard, zero Node dependencies.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"zod":"^4.5.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/x402_0.2.0_1788820498645_0.5419323819465982","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@agentwares/x402","version":"0.2.1","description":"402 Payment Required for paid HTTP endpoints and MCP tools: build the response with x402 and Stripe MPP payment requirements, a structured code/cause/fix/retryable body, and a pluggable PaymentVerifier. Web-standard, zero Node dependencies.","license":"MIT","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/agentwares/libs.git","directory":"packages/x402"},"homepage":"https://github.com/agentwares/libs/tree/main/packages/x402#readme","bugs":{"url":"https://github.com/agentwares/libs/issues"},"keywords":["x402","402","payment-required","micropayments","pay-per-call","agent-payments","mcp","ai-agents","stripe"],"sideEffects":false,"engines":{"node":">=20"},"scripts":{"build":"tsup","typecheck":"tsc --noEmit","lint":"eslint src","test":"vitest run"},"dependencies":{"zod":"^4.5.4"},"gitHead":"d55ef0f39099b901738f22689c2c40fa516d6d5d","_id":"@agentwares/x402@0.2.1","_nodeVersion":"22.23.2","_npmVersion":"12.0.2","dist":{"integrity":"sha512-Q+OwkEB9lUe7yPhB5RsXFpHLgdm4MG0sda9qkl/XRHEoVHiXN+7qGGf5LDZ97aGCD6HeUs/khSh6LsSJUO3mQw==","shasum":"bc950a30f48798b9f9ba4f11529bc986dbd0c6e6","tarball":"https://registry.npmjs.org/@agentwares/x402/-/x402-0.2.1.tgz","fileCount":6,"unpackedSize":57244,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICNUoNQwMq9na5oTUmHd32aOuVYlKljC4Ch7Myql5SWvAiAFflT8HWZkG8VHEX2fIWHtz8tFdCs31QfqyZJdWptg4Q=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:fcb7305c-301e-4901-980d-e8675cf6c0c9"}},"directories":{},"maintainers":[{"name":"umerbukhari","email":"umer.bukhari@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/x402_0.2.1_1789020259500_0.12541959962439564"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-07T18:20:31.537Z","modified":"2026-09-10T06:04:20.541Z","0.1.0":"2026-09-07T18:20:31.911Z","0.2.0":"2026-09-07T22:34:58.780Z","0.2.1":"2026-09-10T06:04:19.644Z"},"bugs":{"url":"https://github.com/agentwares/libs/issues"},"license":"MIT","homepage":"https://github.com/agentwares/libs/tree/main/packages/x402#readme","keywords":["x402","402","payment-required","micropayments","pay-per-call","agent-payments","mcp","ai-agents","stripe"],"repository":{"type":"git","url":"git+https://github.com/agentwares/libs.git","directory":"packages/x402"},"description":"402 Payment Required for paid HTTP endpoints and MCP tools: build the response with x402 and Stripe MPP payment requirements, a structured code/cause/fix/retryable body, and a pluggable PaymentVerifier. Web-standard, zero Node dependencies.","maintainers":[{"name":"umerbukhari","email":"umer.bukhari@gmail.com"}],"readme":"# @agentwares/x402\n\n`402 Payment Required` for paid HTTP endpoints and MCP tools. It builds the response an agent can\nact on without a human: machine-readable payment requirements for both rails (x402 on Base via\nUSDC, and Stripe's Machine Payments Protocol), a structured `code` / `cause` / `fix` / `retryable`\nbody, and the `PaymentVerifier` interface your wallet implements.\n\nNo dependencies beyond `zod`, no Node built-ins, nothing that holds funds. Web-standard `Request`\nand `Response`, so it runs unchanged on Vercel Functions, Cloudflare Workers and Node 20+.\n\n```sh\nnpm install @agentwares/x402\n```\n\n## Answer a paid call\n\n```ts\nimport { paymentRequiredResponse, StubVerifier } from \"@agentwares/x402\";\n\nconst verifier = new StubVerifier(); // swap for your wallet-backed verifier\n\nexport async function GET(request: Request) {\n  const paid = await verifier.verify(request, {\n    rail: \"x402\",\n    amountUsd: \"0.05\",\n    resource: \"/quote\",\n  });\n  if (!paid.ok) {\n    return paymentRequiredResponse({\n      resource: \"/quote\",\n      priceUsd: 0.05,\n      description: \"One property quote\",\n      signupUrl: \"https://example.com/keys\", // offered as the way to pay today\n    });\n  }\n  return Response.json({ quote: 42 });\n}\n```\n\nThe caller gets `402` with `WWW-Authenticate: Payment realm=…`, an `X-Payment-Requirements`\nheader (JSON) plus its base64 `PAYMENT-REQUIRED` twin, and a body like:\n\n```json\n{\n  \"code\": \"PAYMENT_REQUIRED\",\n  \"cause\": \"This call costs $0.05. Pay-per-call (x402 / Stripe MPP) is coming soon; use an API key with prepaid credits.\",\n  \"fix\": \"Create an API key at https://example.com/keys and retry with Authorization: Bearer <key>. Try the free sample mode first.\",\n  \"retryable\": true,\n  \"priceUsd\": 0.05,\n  \"accepts\": [\n    {\n      \"rail\": \"x402\",\n      \"amountUsd\": \"0.05\",\n      \"resource\": \"/quote\",\n      \"network\": \"eip155:8453\",\n      \"asset\": \"USDC\",\n      \"maxTimeoutSeconds\": 300\n    },\n    {\n      \"rail\": \"prepaid_credits\",\n      \"amountUsd\": \"0.05\",\n      \"resource\": \"/quote\",\n      \"currency\": \"usd\",\n      \"maxTimeoutSeconds\": 300\n    }\n  ],\n  \"comingSoon\": true,\n  \"alternatives\": [\"api_key_credits\", \"sample_mode\"]\n}\n```\n\n## API\n\n| Export                                | What it does                                                                                          |\n| ------------------------------------- | ----------------------------------------------------------------------------------------------------- |\n| `buildPaymentRequired(opts)`          | `{ status, headers, body }` for the 402 — use it when you build the response yourself                 |\n| `paymentRequiredResponse(opts)`       | the same thing as a Web-standard `Response`                                                           |\n| `PaymentVerifier`                     | `verify(request, requirement) => Promise<VerifyResult>` — implement this against your wallet          |\n| `StubVerifier`                        | never accepts, never touches funds; use it until a real verifier exists                               |\n| `X402_HEADER`, `X402_REQUIRED_HEADER` | the two header names, so clients and servers agree                                                    |\n| types                                 | `PaymentRail`, `PaymentRequirement`, `PaymentRequiredBody`, `PaymentRequiredResponse`, `VerifyResult` |\n\n`opts.live` controls the wording: with `live: false` (the default) the body says pay-per-call is\ncoming soon and points the agent at API keys with prepaid credits, and sets `comingSoon: true`.\nFlip it to `true` the day a verifier can actually settle.\n\n## Used by\n\n[`@agentwares/mcp-kit`](https://www.npmjs.com/package/@agentwares/mcp-kit)'s `withPayment` wraps an\nMCP tool with exactly this body, so a paid tool and a paid HTTP endpoint answer the same shape.\n\nMIT © agentwares contributors — part of the [agentwares](https://agentwares.vercel.app) portfolio.\n","readmeFilename":"README.md"}