Skip to main content
Every SDK method returns a Result<T, OakError> instead of throwing exceptions. This gives you explicit control over success and failure paths at the type level.

The Result pattern

Result<T, E> is a discriminated union:
The SDK also exports ok() and err() helpers if you need to create Result values in your own code:

Error types

All errors extend OakError. Check the error class to determine what went wrong.

Handling API errors

ApiError is the most common error type. It contains the HTTP status code, the parsed response body, and response headers.

Retry configuration

The SDK includes built-in retry logic with exponential backoff. Configure it when creating the client.
The retry handler also respects the Retry-After header when the API returns 429 Too Many Requests.

Sandbox-only methods

Some operations are restricted to the sandbox environment. If you call a sandbox-only method in production, the SDK returns an EnvironmentViolationError without making a network request.
For more on environment behavior, see Environments.