Overview
The SDK is configured once and exposes resource groups (invoices, tokens, commerce, events, websockets, etc.).Authentication
The SDK supports multiple auth contexts (set once or per request). Choose the minimum required for your surface:apiKey→x-api-key(merchant scope)commerceApiKey→x-commerce-api-key(commerce scope)bearerToken→Authorization: Bearer ...(dashboard JWT)userAccessToken→User-Authorization: Bearer ...(commerce user routes)sessionToken+signature→x-session-token+x-signature(payor/session browser-safe)
Request
Construct a client
Switch auth context
Response
The configured client will automatically attach the correct headers and defaults:Errors
401auth missing/invalid: verify the credential you configured matches the endpoint (merchant vs commerce vs payor).403forbidden: key may be scoped/suspended, or environment access may not be enabled.- Browser runtime error when using server keys: use session/ws tokens instead of server API keys.
Examples
Retries and timeouts
Browser safety
By default, the SDK rejects server API keys in browser runtimes. If you truly need to override this (not recommended), you must opt in:WebSockets
WebSocket usage requires awebSocketFactory (browser provides WebSocket; Node.js typically uses ws).

