Skip to main content
Every request retries transient failures automatically and throws a typed error on real ones. Discriminate with instanceof — every error extends ApiError.

Typed errors

All errors carry status, code, message, requestId, and headers. ApiError.generate maps HTTP status to the right subclass:

Retries & idempotency

Requests retry on 429, 409, and 5xx responses plus network errors, with jittered exponential backoff. A 429 honors the Retry-After header. POST and DELETE requests automatically carry an Idempotency-Key so retries never double-apply — pass your own via RequestOptions.idempotencyKey, or set a idempotencyKeyPrefix on the client. Tune retries and timeout on the constructor or per request:

Pagination

List methods return a PagePromise<T>. await it for a single Page<T> ({ data, hasMore, nextCursor, prevCursor }), or for await over it to stream every item across pages. toArray() collects them all.

Verifying webhooks

Verify inbound webhook signatures with the static UnitPay.verifyWebhook(body, headers, secret). It validates the Svix signature and returns the parsed, camelCased event; it throws if the signature is invalid.

Observability

Subscribe to raw request/response events for logging or tracing, and read the SDK version:

See also

Customers & subscriptions

Paginated reads.

Introduction

Install and instantiate.