{"_id":"@agent-tech/pay","_rev":"6-bc896ce5ca17b5c2c98205d78977f31d","name":"@agent-tech/pay","dist-tags":{"latest":"0.1.7"},"versions":{"0.1.0":{"name":"@agent-tech/pay","version":"0.1.0","license":"MIT","_id":"@agent-tech/pay@0.1.0","maintainers":[{"name":"agent_tech","email":"anna@agent.tech"}],"bin":{"agent-pay":"dist/cli/index.js"},"dist":{"shasum":"63fa414f17067cda8128513d93148aacc7a24ac4","tarball":"https://registry.npmjs.org/@agent-tech/pay/-/pay-0.1.0.tgz","fileCount":70,"integrity":"sha512-DK90I14d/D4OC2QPtQP2ydwC8SnyqKtMbjisnOf2jzjPE3T9QppbyuFIC5h106N9/Aie8YzXJhcZPgg8arP4uw==","signatures":[{"sig":"MEUCIC/+V/SRoNEwwncvHqza3NjUaNIErXCBnEc+e1bB4eXwAiEA0hJ7kJxQOfdhbNndJG0NYOjal6CAaJK17q6EhkF8fyc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":107968},"main":"./dist/cjs/index.js","type":"module","types":"./dist/esm/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.js"}},"./client":{"import":{"types":"./dist/esm/browser.d.ts","default":"./dist/esm/browser.js"},"require":{"types":"./dist/cjs/browser.d.ts","default":"./dist/cjs/browser.js"}},"./server":{"import":{"types":"./dist/esm/server.d.ts","default":"./dist/esm/server.js"},"require":{"types":"./dist/cjs/server.d.ts","default":"./dist/cjs/server.js"}}},"gitHead":"d9dc3b320206222663d9320b5ff16ebc2defadde","scripts":{"lint":"biome lint","test":"vitest run","build":"bun build ./src/index.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/index.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/server.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/server.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/browser.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/browser.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/cli/index.ts --outdir dist/cli --format esm --target node --packages external && tsc -p tsconfig.build.json && tsc -p tsconfig.build.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'}))\"","check":"biome check","format":"biome format --write ./src","typecheck":"tsc --noEmit","format:check":"biome format ./src"},"_npmUser":{"name":"agent_tech","email":"anna@agent.tech"},"_npmVersion":"11.10.1","description":"TypeScript client for the Agent Tech v2 payment API","directories":{},"sideEffects":false,"_nodeVersion":"25.7.0","dependencies":{"commander":"^12.1.0","@types/bun":"^1.3.9","camelcase-keys":"^10.0.2","decamelize-keys":"^2.0.1"},"publishConfig":{"access":"restricted"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","typescript":"^5.7.0","@types/node":"^25.3.1","@biomejs/biome":"^2.4.5"},"_npmOperationalInternal":{"tmp":"tmp/pay_0.1.0_1772553106610_0.820319546657934","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.1.4":{"name":"@agent-tech/pay","version":"0.1.4","license":"MIT","_id":"@agent-tech/pay@0.1.4","maintainers":[{"name":"agent_tech","email":"anna@agent.tech"},{"name":"paul-agent","email":"paul@agent.tech"}],"homepage":"https://github.com/agent-tech/AgentPay-SDK-JS-TS#readme","bugs":{"url":"https://github.com/agent-tech/AgentPay-SDK-JS-TS/issues"},"bin":{"agent-pay":"dist/cli/index.js"},"dist":{"shasum":"70150b8e68c3e422f711b527b7eca15f32836fba","tarball":"https://registry.npmjs.org/@agent-tech/pay/-/pay-0.1.4.tgz","fileCount":108,"integrity":"sha512-+aRWTus6IbzQ+J91jZ6bnVHBLmLULc14TKsfnjuKkgsCFyQvlwChpwMKvvWlEN2X5fQGuHAqycoSZnIDBVFCrw==","signatures":[{"sig":"MEUCIDCooVgisqqTCY5h+9+BxYihdAGgyl6W7gSU9cb2R1QYAiEA7g842NrkCmNvswu1zgIzJZP22dCFKjL8izLuAEctsM8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":217160},"main":"./dist/cjs/index.js","type":"module","types":"./dist/esm/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.js"}},"./client":{"import":{"types":"./dist/esm/browser.d.ts","default":"./dist/esm/browser.js"},"require":{"types":"./dist/cjs/browser.d.ts","default":"./dist/cjs/browser.js"}},"./server":{"import":{"types":"./dist/esm/server.d.ts","default":"./dist/esm/server.js"},"require":{"types":"./dist/cjs/server.d.ts","default":"./dist/cjs/server.js"}}},"gitHead":"1d82dcd9d49c3b5d2981ec34e53719f2955f4425","scripts":{"lint":"biome lint","test":"vitest run","build":"bun build ./src/index.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/index.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/server.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/server.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/browser.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/browser.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/cli/index.ts --outdir dist/cli --format esm --target node --packages external && tsc -p tsconfig.build.json && tsc -p tsconfig.build.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'}))\"","check":"biome check","format":"biome format --write ./src","typecheck":"tsc --noEmit","format:check":"biome format ./src"},"_npmUser":{"name":"paul-agent","email":"paul@agent.tech"},"repository":{"url":"git+https://github.com/agent-tech/AgentPay-SDK-JS-TS.git","type":"git"},"_npmVersion":"10.9.4","description":"TypeScript client for the Agent Tech v2 payment API","directories":{},"sideEffects":false,"_nodeVersion":"22.21.1","dependencies":{"zod":"^3.23.0","commander":"^12.1.0","@types/bun":"^1.3.9","camelcase-keys":"^10.0.2","decamelize-keys":"^2.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","typescript":"^5.7.0","@types/node":"^25.3.1","@biomejs/biome":"^2.4.5"},"_npmOperationalInternal":{"tmp":"tmp/pay_0.1.4_1772702913800_0.05925429474636745","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.1.6":{"name":"@agent-tech/pay","version":"0.1.6","license":"MIT","_id":"@agent-tech/pay@0.1.6","maintainers":[{"name":"agent_tech","email":"anna@agent.tech"},{"name":"paul-agent","email":"paul@agent.tech"}],"homepage":"https://github.com/agent-tech/AgentPay-SDK-JS-TS#readme","bugs":{"url":"https://github.com/agent-tech/AgentPay-SDK-JS-TS/issues"},"bin":{"agent-pay":"dist/cli/index.js"},"dist":{"shasum":"11a1d144a691faa4aaf8719652fd87d0ab6b7d4b","tarball":"https://registry.npmjs.org/@agent-tech/pay/-/pay-0.1.6.tgz","fileCount":82,"integrity":"sha512-11MaQki6y710Uz5CHM2QS+I3TJ3G09I/bJlqmuaURMXRnxeskdhpHWe2u54PnIMSCSNQgmm61onQp4wGv6nFyg==","signatures":[{"sig":"MEUCIE6Hs9bglXaTFla3jAasPDVNRo3pXS6mQrEZOC7CF4xqAiEA7jn9dXjXkAnat3rSN51GnIPT4Jdvq2bEt3Mm3kY51/w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@agent-tech%2fpay@0.1.6","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":130199},"main":"./dist/cjs/index.js","type":"module","types":"./dist/esm/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.js"}},"./client":{"import":{"types":"./dist/esm/browser.d.ts","default":"./dist/esm/browser.js"},"require":{"types":"./dist/cjs/browser.d.ts","default":"./dist/cjs/browser.js"}},"./server":{"import":{"types":"./dist/esm/server.d.ts","default":"./dist/esm/server.js"},"require":{"types":"./dist/cjs/server.d.ts","default":"./dist/cjs/server.js"}}},"gitHead":"823d2dd0a4acfe1fca2b60b347589ca3af5f6cdc","scripts":{"lint":"biome lint","test":"vitest run","build":"bun build ./src/index.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/index.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/server.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/server.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/browser.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/browser.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/cli/index.ts --outdir dist/cli --format esm --target node --packages external && tsc -p tsconfig.build.json && tsc -p tsconfig.build.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'}))\"","check":"biome check","format":"biome format --write ./src","typecheck":"tsc --noEmit","format:check":"biome format ./src"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:1965d41d-de8c-4d4c-91a2-485bcacb88af"}},"repository":{"url":"git+https://github.com/agent-tech/AgentPay-SDK-JS-TS.git","type":"git"},"_npmVersion":"11.11.0","description":"TypeScript client for the Agent Tech v2 payment API","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"zod":"^3.23.0","commander":"^12.1.0","@types/bun":"^1.3.9","camelcase-keys":"^10.0.2","decamelize-keys":"^2.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","typescript":"^5.7.0","@types/node":"^25.3.1","@biomejs/biome":"^2.4.5"},"_npmOperationalInternal":{"tmp":"tmp/pay_0.1.6_1772705132366_0.6702976115242045","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.1.7":{"name":"@agent-tech/pay","version":"0.1.7","license":"MIT","_id":"@agent-tech/pay@0.1.7","maintainers":[{"name":"agent_tech","email":"anna@agent.tech"},{"name":"paul-agent","email":"paul@agent.tech"}],"homepage":"https://github.com/agent-tech/AgentPay-SDK-JS-TS#readme","bugs":{"url":"https://github.com/agent-tech/AgentPay-SDK-JS-TS/issues"},"bin":{"agent-pay":"dist/cli/index.js"},"dist":{"shasum":"17eb192bd401c68c45e475d5fe2ba1f6005e35ca","tarball":"https://registry.npmjs.org/@agent-tech/pay/-/pay-0.1.7.tgz","fileCount":112,"integrity":"sha512-/FSdzFsoX6iE/EGV3gwZoiu16lPF1iX/UKCqNKw0ofGUmHpi0/I/SIhI41cokw519t1NYNmYKKy77T6crxvk0Q==","signatures":[{"sig":"MEYCIQC8F0jeZ0cWZ/3aUFV9mHmuNBkHUPUnkayzlPpf/jap5AIhAK/5I55ExWqBwpFUDTkL8CWk5+15MHXvGzlOXjCjU7Vp","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":217697},"main":"./dist/cjs/index.js","type":"module","types":"./dist/esm/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.js"}},"./client":{"import":{"types":"./dist/esm/browser.d.ts","default":"./dist/esm/browser.js"},"require":{"types":"./dist/cjs/browser.d.ts","default":"./dist/cjs/browser.js"}},"./server":{"import":{"types":"./dist/esm/server.d.ts","default":"./dist/esm/server.js"},"require":{"types":"./dist/cjs/server.d.ts","default":"./dist/cjs/server.js"}}},"gitHead":"b265338b3830f7e4d5e1a41e23e8e3fd7a2fd8da","scripts":{"lint":"biome lint","test":"vitest run","build":"bun build ./src/index.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/index.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/server.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/server.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/browser.ts --outdir dist/esm --format esm --target node --packages external && bun build ./src/browser.ts --outdir dist/cjs --format cjs --target node --packages external && bun build ./src/cli/index.ts --outdir dist/cli --format esm --target node --packages external && tsc -p tsconfig.build.json && tsc -p tsconfig.build.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'}))\"","check":"biome check","format":"biome format --write ./src","typecheck":"tsc --noEmit","format:check":"biome format ./src"},"_npmUser":{"name":"paul-agent","email":"paul@agent.tech"},"repository":{"url":"git+https://github.com/agent-tech/AgentPay-SDK-JS-TS.git","type":"git"},"_npmVersion":"10.9.4","description":"TypeScript client for the Agent Tech v2 payment API","directories":{},"sideEffects":false,"_nodeVersion":"22.21.1","dependencies":{"zod":"^3.23.0","commander":"^12.1.0","@types/bun":"^1.3.9","camelcase-keys":"^10.0.2","decamelize-keys":"^2.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","typescript":"^5.7.0","@types/node":"^25.3.1","@biomejs/biome":"^2.4.5"},"_npmOperationalInternal":{"tmp":"tmp/pay_0.1.7_1772706147673_0.29915422469308806","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2026-03-03T15:51:46.486Z","modified":"2026-03-15T11:15:34.696Z","0.1.0":"2026-03-03T15:51:46.758Z","0.1.4":"2026-03-05T09:28:33.940Z","0.1.6":"2026-03-05T10:05:32.520Z","0.1.7":"2026-03-05T10:22:27.807Z"},"bugs":{"url":"https://github.com/agent-tech/AgentPay-SDK-JS-TS/issues"},"license":"MIT","homepage":"https://github.com/agent-tech/AgentPay-SDK-JS-TS#readme","repository":{"url":"git+https://github.com/agent-tech/AgentPay-SDK-JS-TS.git","type":"git"},"description":"TypeScript client for the Agent Tech v2 payment API","maintainers":[{"name":"agent_tech","email":"anna@agent.tech"},{"name":"paul-agent","email":"paul@agent.tech"}],"readme":"# Pay SDK (JS & TS)\n\n[![npm version](https://img.shields.io/npm/v/@agent-tech/pay.svg)](https://www.npmjs.com/package/@agent-tech/pay)\n[![node](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)](https://nodejs.org)\n[![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](https://www.typescriptlang.org)\n\nJavascript & TypeScript client for the Agent Tech payment API — create intents, execute USDC transfers on Base, and query status.\n\n- **Lightweight** — two small runtime deps for key conversion; uses built-in `fetch` (Node 18+)\n- **Dual ESM + CommonJS** — works in TypeScript and JavaScript projects\n- **Two clients** — `PayClient` (authenticated, server-side) and `PublicPayClient` (unauthenticated, payer-side)\n- **Bearer token authentication** for PayClient\n- **All payments settle on Base** chain\n\n## Table of Contents\n\n- [Install](#install)\n- [Quick Start](#quick-start)\n- [Direct Imports (Server / Client)](#direct-imports-server--client)\n- [CLI](#cli)\n- [Cursor Skills](#skills)\n- [Clients](#clients)\n  - [PayClient (Authenticated)](#payclient-authenticated)\n  - [PublicPayClient (Unauthenticated)](#publicpayclient-unauthenticated)\n- [Authentication](#authentication)\n- [API Methods](#api-methods)\n- [Intent Lifecycle](#intent-lifecycle)\n- [Supported Chains](#supported-chains)\n- [Fee Breakdown](#fee-breakdown)\n- [Error Handling](#error-handling)\n- [Advanced](#advanced)\n\n## Install\n\n```bash\nnpm install @agent-tech/pay\n```\n\n## Quick Start\n\n### TypeScript (ESM)\n\n```ts\nimport { PayClient, IntentStatus } from \"@agent-tech/pay\";\n\nconst client = new PayClient({\n  baseUrl: \"https://api-pay.agent.tech\",\n  auth: { apiKey: \"your-api-key\", secretKey: \"your-secret-key\" },\n});\n\n// 1. Create intent\nconst resp = await client.createIntent({\n  email: \"merchant@example.com\",\n  amount: \"100.50\",\n  payerChain: \"solana\",\n});\nconsole.log(\"Intent ID:\", resp.intentId);\n\n// 2. Execute transfer (backend signs with Agent wallet)\nconst exec = await client.executeIntent(resp.intentId);\nconsole.log(\"Status:\", exec.status);\n\n// 3. Query full receipt\nconst intent = await client.getIntent(resp.intentId);\nconsole.log(\"Final status:\", intent.status);\n```\n\n### JavaScript (CommonJS)\n\n```js\nconst { PayClient } = require(\"@agent-tech/pay\");\n\nconst client = new PayClient({\n  baseUrl: \"https://api-pay.agent.tech\",\n  auth: { apiKey: \"your-api-key\", secretKey: \"your-secret-key\" },\n});\n\nasync function main() {\n  const resp = await client.createIntent({\n    email: \"merchant@example.com\",\n    amount: \"100.50\",\n    payerChain: \"solana\",\n  });\n  console.log(\"Intent ID:\", resp.intentId);\n}\nmain();\n```\n\n### Run the bundled example\n\n```bash\ngit clone https://github.com/agent-tech/agent-sdk-js\ncd agent-sdk-js\nnpm install\n\nPAY_BASE_URL=https://api-pay.agent.tech \\\nPAY_API_KEY=your-api-key \\\nPAY_SECRET_KEY=your-secret-key \\\nnpx tsx examples/basic.ts\n```\n\nSet `PAY_INTENT_ID` to skip creation and query an existing intent instead.\n\n## Direct Imports (Server / Client)\n\nFor clearer separation of concerns, use dedicated entry points:\n\n**Server-side** (contains `secretKey` — use only on the backend):\n\n```ts\nimport { PayClient } from \"@agent-tech/pay/server\";\n\nconst client = new PayClient({\n  baseUrl: \"https://api-pay.agent.tech\",\n  auth: { apiKey: \"your-api-key\", secretKey: \"your-secret-key\" },\n});\n```\n\n**Client-side** (no secret credentials — safe for browser / payer-side code):\n\n```ts\nimport { PublicPayClient } from \"@agent-tech/pay/client\";\n\nconst client = new PublicPayClient({\n  baseUrl: \"https://api-pay.agent.tech\",\n});\n```\n\nThe default `@agent-tech/pay` entry still exports both clients for backward compatibility.\n\n## CLI\n\nThe package includes a CLI (`agent-pay`) for auth management and intent operations.\n\n### Install & run\n\n```bash\nnpm install -g @agent-tech/pay\nagent-pay --help\n```\n\nOr run via `npx`:\n\n```bash\nnpx @agent-tech/pay auth show\n```\n\n### Auth commands\n\n| Command | Description |\n|---------|-------------|\n| `agent-pay auth set --api-key <key> --secret-key <key> --base-url <url>` | Save credentials to `~/.agent-tech-pay/config.json` |\n| `agent-pay auth show` | Show current config (secret key masked) |\n| `agent-pay auth clear` | Remove stored config |\n| `agent-pay balance read --address <addr> [--rpc-url <url>]` | Read agent USDC balance from Base chain (default RPC: https://mainnet.base.org) |\n| `agent-pay reset [--yes]` | Remove **all** stored config + sessions |\n\nEnv vars `PAY_API_KEY`, `PAY_SECRET_KEY`, `PAY_BASE_URL` can be used instead of flags for `auth set`.\n\n### Intent commands\n\nRequires auth config (except `submit-proof`). Use `auth set` first.\n\n| Command | Description |\n|---------|-------------|\n| `agent-pay intent create --amount <val> --payer-chain <chain> [--email <e> \\| --recipient <r>]` | Create intent (server-side) |\n| `agent-pay intent execute [intent-id]` | Execute intent (server-side). If omitted, uses latest active session |\n| `agent-pay intent get [intent-id]` | Get intent status (server-side). If omitted, uses latest active session |\n| `agent-pay intent submit-proof <intent-id> --proof <settle-proof>` | Submit settle proof (client-side, no auth) |\n| `agent-pay intent sessions [--expired]` | List stored sessions (optionally expired only) |\n\nFor `submit-proof`, `--base-url` or stored config is used; no secret key required.\n\n## Skills\n\n### npx (skills.sh)\n\n```bash\nnpx skills add agent-tech/AgentPay-SDK-JS-TS\n```\n\nThe `skills` CLI uses the format `npx skills add <github-org>/<github-repo>`. See [skills.sh documentation](https://skills.sh/docs).\n\n### Clawhub\n\n```bash\nclawhub skills add agent-tech/AgentPay-SDK-JS-TS\n```\n\nInstall the same skill via [Clawhub](https://clawhub.ai) with the same `<org>/<repo>` format.\n\n## Clients\n\nThe SDK provides two client classes for different use cases.\n\n### PayClient (Authenticated)\n\nServer-side client that uses `/v2` endpoints with authentication. The backend Agent wallet signs and executes transfers — no wallet or signing required on your side.\n\n```ts\nimport { PayClient } from \"@agent-tech/pay\";\n\nconst client = new PayClient({\n  baseUrl: \"https://api-pay.agent.tech\",\n  auth: { apiKey: \"id\", secretKey: \"secret\" },\n});\n\nconst intent = await client.createIntent({ email: \"merchant@example.com\", amount: \"10.00\", payerChain: \"solana\" });\nconst exec   = await client.executeIntent(intent.intentId);\nconst status = await client.getIntent(intent.intentId);\n```\n\n| Method | Endpoint | Description |\n|---|---|---|\n| `createIntent(req)` | `POST /v2/intents` | Create a payment intent |\n| `executeIntent(id)` | `POST /v2/intents/{id}/execute` | Execute transfer on Base with Agent wallet |\n| `getIntent(id)` | `GET /v2/intents?intent_id=...` | Get intent status and receipt |\n\n### PublicPayClient (Unauthenticated)\n\nClient-side / payer-side client that uses `/api` endpoints without authentication. Use this when the integrator holds the payer's wallet and can sign X402 payments and submit settle proofs directly.\n\nBoth clients use the same `baseUrl` (API root without path prefix, e.g. `https://api-pay.agent.tech`).\n\n```ts\nimport { PublicPayClient } from \"@agent-tech/pay\";\n\nconst client = new PublicPayClient({\n  baseUrl: \"https://api-pay.agent.tech\",\n});\n\nconst intent = await client.createIntent({ recipient: \"0x...\", amount: \"10.00\", payerChain: \"base\" });\n// ... payer signs X402 payment off-chain ...\nconst result = await client.submitProof(intent.intentId, \"settle_proof_string\");\nconst status = await client.getIntent(intent.intentId);\n```\n\n| Method | Endpoint | Description |\n|---|---|---|\n| `createIntent(req)` | `POST /api/intents` | Create a payment intent |\n| `submitProof(id, proof)` | `POST /api/intents/{id}` | Submit settle proof after X402 payment |\n| `getIntent(id)` | `GET /api/intents?intent_id=...` | Get intent status and receipt |\n\n## Authentication\n\nAuthentication applies to `PayClient` only. `PublicPayClient` requires no credentials.\n\n### Bearer token\n\nBase64-encodes `apiKey:secretKey` and sends it as `Authorization: Bearer <token>`.\n\n```ts\nconst client = new PayClient({\n  baseUrl,\n  auth: { apiKey: \"api-key\", secretKey: \"secret-key\" },\n});\n```\n\n### Custom fetch / timeout\n\nThe default timeout is **30 seconds** for both clients. Override with options:\n\n```ts\nconst client = new PayClient({\n  baseUrl,\n  auth: { apiKey: \"id\", secretKey: \"secret\" },\n  timeoutMs: 60_000,\n});\n\n// PublicPayClient supports the same options (minus auth)\nconst publicClient = new PublicPayClient({ baseUrl, timeoutMs: 60_000 });\n```\n\nOr provide a custom `fetcher` implementation (timeout is ignored when custom fetcher is provided):\n\n```ts\nconst client = new PayClient({\n  baseUrl,\n  auth: { apiKey: \"id\", secretKey: \"secret\" },\n  fetcher: myCustomFetcher,\n});\n```\n\n## API Methods\n\n### PayClient\n\n| Method | Endpoint | Description |\n|---|---|---|\n| `createIntent` | `POST /v2/intents` | Create a payment intent |\n| `executeIntent` | `POST /v2/intents/{id}/execute` | Execute transfer on Base with Agent wallet |\n| `getIntent` | `GET /v2/intents?intent_id=...` | Get intent status and receipt |\n\n### PublicPayClient\n\n| Method | Endpoint | Description |\n|---|---|---|\n| `createIntent` | `POST /api/intents` | Create a payment intent |\n| `submitProof` | `POST /api/intents/{id}` | Submit settle proof after X402 payment |\n| `getIntent` | `GET /api/intents?intent_id=...` | Get intent status and receipt |\n\n### createIntent\n\nAvailable on both clients. Exactly one of `email` or `recipient` must be provided.\n\n```ts\nconst resp = await client.createIntent({\n  email: \"merchant@example.com\", // or recipient (exactly one required)\n  amount: \"100.50\",              // 0.01–1,000,000 USDC, max 6 decimals\n  payerChain: \"solana\",          // \"solana\", \"base\"\n});\n```\n\n**`CreateIntentRequest` fields:**\n\n| Field | JSON | Required | Description |\n|---|---|---|---|\n| `email` | `email` | One of email/recipient | Recipient email address |\n| `recipient` | `recipient` | One of email/recipient | Recipient wallet address |\n| `amount` | `amount` | Yes | USDC amount as string (e.g. `\"100.50\"`) |\n| `payerChain` | `payer_chain` | Yes | Source chain: `solana`, `base` |\n\n### executeIntent (PayClient only)\n\nNo request body — the backend uses the Agent wallet to sign and transfer USDC on Base.\n\n```ts\nconst exec = await client.executeIntent(resp.intentId);\n// exec.status is typically \"BASE_SETTLED\"\n```\n\n### submitProof (PublicPayClient only)\n\nSubmit a settle proof after the payer has completed an X402 payment off-chain.\n\n```ts\nconst result = await publicClient.submitProof(intentId, \"settle_proof_string\");\nconsole.log(result.status);\n```\n\n### getIntent (query status)\n\nAvailable on both clients.\n\n```ts\nconst intent = await client.getIntent(intentId);\nswitch (intent.status) {\n  case IntentStatus.BaseSettled:\n    // use intent.basePayment for receipt\n    break;\n  case IntentStatus.Expired:\n  case IntentStatus.VerificationFailed:\n    // terminal failure\n    break;\n  default:\n    // still processing — poll again\n}\n```\n\n## Intent Lifecycle\n\nIntents expire **10 minutes** after creation.\n\n```\n                          ┌──────────────────┐\n                          │ AWAITING_PAYMENT  │\n                          └────────┬─────────┘\n                                   │\n                      ┌────────────┼────────────┐\n                      │            │            │\n                      ▼            ▼            ▼\n               ┌──────────┐ ┌──────────┐ ┌─────────────────────┐\n               │ EXPIRED  │ │ PENDING  │ │ VERIFICATION_FAILED │\n               └──────────┘ └────┬─────┘ └─────────────────────┘\n                                 │\n                                 ▼\n                        ┌────────────────┐\n                        │ SOURCE_SETTLED │\n                        └───────┬────────┘\n                                │\n                                ▼\n                        ┌───────────────┐\n                        │ BASE_SETTLING │\n                        └───────┬───────┘\n                                │\n                                ▼\n                        ┌──────────────┐\n                        │ BASE_SETTLED │\n                        └──────────────┘\n```\n\nUse the status constants instead of bare strings:\n\n| Constant | Value | Description |\n|---|---|---|\n| `IntentStatus.AwaitingPayment` | `AWAITING_PAYMENT` | Intent created, waiting for execution |\n| `IntentStatus.Pending` | `PENDING` | Execution initiated, processing |\n| `IntentStatus.VerificationFailed` | `VERIFICATION_FAILED` | Source payment verification failed (terminal) |\n| `IntentStatus.SourceSettled` | `SOURCE_SETTLED` | Source chain payment confirmed |\n| `IntentStatus.BaseSettling` | `BASE_SETTLING` | USDC transfer on Base in progress |\n| `IntentStatus.BaseSettled` | `BASE_SETTLED` | Transfer complete — check `basePayment` for receipt (terminal) |\n| `IntentStatus.Expired` | `EXPIRED` | Intent was not executed within 10 minutes (terminal) |\n\n## Supported Chains\n\n| Chain | Identifier | Role |\n|---|---|---|\n| Solana | `solana` | Payer chain (source) |\n| Base | `base` | Payer chain (source) **and** settlement chain (target) |\n\nAll payments settle on **Base** regardless of the source chain. The `payerChain` field in `CreateIntentRequest` specifies the source chain only.\n\n## Fee Breakdown\n\nThe `FeeBreakdown` interface is included in all intent response types (via `IntentBase`):\n\n| Field | JSON | Description |\n|---|---|---|\n| `sourceChain` | `source_chain` | Source chain identifier |\n| `sourceChainFee` | `source_chain_fee` | Gas/network fee on the source chain |\n| `targetChain` | `target_chain` | Target chain (always `\"base\"`) |\n| `targetChainFee` | `target_chain_fee` | Gas/network fee on Base |\n| `platformFee` | `platform_fee` | Platform service fee |\n| `platformFeePercentage` | `platform_fee_percentage` | Platform fee as a percentage |\n| `totalFee` | `total_fee` | Sum of all fees |\n\n**Amount rules:**\n- Minimum: **0.01 USDC**\n- Maximum: **1,000,000 USDC**\n- Up to **6 decimal places** (e.g. `\"0.000001\"`, `\"123.45\"`)\n\n## Error Handling\n\nThe SDK uses two error classes:\n\n**`PayApiError`** — thrown for non-2xx HTTP responses from the API:\n\n```ts\nimport { PayApiError } from \"@agent-tech/pay\";\n\ntry {\n  await client.createIntent(req);\n} catch (err) {\n  if (err instanceof PayApiError) {\n    console.log(`HTTP ${err.statusCode}: ${err.message}`);\n  }\n}\n```\n\n**`PayValidationError`** — thrown when the SDK rejects a request before it reaches the API. Input validation is implemented with [Zod](https://zod.dev); error messages follow the format `validation: <message>`.\n\n```ts\nimport { PayValidationError } from \"@agent-tech/pay\";\n\ntry {\n  await client.executeIntent(\"\");\n} catch (err) {\n  if (err instanceof PayValidationError) {\n    console.log(`Invalid input: ${err.message}`);\n  }\n}\n```\n\n**When `PayValidationError` is thrown:**\n\n| Context | Rule |\n|---|---|\n| **Client constructor** | `baseUrl` is required and must not be empty |\n| **PayClient constructor** | `auth.apiKey` and `auth.secretKey` are required and must not be empty |\n| **createIntent** | `request` is required; exactly one of `email` or `recipient` must be provided; `amount` is required, must be a valid number, and ≥ 0.2 USDC; `payerChain` is required and must not be empty |\n| **executeIntent / getIntent** | `intentId` is required and must not be empty |\n| **submitProof** (PublicPayClient) | `intentId` and `settleProof` are required and must not be empty |\n\n| Status Code | Meaning |\n|---|---|\n| 400 | Bad request — invalid parameters, amount out of range, or malformed input |\n| 401 | Unauthorized — missing or invalid credentials |\n| 403 | Forbidden — insufficient permissions for this operation |\n| 404 | Not found — intent does not exist |\n| 429 | Rate limited — too many requests (60 req/min/IP typical) |\n| 503 | Service unavailable — temporary backend issue |\n\n## Advanced\n\n### AbortSignal for cancellation\n\nAll API methods accept an optional `AbortSignal` for cancellation:\n\n```ts\nconst controller = new AbortController();\nsetTimeout(() => controller.abort(), 5000);\n\nconst resp = await client.createIntent(req, controller.signal);\n```\n\n### Rate limiting\n\nThe API allows approximately **60 requests per IP per minute**. On HTTP 429, implement exponential backoff:\n\n```ts\ntry {\n  await client.getIntent(id);\n} catch (err) {\n  if (err instanceof PayApiError && err.statusCode === 429) {\n    await sleep(backoff);\n    // retry\n  }\n}\n```\n","readmeFilename":"README.md"}