@agentaos/pay is a server-side TypeScript SDK for the AgentaOS Payment API. AgentaOS is a Merchant of Record: create a checkout or a payment link, and AgentaOS collects the payment (card or wallet), calculates and remits tax, issues the invoice, and settles to your balance. The SDK is a thin, typed wrapper over the REST API, one class per resource, camelCase in, camelCase out.
Install
Requires Node.js 20+. The package ships as ESM only (
"type": "module") with zero runtime dependencies, its HTTP layer is the built-in fetch.Initialize
sk_test_ and sk_live_ key.
Authentication
The constructor takes one positional argument, your key, and detects which auth mode to use from its shape. There is no separate flag to set:A JWT-mode client is how the AgentaOS CLI authenticates its own SDK calls after
agenta login. If you’re building a normal backend integration, use an API key.Options
The second constructor argument configures transport behavior. Every field is optional.string
default:"https://api.agentaos.ai"
API origin. Each resource appends its own path (e.g.
/api/v1/gateway/sessions) to this origin, so set this to override the host, not to add a path prefix. Useful for pointing at a local or staging server.number
default:"30000"
Per-attempt request timeout in milliseconds. On timeout the call throws
TimeoutError, which is not retried. If maxRetries is set, each retry attempt gets its own fresh timeout window, worst-case latency is roughly (maxRetries + 1) × timeout plus backoff delay.number
default:"2"
Max retries on
5xx responses and network errors, with exponential backoff (1s, 2s, 4s..., capped at 10s). Set 0 to disable. A 429 is retried inline at most once when the server’s Retry-After is 60s or less; otherwise it throws immediately. See Errors → Retry behavior.boolean
default:"false"
Logs each request (
METHOD path -> status (Nms)) and retry/backoff events to stderr. Never logs your API key or request/response bodies.(level: 'debug' | 'info' | 'warn' | 'error', message: string) => void
Custom sink for debug output instead of
stderr. Only called when debug: true.Resources
The client exposes one property per resource. All of them share the same auth and retry configuration from the constructor.transactions.list() takes { direction?: 'all' | 'inbound' | 'outbound', from?, to?, limit?, offset? } and returns a PaginatedList<Transaction>. It has no create, transactions are a read-only ledger produced by checkouts, subscription charges, and outbound sends.The money model
The SDK is strict about units, and the field name tells you which one you’re holding:Pagination
Everylist() method returns the same shape:
number
default:"20"
Page size. Capped server-side at 100 for
checkouts, paymentLinks, subscriptions, and customers; capped at 5000 for transactions and invoices.number
default:"0"
Number of records to skip, for the next page pass
offset + items.length from the previous response.Field casing
The REST API is snake_case (checkout_url); the SDK is camelCase (checkoutUrl) both ways: request bodies you pass in are already camelCase and go over the wire as-is (server DTOs accept camelCase), and every response body is deep-transformed from the server’s snake_case back to camelCase before it reaches your code, including nested objects and webhook payloads.
Error handling
Every failed call throws a subclass ofAgentaOSError (itself an Error) with a typed status, code, and optional requestId:
Next steps
Checkouts
Create, list, retrieve, and cancel single payment sessions.
Payment links
Reusable one-time and subscription payment URLs.
Webhooks
Verify signed event payloads server-side.
Errors
The full error hierarchy and retry/timeout behavior.