@useroutr/sdk is the official client for your server. It is written in TypeScript, ships its
own types, and has no dependencies beyond Useroutr’s type package.
Install
Quickstart
Sandbox and production
The key picks the environment, so going live is a change of key and nothing else.
Each environment refuses the other’s keys with a message that says so.
Options
baseUrl overrides the key’s environment, and so does the USEROUTR_BASE_URL environment
variable when baseUrl is not given.
Resources
Every method takes a last, optional argument with
idempotencyKey, timeoutMs and requestId.
Response types come from @useroutr/types and are re-exported by the SDK:
Pagination
list returns one page. iterate walks every page for you:
Errors
Every failure is aUseroutrError with code, statusCode, requestId, retryable and
details, and a subclass tells you the kind:
Retries and timeouts
Reads, and writes that carry an idempotency key, are retried on408, 425, 429, 500,
502, 503 and 504, on timeouts and on connection errors, up to maxRetries times, honouring
Retry-After. Writes without a key are
never retried, so a network error can never create a duplicate. A timeout surfaces as a
ConnectionError with code: "TIMEOUT".
A keyed write answered 409 IDEMPOTENCY_REQUEST_IN_PROGRESS is waiting on an earlier request
with the same key, often its own attempt that timed out while Useroutr carried on. The SDK asks
again for up to timeoutMs, without using up maxRetries, and returns that request’s result.
Creating a funding intent can take longer than the default 30 seconds, so this is how a default
client still gets its intent.
Webhooks
constructEvent verifies the signature and returns the typed event. See
Webhooks for complete handlers.
Anything else
request calls any endpoint directly and also returns the request id and whether an idempotent
call was replayed: