REST API Guide
PayChain exposes the same core payment, payout, balance, transaction, network, token, billing, and webhook surfaces over HTTPS. The SDK is recommended for Node.js and TypeScript, but the REST API remains the source of truth for direct integrations.API positioning: PayChain is SDK-first for speed, but API-complete for teams that need direct HTTP access or non-TypeScript environments.
Base URLs
Required headers
Idempotency-Key on mutating requests so retries do not create duplicate invoices, withdrawals, or payout actions.
API key types
Common REST request pattern
Core REST examples
Create a customer
Ensure a customer deposit address
Use this before displaying a reusable customer address for a specific rail. Send the exactchain and networkId, then verify the returned address.chainFamily and address.networkId before showing the address to the payer.
Solana and Stellar use the same ensure pattern: call the customer address ensure endpoint for the exact rail and never fall back to an EVM 0x... address when a non-EVM address is expected.
The ensure endpoint:
- Returns the existing customer address when the customer already has one for the requested rail.
- Provisions a missing address when the business is configured for that rail.
- Returns
createdand address metadata so your backend can verify the rail before displaying payment instructions.
created: true when PayChain provisioned a new address, or created: false when the address already existed. Use the returned address.address only when the returned rail matches the requested rail, such as address.chainFamily: "sol" with address.networkId: "sol-mainnet" or address.chainFamily: "stellar" with address.networkId: "stellar-mainnet".
Lazy provisioning note: If
networkId is omitted and only one active network matches the requested rail, PayChain may infer it. Production integrations should still send networkId explicitly so the address-selection pattern stays consistent across Solana, Stellar, and future rails.Get an invoice after a webhook
Poll invoice confirmation progress
confirmationProgress.current, confirmationProgress.required, confirmationProgress.remaining, confirmationProgress.percent, and confirmationProgress.txHash.
List invoices for reconciliation
Quote and create a withdrawal
Read balances and transactions
amounts.total from amounts.totalHeld and amounts.requiresRecovery. Use amounts.total or withdrawal quotes for payout capacity.
Discover networks and tokens
Read billing and gas usage
Response handling
Store these values when available:- PayChain resource ID.
- Your own
clientReferenceorexternalRef. x-request-id.- Status.
- Amount, token, chain, and network.
- Webhook delivery ID.
- Transaction hash after settlement or payout completion.
Pagination
List endpoints may paginate. Keep pagination handling server-side and do not build business-critical reconciliation from a small client-side row limit.Errors
Expect structured errors with:- HTTP status.
- Machine-readable code.
- Message.
- Request ID.
- Details where available.
Webhooks
REST integrations should still use signed webhooks for real-time lifecycle changes.How REST maps to the SDK
See Supported networks and tokens before hardcoding any network or token assumptions.
Production checklist
- API keys stored in protected server-side secret storage.
- Idempotency keys on mutating requests.
- Webhook signature verification uses raw body.
- Standard and payout API keys are separated.
- Request IDs are logged without secrets.
- Sandbox and live credentials are separate.
- Payout destinations are validated server-side.
- Billing, gas credits, and payout quota behavior are understood.