The easiest way to move money with your AI agent. Built for TypeScript developers who want power, safety, and speed.
Quick Install
Node.js 20+ is required for full compatibility.
Environment Setup
Before you start, add your credentials to a.env
file in your project root:
Get these from your Payman dashboard after registering an app.
Authentication & Initialization
You can initialize the client in several ways, depending on your use case:Client Credentials (Recommended)
OAuth Authorization Code
Access Token or Refresh Token
Making Requests
Ask questions, send money, or trigger actions—all in one line.Formatted Response (default)
Raw JSON Response
Streaming Responses
Use
onMessage
for real-time updates, long-running tasks, or
progress monitoring. Streaming is ideal for workflows where you want to
process results as they arrive.Metadata
Attach metadata to requests for extra context and control over how your requests are processed:Session Management
Sessions allow you to maintain context across multiple requests. Each client
instance manages its own session by default, so you can have ongoing
conversations or workflows that remember previous actions.
How Sessions Work
- Every time you create a client, a new session is started unless you provide a
sessionId
. - The session ID is included in every response from
payman.ask()
. - You can use this session ID to resume a conversation or workflow at any time, even across different client instances or after a restart.
Resuming a Session
To resume a previous session, pass thesessionId
when initializing the client:
withToken
method:
Session management is essential for building conversational agents,
multi-step workflows, or any scenario where you want to maintain state
across requests.
Token Management
Tokens are fetched and refreshed automatically. You can also access them directly if needed:Tokens refresh automatically before they expire. If you provide a refresh
token, the SDK will use it as needed.
Error Handling
All API calls throw if something goes wrong. Catch and inspect errors as needed:API Reference (At a Glance)
Static MethodswithCredentials(config)
withAuthCode(config, code)
withToken(config, tokenInfo)
ask(text, options?)
getAccessToken()
getRefreshToken()
isAccessTokenExpired()
getSessionId()
getClientName()
Need help? Email us at
[email protected]