SDK Guide
The PayChain SDK is the recommended integration path for Node.js and TypeScript backends. It wraps the same public REST API with typed helpers, safer payout split handling, idempotency support, error mapping, and webhook verification utilities.Positioning note: Use the SDK when your backend runs Node.js or TypeScript. Use the REST API directly when you need another language, full HTTP control, or your own internal SDK.
Install
Create a client
What the SDK covers
- Customers.
- Invoices.
- Payout route attachment.
- Dynamic payout recipients.
- Withdrawals.
- Webhooks.
- Balances.
- Transactions.
- Networks.
- Tokens.
What the SDK does not cover
- Admin APIs.
- Dashboard-session flows.
- Route-template creation, archive, or delete.
- API key creation, rotation, or revocation.
- Billing mutation flows.
- Internal gas sponsorship controls.
- Wallet provider, network provider, signer, sponsored-gas, or treasury-private implementation details.
Idempotency
Every mutating operation should include an idempotency key.Customer deposit addresses
For reusable customer deposit-address flows, ensure the customer has an address for the rail before showing payment instructions.Invoice confirmation progress
Useinvoices.get to poll canonical invoice state while a payment is waiting for required network confirmations.
Fulfillment note: Wait for
paid or overpaid invoice status before fulfilling. Confirmation progress is for customer-facing visibility while settlement finality is still pending.Webhook verification
Webhook verification must use the raw request body.When to use REST instead
Use REST directly when:- Your backend is not Node.js or TypeScript.
- You need language-specific HTTP instrumentation.
- You want to build your own wrapper.
- You need to inspect exact request and response payloads.
- You are debugging endpoint-level behavior.