instanceof — every error extends ApiError.
Typed errors
All errors carrystatus, code, message, requestId, and headers. ApiError.generate maps HTTP status to the right subclass:
| Class | When it throws |
|---|---|
ApiError | Base class for every error below. |
BadRequestError | 400 — malformed request. |
AuthenticationError | 401 — missing or invalid API key. |
NotFoundError | 404 — resource doesn’t exist. |
ConflictError | 409 — idempotency or state conflict (retried first). |
ValidationError | 422 — request body failed validation. |
RateLimitError | 429 — rate limited. Carries retryAfter: number | null. |
InternalServerError | 5xx — server error (retried first). |
ConnectionError | Network failure after retries are exhausted. |
TimeoutError | Request exceeded the configured timeout. |
Retries & idempotency
Requests retry on429, 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 aPagePromise<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 staticUnitPay.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.